web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Suggested Answer

Update form field from lookup field within quickview

(0) ShareShare
ReportReport
Posted on by 2
On my main form I have a lookup field called /Name/, when the user selects /Name/ a quickview is displayed, one of the fields within the quickview is a lookup field called /Course_Information/. I am trying to take /Course_Information/ and write that value into a field on the main form called /courseinformation/. 

Nothing happens the first time I select a /Name/ from the lookup field. When I remove the item /Name/ and select the /Name/ a second time, the below code then copies the quickview field into the form field.. Im unsure why this is happening. Any support would be appreciated 
 
function OnLoad1(executionContext) {      Xrm.Page.getAttribute(/nelep_studentapplication/).addOnChange(getQuickViewForm);}function getQuickViewForm(executionContext){var formContext = executionContext.getFormContext();var quickViewControl = formContext.ui.quickForms.get(/QuickviewControl1682435827537/);if (quickViewControl != undefined) {        if (quickViewControl.isLoaded()) {// Access the value of the attribute bound to the constituent controlvar CourseInformation = quickViewControl.getControl(0).getAttribute().getValue();var CourseID = CourseInformation[0].id;var CourseName = CourseInformation[0].name;var CourseType = CourseInformation[0].entityType;formContext.getAttribute(/courseinformation/).setValue([{ id: CourseID, name: CourseName, entityType: CourseType }]); // Unit Group                        return;        }        else {setTimeout(getQuickViewForm, 1, executionContext);        }    }    else {        Xrm.Utility.alertDialog(/No data to display in the quick view control./);        return;    }}
 
I have the same question (0)
  • ConnollyZ Profile Picture
    2 on at
    function OnLoad1(executionContext) {
       
       Xrm.Page.getAttribute("nelep_studentapplication").addOnChange(getQuickViewForm);
        
    }
    function getQuickViewForm(executionContext)
    {
    var formContext = executionContext.getFormContext();
    var quickViewControl = formContext.ui.quickForms.get("QuickviewControl1682435827537");

        if (quickViewControl != undefined) {
            if (quickViewControl.isLoaded()) {
                // Access the value of the attribute bound to the constituent control
                var CourseInformation = quickViewControl.getControl(0).getAttribute().getValue();
                var CourseID = CourseInformation[0].id;
                var CourseName = CourseInformation[0].name;
                var CourseType = CourseInformation[0].entityType;
            
                formContext.getAttribute("courseinformation").setValue([{ id: CourseID, name: CourseName, entityType: CourseType }]); // Unit Group
                
                return;
            }
            else {setTimeout(getQuickViewForm, 1, executionContext);
            
            }    
        }
        else {
            Xrm.Utility.alertDialog("No data to display in the quick view control.");
            return;
        }
    }
     
  • Suggested answer
    Leah Ju Profile Picture
    Microsoft Employee on at
    Hi Partner,
    Did you put the code on the onload event?
    --Try to add the web resource  directly on the field onchange event.
    Based on you description and code, you need get 'courseinformation' value from name entity and set 'Course_Information' field on current entity.
    --Essentially, you are trying to copy a field value from the parent entity (Name) to populate a field value in the current entity.
    So you can retrieve name entity to get value not through quick view control:

    Xrm.WebApi.retrieveRecord("Nameentity", "nameid", "?$select=_lookupname_value").then(
        function success(result) {
            console.log(result);
            // Columns
            var incidentid = result["incidentid"]; // Guid
            var accountid = result["_accountid_value"]; // Lookup
            var accountid_formatted = result["_accountid_value@OData.Community.Display.V1.FormattedValue"];
            var accountid_lookuplogicalname = result["_accountid_value@Microsoft.Dynamics.CRM.lookuplogicalname"];
        },
        function(error) {
            console.log(error.message);
        }
    );
    Or you can try to use workflow to achieve you goal easily.
  • Leah Ju Profile Picture
    Microsoft Employee on at
    Hi Partner,
    Was my answer helpful? 
    If it was helpful, can you verify it?
    If you have any questions, please feel free to contact me.
    Regards,
    Leah

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
#ManoVerse Profile Picture

#ManoVerse 93

#1
Siv Sagar Profile Picture

Siv Sagar 93 Super User 2025 Season 2

#3
Martin Dráb Profile Picture

Martin Dráb 62 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans