Hi
Scenario
Field a: lookup field
Field b: lookup field
Based on lookup field a . value should autopopulate in lookup field b .
How is that possible . any suggestions will be marked as verified
ASAP
Hi
Scenario
Field a: lookup field
Field b: lookup field
Based on lookup field a . value should autopopulate in lookup field b .
How is that possible . any suggestions will be marked as verified
ASAP
Hi ,
Please Do watch this Blog for Auto Populating Lookup Field Values
dynamics365starsolutions.blogspot.com/.../auto-populate-lookup-values-using.html
Hope it is Helpful for You
Hi,
use below code to fill lookup B based on lookup A
function fillLookup(executionContext) { var formContext = executionContext.getFormContext(); var lookup = formContext.getAttribute("new_state").getValue(); if (lookup != null) { var lookunfieldStateId=lookup[0].id; Xrm.WebApi.online.retrieveMultipleRecords("new_city", "?$select=new_name&$filter=_new_state_value eq " lookunfieldStateId "&$orderby=createdon desc&$top=1").then( function success(results) { for (var i = 0; i < results.entities.length; i ) { var new_name = results.entities[i]["new_name"]; var new_cityid = results.entities[i]["new_cityid"]; var value = new Array(); //create a new object array value[0] = new Object(); value[0].id = new_cityid; // set ID to ID value[0].name = new_name; //set name to name value[0].entityType = "new_city"; //optional formContext.getAttribute("new_city").setValue(value); } }, function(error) { Xrm.Utility.alertDialog(error.message); } ); } }
I have use order by created on field desc and applied top1 to get first record. You can change this as per your logic
Add this function on onchange of Lookup field A.
I have tested this code my trial instance and it is working.
Any suggestions
When I open record and select lookup field a . it should auto populate . both the fields are mandatory and workflow also did not triggered
But value should display before creating record or updating record it should auto populate .
Hi I believe that the best approach would be using a business rule.
docs.microsoft.com/.../create-business-rules-recommendations-apply-logic-form
Can you pls help me by sending links or any similar code which will be helpful
Hi,
If we have relationship added between Lookup A entity record with Lookup B entity record then we can write JS on change of Lookup field A and get Lookupfield B using xrm.webpi. Then set the value of Lookup B.
Question is what if we have multiple records for a lookup field A value? Which value to be to autopopulated?
Is it based on modified on/created if that is the case you could add Top1 in web api.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,280 Super User 2024 Season 2
Martin Dráb 230,214 Most Valuable Professional
nmaenpaa 101,156