Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Suggested answer

Copying data from a Partylist field to a Lookup field (JavaScript)

Posted on by Microsoft Employee

Hello: I have the following code to the field value from a partylist field and set that to the value of a lookup field. It is not setting the value, so I would like someone to look at the code to see if there are any errors or suggestions, thanks!

OrganizerOnChangefunction () {
        var field = Xrm.Page.data.entity.attributes.get("organizer").getValue();
        if (field.getValue() != null) {
            var partylist = field.getValue();
            if (partylist.length > 0) {
                var lookupValue = new Array();
                lookupValue[0= new Object();
                lookupValue[0].id = partylist[0].id;
                lookupValue[0].name =  partylist[0].name;
                lookupValue[0].entityType = partylist[0].entityType
                Xrm.Page.getAttribute("sla_requestorid").setValue(lookupValue);
            }
        }
    },
  • Suggested answer
    a33ik Profile Picture
    a33ik 84,323 Most Valuable Professional on at
    RE: Copying data from a Partylist field to a Lookup field (JavaScript)

    Hello,

    Your code looks almost ok. Here is updated version you should check:

    OrganizerOnChange: function () {
            var fieldValue = Xrm.Page.data.entity.attributes.get("organizer").getValue();
            if (fieldValue && fieldValue.length > 0) {
                var lookupValue = [fieldValue[0]];
                Xrm.Page.getAttribute("sla_requestorid").setValue(lookupValue);
            }
        },

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