Dynamics CRM How to access a QuickForm component via Jscript in Turbo Forms

 

In Legacy forms we used to have the possibility of getting the primary contact’s email address of an account by using a syntax like this:

image

 

The syntax is documented in this article: https://msdn.microsoft.com/en-us/library/gg334266.aspx

This sample code would prompt the following field in an alert dialog, which belongs to the primary contact of the account.

clip_image001

However, in the new Turbo forms this is no longer possible, because in order to improve e performance when the form loads, we don’t make accessible the QuickForm components through this type of Jscript syntax.

There is, however, a simple workaround, which consists on using the REST endpoint to retrieve the related contact, so we can then access any of its attributes.

To do that, we need to include the SDK_JQUERY library into our web resources, or copy and paste the retrieveRecord function from it.

To add the library, we go to: Settings – Customizations – Customize the System – Components – Web Resources – New – Web Resource.

Put SDK_JQUERY as name, and Jscript as type. Make it point to the path: yourSdkFolder\SampleCode\JS\RESTEndpoint\JavaScriptRESTDataOperations\JavaScriptRESTDataOperations\Scripts\SDK.REST.

Then save and publish.

Now go to the Account form – Properties – Events – Form Libraries - Add,

We will add here the sdk_query library, like this:

clip_image002

Plus a new library called “getControls.js” that will contain the following code in it:

image

Then add an Event Handler, in the onSave event, and type “myOnSave” on the Function field:

clip_image002[5]

After that, save and Publish the form, and reload the UI with F5 to test it.

When your form is saved, you’ll see an alert message on screen which in this case will say the email address of your primary contact.

Best Regards

EMEA Dynamics CRM Support Team

 

Share this Blog Article on Twitter

Tweet

Follow Us on Twitter

Follow @MSDynCRMSupport

Comments

  • Anonymous
    September 29, 2015
    It also seems that Turbo Forms also affects controls that are in the header and footer of the form?