SBX - Search With Button

SBX - Forum Post Title

Setting value on lookup field using JavaScript in crm portals

Microsoft Dynamics CRM Forum

Lester DSouza asked a question on 27 Dec 2017 12:25 AM
My Badges

Question Status

Verified

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. 

Reply
Lester DSouza responded on 27 Dec 2017 1:03 AM
My Badges
Verified Answer

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

Reply
Rizwan Aarif responded on 27 Mar 2018 1:47 AM
My Badges
Suggested Answer

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>


Reply
Ahmad Pirani responded on 28 May 2018 11:39 AM
My Badges

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

Reply
shahzebkhanniet@gmail.com responded on 9 Jul 2018 1:30 PM
My Badges

Nice

Reply
d365demystified responded on 11 Jun 2019 5:56 PM

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

Reply
Lester DSouza responded on 27 Dec 2017 1:03 AM
My Badges
Verified Answer

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

Reply
Rizwan Aarif responded on 27 Mar 2018 1:47 AM
My Badges
Suggested Answer

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>


Reply

SBX - Two Col Forum

SBX - Migrated JS