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.

5 comments:

  1. How can i fire the event after setting the lookup

    ReplyDelete
  2. Use javascript event handler on change

    ReplyDelete
  3. I'm using web forms, I have tried the script and it is working fine default value is getting populated in the lookup filed but when i click on the next step the value is not getting save to the lookup filed its throwing an error that the lookup field should have a value and save your changes. please suggest

    ReplyDelete
  4. Step 2 reads:
    $(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");
    });

    Just check again, the field references are not 100% correct. It should read

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

    Missing "id" on the second and fourth line. But very helpful, thanks!

    ReplyDelete
  5. Special thanks to (hackingsetting50@gmail.com) for exposing my cheating husband. Right with me i got a lot of evidences and proofs that shows that my husband is a fuck boy and as well a cheater ranging from his text messages, call logs, whats-app messages, deleted messages and many more, All thanks to

    (hackingsetting50@gmail.com), if not for him i will never know what has been going on for a long time.

    Contact him now and thank me later.

    ReplyDelete

Blogger Widgets