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...
Answered

Lookup field value Overwritten Original value

(5) ShareShare
ReportReport
Posted on by 5,514
unexpected error
Categories:
I have the same question (0)
  • sandeepc Profile Picture
    5,514 on at
    .
  • André Arnaud de Calavon Profile Picture
    301,231 Super User 2025 Season 2 on at
    Hi Sandeep,
     
    Can you tell us what Dynamics 365 application this question is related to? There are several different solutions in the Dynamics 365 family, like: Sales, Finance, Supply Chain Management, Project Operations, and Business Central. 
  • sandeepc Profile Picture
    5,514 on at
    Sales @andre
  • Verified answer
    Jeevarajan Kumar Profile Picture
    781 Most Valuable Professional on at
     Hi Sandeep,

    Few things, by the looks of it, itseems that lookup field_2 is a polymorphic lookup field.
    Step1: Make sure that it's multi entity polymorphic field since you cannot set a "concatenated" value into a single lookup polymorphic field.
    Step 2: it seems there are few issues in the code. 1.  dont do JSON parse, use the object directly. 2. Don't use Split, its not a string as its an object. 3. Key issue here is the concat, try something like this rather
     
     // Merge and remove duplicates
        const merged = [...lookup field_2];
        lookup field_3.forEach(item => {
            if (!merged.some(existing => existing.id === item.id && existing.entityType === (item.entityType || item.logicalName))) {
                merged.push({
                    id: item.id,
                    name: item.name,
                    entityType: item.entityType || item.logicalName
                });
            }
        });
        formContext.getAttribute("lookupfield_2").setValue(merged);

    Please mark my answer as Yes if it helps!

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
iampranjal Profile Picture

iampranjal 51

#2
Martin Dráb Profile Picture

Martin Dráb 39 Most Valuable Professional

#3
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 26 Super User 2025 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans