Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Setting value on lookup field using JavaScript in crm portals

Posted on by

Hi All,

Can anyone tell me how can i set the value on a lookup field using javascript in CRM portal form. I have tried using the following script :

$("arrtibute_id").val("attribute_GUID");
$("#attribute_entityname").val("entity_name");
but it didn't work for me can anyone suggest? Thanks in advance. 

*This post is locked for comments

  • Elie.Mouawad Profile Picture
    Elie.Mouawad 9 on at
    RE: Setting value on lookup field using JavaScript in crm portals

    $("#FIELDNAME_name").attr("value", $(this).attr("data-name"));

    $("#FIELDNAME").attr("value", $(this).attr("value"));

    $("#FIELDNAME_entityname").attr("value", "ENTITYNAME");

    Note: on the second line, no "_id", and it works.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Setting value on lookup field using JavaScript in crm portals

    Can someone help ? this is not working for me as well

  • d365demystified Profile Picture
    d365demystified 5 on at
    RE: Setting value on lookup field using JavaScript in crm portals

    I have made this work in D365 latest portal release let me know if anyone is still looking for solution

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Setting value on lookup field using JavaScript in crm portals

    Nice

  • Ahmad Pirani Profile Picture
    Ahmad Pirani 90 on at
    RE: Setting value on lookup field using JavaScript in crm portals

    Does not work anymore. At leas not on the downloaded ADX Portal.

  • Suggested answer
    Rizwan Aarif Profile Picture
    Rizwan Aarif 480 on at
    RE: Setting value on lookup field using JavaScript in crm portals

    Hi, It does not set value unless you put you code inside document.ready or on load event.

    You can use the code like below:

    <script>
      $(document).ready(function() {
        $("#defaultpricelevelid_name").attr("value", "{{pricelistName}}");
        $("#defaultpricelevelid").attr("value", "{{pricelistId}}");
        $("#defaultpricelevelid_entityname").attr("value", "pricelevel");
        
      });
    </script>


  • Verified answer
    RE: Setting value on lookup field using JavaScript in crm portals

    I was able to solve my problem. I wrote the following jquery which solved my problem
    $("attribute_name").attr("value","Name");
    $("arrtibute_id").attr("value","attribute_GUID");
    $("#attribute_entityname").attr("value","entity_name");

    I refered the following blog which helped me solve my problem
    Link: arpitmscrmhunt.blogspot.in/.../adxstudio-set-values-in-lookup-fields.html

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans