Friday 30 September 2016

ADXStudio - Set values in Lookup fields of Entity Forms

This is one of the common requirement in ADXStudio to set values in Lookup Fields in Entity Forms. Initially it was very difficult for me to get the solution of this but finally i got the way. Here is the solution :

Suppose we are exposing Case Entity Form on ADXStudio Portal and we have a Customer Lookup on that form and i want to set value in this lookup field-

Step 1 : Get Lookup IDs

Right Click on Lookup Field and Click Inspect to see rendered HTML or press F12. You will find three IDs of that lookup field:

Name ID ; customer_name
Guid ID : customerid
EntityName ID : customer_entityname

Same for other lookup you will find same IDs but with different names.

So same as CRM Lookups, ADXStudio also keep three values for each lookup rendered on portal forms.










Step 2: Set values in Lookup Fields

Write below JavaScript in Custom JavaScript Section of Entity Forms

$(document).ready(function(){
    $("#customer_name").attr("value","A J E CALDER LTD");
    $("#customerid").attr("value","0a4d0c86-4253-e611-80f0-5065f38b75b1");
    $("#customer_entityname").attr("value","contact");
});


In first line i have set the name of record, in second line i have set the guid and in third line i have set the name of entity to which this record belongs.

So this way we can set value in any of the lookup field in ADXStudio Entity Forms.

Blogger Widgets