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 CRM (Archived)

Xrm.Page.data.entity.save(); not working

(0) ShareShare
ReportReport
Posted on by 395

Hi,

I have problem:

I save my entity and then I change one lookUp field and save again, but it is not saved!
If I save only once - after the lookup field is change - it works.

What should I do?

thanks!

*This post is locked for comments

I have the same question (0)
  • Mahendar Pal Profile Picture
    45,095 on at

    Just to confirm are you setting the same lookup value again, if yest it won't fire.

  • NAOMI314 Profile Picture
    395 on at

    thanks!

    The lookUp field is empty.

    My code:

    function ChangeLookUp1() {

       Xrm.Page.data.entity.save();

        var lookup = new Array();

               lookup[0] = new Object();

               lookup[0].name = "new value";

               lookup[0].entityType = "entity1";

       Xrm.Page.getAttribute("lookUp1").setValue(lookup);

       Xrm.Page.data.entity.save();

    }

    also that I set different value it not saved.

    Any other idea?

    thanks!

  • Suggested answer
    Mahendar Pal Profile Picture
    45,095 on at

    Where is ID property?? To set lookup you need three properties, id, name and entitytype ?

    lookup[0].name = "new value";

    lookup[0].entityType = "entity1";

    lookup[0].id="GUID of the record"  //write here guid of the record that you want to set in lookup

    Thanks

  • NAOMI314 Profile Picture
    395 on at

    thanks!

    do not worry I set the Id:

    My full code:

    Xrm.Page.data.entity.save();

    .

    .

    .

    oDataQuery = "entity1?$select=new_entity1Id&$filter=lu1/Id eq guid'" + 111 + "';

           result = GlobalFunctions.getFirstRecordFromOData(oDataQuery); //GlobalFunctions is another js

           if (result != null) {

               var new_entity1Id = result.new_entity1Id;

               var lookup = new Array();

               lookup[0] = new Object();

               lookup[0].id = new_entity1Id;

               lookup[0].name ="aa";

               lookup[0].entityType = "entity1";

               Xrm.Page.getAttribute("lookUp1").setValue(lookup);

               Xrm.Page.data.entity.save();

    }

    As I have already written if I remove the first save the lookUp field is saved.

    Do you know why?

    thanks!

  • Mahendar Pal Profile Picture
    45,095 on at

    Can you try to directly hard code GUID value instead of calling this function just for the testing ?? and then check if the behavior is same, Is your function is asynchronous or synchronous ??

    Thanks

  • Verified answer
    Sanjaya Prakash Pradhan Profile Picture
    2,745 User Group Leader on at

    You have used Xrm.Page.data.entity.save() twice.

    Restructure your code to use this method once. As per my understanding when you write a .save() method the page gets posted back (round trip) to the server which overrides the next .save() request.

    My Suggestion is restructure your code to use one .save().

    You must remove one save method and use the last one only.

  • Temmy Wahyu Raharjo Profile Picture
    2,916 on at

    Do you already checked if the submit mode of the current attribute? If no, you can try to Xrm.Page.getAttribute("yourattribute").setSubmitMode("always") and test it.

  • Community Member Profile Picture
    on at

    That page will not working until you have to make that page really accomplish position of the overall work. As we using working page from the best essay pages to have some particulars circumstances of the question ideas.

  • Tristan Halliday Profile Picture
    5 on at

    Microsoft is known as the best version that is known to be the exciting offer. Although there is au.edubirdie.com review the site that conveys much reviews in presenting this showing details.

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 CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans