Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Refresh form after api update

Posted on by 105

Hello,

I'm creating a JS function onLoad of opportunity form, a JS function calls a custom action to do some operations then the custom action update attributes in the entity. actually I see updated fields when I refresh  twice, is there anyways to force the refresh ? I tried with Xrm.Page.data.refresh() in the answer of the webrequest call but it doesn't work.

Thank you

*This post is locked for comments

  • Suggested answer
    gdas Profile Picture
    gdas 50,085 on at
    RE: Refresh form after api update

    You can call a javascript function in onload event.

    Please note this is short of unsupported customization .

    function retrieveFieldValue ()

    {

    setTimeout(function(){

    //Call web api.

    }, 3000);

    }

  • Sskod Profile Picture
    Sskod 105 on at
    RE: Refresh form after api update

    Thank you,

    where do I put the timeout exactly? it didn't work, the data is not refreshed

  • Suggested answer
    gdas Profile Picture
    gdas 50,085 on at
    RE: Refresh form after api update

    Hello,

    I understand now your issue.

    In normal scenario if you received any data in client side you can set immediately to the UI , but in your case you need to reload as the data changes directly in Database and you don't have the data in client side.

    Seems you need to use settimeout  and after certain time you need to retrieve data through web API /FetchXML in client side and then set the value through JS.

    Hope this helps.

  • Suggested answer
    gdas Profile Picture
    gdas 50,085 on at
    RE: Refresh form after api update

    Hello,

    In normal scenario if you received any data in client side you can set immediately to the UI , but in your case you need to reload as the data changes directly in Database and you don't have the data in client side.

    Seems you need to use settimeout  and after certain time you need to retrieve data through web API /FetchXML in client side and then set the value through JS.

    Hope this helps.

  • SergeyT Profile Picture
    SergeyT 310 on at
    RE: Refresh form after api update

    Does by any chance your action use asynchronous workflows or plugins and subject entity isn't update immediately?

  • Sskod Profile Picture
    Sskod 105 on at
    RE: Refresh form after api update

    I get a loop of refresh with this :/

    Up

  • Suggested answer
    gdas Profile Picture
    gdas 50,085 on at
    RE: Refresh form after api update

    Hello,

    Though the page will reload everything but it will work using this.

    Xrm.Utility.openEntityForm(“<entity name>”, Xrm.Page.data.entity.getId());

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,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans