Posts

Showing posts from December, 2016

How to Set field values in CRM through parameters passed to a new form using JavaScript

Image
In this blog I am showing how we can add default values to the new form when open new form. You can set default values for new records created by users by specifying attribute values in the URL that is used to open the form. For this you need to add a Button placed on the form(Existing Record) and on click of this button we'll copy data to the new form from the existing record. In this example I placed a button of account entity form which is enable only if record exists and on click of this a new form opens with few values copied to new form using parameter passed in URL. Add code as shown below function GetIdFromLookup(lkpFieldSchemaName) {     var lkpField = null;     var sGuid = null;     lkpField = Xrm.Page.data.entity.attributes.get(lkpFieldSchemaName);     if (lkpField != null && lkpField.getValue() != null)         sGuid = lkpField.getValue()[0].id;     return sGuid; } function GetNameFromLookup(lkpFieldSchemaName) {     var lkpField = null;
go to top image