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)

View does not update upon save and close

(0) ShareShare
ReportReport
Posted on by

Hello,

 

I have a script which adds the latest note in a hidden field, and is subsequently displayed on one my views for the proposal entity. However, when I went to test it by adding a note, the view did not update upon clicking save and close. Only when I reopen the proposal, click save, and close the window did the view update. Is there a way to work around this issue so that the view updates when I click save and close?

*This post is locked for comments

I have the same question (0)
  • FinneyA Profile Picture
    325 on at

    Try:

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

  • Community Member Profile Picture
    on at

    I tried this, but the form does not refresh, therefore the latest note does not appear in the view until I open the form again, causing the page to reload and therefore refresh the form. What I am looking for is for the form to refresh when the user clicks save and close on the form.

  • Verified answer
    Community Member Profile Picture
    on at

    After doing some research, I have found out what the issue was.

    In my function, I was retrieving the data from the note field asynchronously. This may have resulted in the control returning to the user before the code was executed and the field was populated on the form. Therefore, this resulted in the information not being brought over when I clicked save and close. Once I made the request synchronously, I had no issues with the view update upon clicking save and close.  Here is the code with the synchronous JSON request for anyone who may be interested in it:

    function GetLatestNote() {

    var req = new XMLHttpRequest();

    req.open("GET", encodeURI( Xrm.Page.context.getClientUrl() + "/XRMServices/2011/OrganizationData.svc/AnnotationSet?"  + "$select=NoteText&$filter=ObjectId/Id eq guid'"+Xrm.Page.data.entity.getId()+"'&$orderby=CreatedOn desc&$top=1"), false);

    req.setRequestHeader('Accept', 'application/json');

    req.setRequestHeader('Content-Type', 'application/json; charset=utf-8');

    req.send(null);  

    var note = JSON.parse(req.responseText).d;

    var results = note.results;

    var NoteText  = results[0].NoteText;

    var newnote = Xrm.Page.getAttribute("new_lastcomment").setValue(NoteText);

    }

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