Turn Dynamics 365 address field into dropdown list - javascript

I’m new to both Dynamics 365 and javascript.
By now users when have to fill an address form write values manually, therefore for the same region we have values like: Lombardia, LOMABARDIA, lomb, Lombadia, etc...
I can't create custom fields because address fields are grouped into composite field and are used for outlook sync.
So i think the right way is create a javascript mask that paste the choosen value in the free text address field, but here is my biggest problem, how to set that mask...
Questions:
Is this the best practice? if not what is?
I am able to create javascript's list and get/set value from crm, but i dont know how to build it over a free text field, any help?

You should consider address resolution API, you will then be able to split the selected address that will be in a standard format. Try to check out Experian or even the google API, you can build a custom web resource, hook up the JS that will do address resolution for you, on selection split the values in the composite fields.

Rather than "build it over a free text field", which is unsupported, you can build your own custom HTML web resource and add that to the form.
As this document points out, you will need to use parent.Xrm.Page to reference the form - e.g.:
var customerRef = parent.Xrm.Page.getAttribute('customerid').getValue();
This forum indicates that although Xrm.Page is deprecated in v9, it is still valid (for now) to use parent.Xrm.Page from a custom web resource.
Also, please note that to enable accessing the form you should include
<script type="text/javascript" src="../ClientGlobalContext.js.aspx"></script>
in your custom web resource.

Related

Google Forms: Field is required error when setting it programmatically

I'm working on chrome extension for automating google forms submission.There is an <input> field of type date which is a required field. I'm setting the date programmatically before submitting it. But google forms assumes the date field is not set since I didn't edit it manually, and it's giving a *Field is required error while submitting. I'm able to submit if I set the date manually but I want it to be automated and programmatic.
I tried checking if there is a property on the input element which google forms checks to see if the value is set or not, but no luck. I believe frameworks like Angular/React have properties like dirty/pristine for this purpose but I need this in vanilla JS. I'm looking for a property which I'll be able to set in the javascript of the chrome extension.
I also want to note that a solution like making the input field not required won't be possible since the form is external and I can't alter the form in any way. I only have access to the chrome extension source code.

How to set the default type for an Activity Entity in Microsoft Dynamics?

I am refactoring some script code that is attached to the Fax Activity Entity in Microsoft Dynamics. In the script code I see:
document.getElementById("regardingobjectid").setAttribute("defaulttype", "2");
From what I understand, accessing the DOM from a Web Resource is unsupported in Dynamics. I would like to change this code to be something like the following:
Xrm.Page.getAttribute("regardingobjectid").setValue({defaulttype: 2})
Unfortunately, I can't find any documentation regarding setting the defaulttype property for the regardingobjectid field. I see some things about setting other properties, but none specifically for regardingobjectid. How can I set the defaulttype in a supported way?
You are correct that code is unsupported and should be avoided.
The regarding (regardingobjectid) field is a lookup field which allows many different entity types; contact, account, etc.
When a user opens the Look Up Record popup via 'Look Up More Records' link, it will display the default entity (account) first. The user can manually select a different entity type, but that requires more clicks.
In this case I believe the previous coder is trying to change the default entity type to contact. Google .setAttribute("defaulttype", "2") and there are plenty of hits describing the process.
I'm not 100% sure if there is a supported way to achieve this. Googling suggests there are a number of people trying to achieve this behaviour and struggling. There is a feature request open for this type of behaviour.
That said I believe using setDefaultView should work (MSDN).
Xrm.Page.getControl("regardingobjectid").setDefaultView("{00000000-0000-0000-00AA-000010001003}");
Where the Guid is the id of a contact view.
Related; Lookup contacts instead of accounts on emails in MS Dynamics CRM 2013

Submit user location in a form

I'm trying to figure out how to get the location of someone filling out a web form on my site. I just want to get it down to a state level for US and Country for international(although state or equivalent is fine international too). I just don't want the user to have to select from a super long list or fill out a field. So ideally something like a hidden field that could have javascript or php pass the info to it.
Any ideas?
You can try; http://www.w3schools.com/html/html5_geolocation.asp
And using Google API:
http://maps.googleapis.com/maps/api/staticmap?zoom=10&size=400x400&maptype=roadmap&markers=color:red%7Ccolor:red%7Clabel:C%7Cxx.xxxxxxx,xx.xxxxxxx&sensor=false
Using PHP or Javascript to replace the "xx.xxxxxxx"'s will give you a map of the users location.
You can probably use Google API to determine the users State, etc - as you mentioned. But I don't think you will be baby fed on this one.
You could try to figure out their location using their IP address. However, this is far from reliable. Unfortunately, if you need this data to be accurate, you're going to have to get them to give you their location.

City/Country - Post/Zip code matching/validation checking on web pages

I'm currently looking for possible ways to implement a post code/zip code checking mechanism on my "contact us" web page where the user selects a country and/or city and the system lists or validates the associated post/zip codes against the available and valid post codes in that region preferably through JavaScript or jQuery.
This can be done in JavaScript or jQuery with AJAX and a few MySQL queries, there are several free zipcode databases you can use... I wouldn't suggest trying to implement this as a standalone JavaScript or jQuery script...
Another option could be to validate the posdtcode using an addressing API (such as Postcode Anywhere's, the company I work for: http://www.postcodeanywhere.co.uk/support/webservices/PostcodeAnywhereInternational/Interactive/RetrieveByPostalCode/v2.2/default.aspx) to check for the presence of a Postcode as well as validating it's format. THis can be done easily via JavaScript. It would also allow you to validate that the city matches.

how to write a chrome suggestion service

When I type something in the address, the google suggestion service is offering an autocomplete.
I would like to write my own autocomplete... I tend to use yubnub and I need my own commands with autocomplete.
How can I do that?
Please advise,
Thanks,
-hbt
I use a variation of this code:
http://www.codeproject.com/KB/aspnet/Search_SuggestTextBox.aspx
Essentially, every time a key is pressed in the box, an ajax call is made and the textbox's value is passed to a PHP page that parses the typed text, makes sense of it, and displays a drop-down-like box that gives you selection options.
You can see my implementation on this page:
http://www.needthishere.com/index.php
Once the page loads, type a zip code in the appropriate box. This technique can be used for an type of auto-complete-lookup-type functionality.
Currently there isn't a way to hook into Chrome's address bar (called the Omnibar by the Chrome team) but there is a proposed extension API:
https://docs.google.com/a/google.com/Doc?docid=0AYUOdFfLVYFRZGZqNnQ2N2RfODFnMzg2a2NmZA&hl=en
This API would let you get events when then user types into the Omnibar, and return suggestions that would be displayed in the autocomplete section.
Currently, this is enabled as an experimental API, so you can probably start playing with it:
http://code.google.com/chrome/extensions/dev/experimental.omnibox.html
You'll need to follow these directions on how to enable experimental APIs for extension development:
http://code.google.com/chrome/extensions/dev/experimental.html
I haven't used this API myself, but it would be good to get any feedback you might have if you do wind up writing something. The best place for that would be to send a message to the Chromium extensions discussion group: http://groups.google.com/a/chromium.org/group/chromium-extensions/topics

Categories

Resources