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)

Reload form when field value changes? (javascript)

(0) ShareShare
ReportReport
Posted on by 886

Hi,

I have set a realtime workflow to be running when the user saves the form. The workflow will finally set the boolean field des1_prerunworkflowcompleted to true.

I wan't the form to be reloaded, when the value is changed to true, how can i accomblish this?

I will like to get this displayed when doing so..

http://www.crmanswers.net/2014/10/the-xrmpagedatarefresh-method.html

Something like? (I know nothing about java). But I have added the following to a new form library, and then added it to the event handler (To des1_prerunworkflowcompleted, and selected on change). But nothing is happening...

It should load when the realtime workflow is running, changing the Boolean field des1_prerunworkflowcompleted to true..

// Refresh page

                    if (prerunworkflowcompleted == true) {

                    Xrm.Page.data.refresh();

}

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Community Member Profile Picture
    on at

    Hi,

    In that case you will set the value to true on save event of the form then you don't need to refresh the page

    you can accomplish by writing the simple javascript :

    function on_Save() {

    Xrm.Page.getAttribute("des1_prerunworkflowcompleted").setValue(true);

    }

    and registered this function on form save event.

    Please refer to below links for how to register and call the functions on onsave of the form :

    blogs.c5insight.com/.../How-to-use-Javascript-on-Dynamics-CRM-2011-2013-2015-form

    www.linkedin.com/.../how-on-demand-economy-reshaping-40-hour-work-week-alex-chriss

  • Suggested answer
    rskadk1 Profile Picture
    886 on at

    After reading your answer again. I think you misunderstood me. The reason why I want to refresh the page when that value is changed is to load some business rules (unhide fields)

    The JavaScript code should reload the page, so the business rules is loaded. But the page refresh should only happen when the realtime workflow have set the field to true. I guess the JavaScript will be triggered when the value is updated by the realtime workflow? The realtime workflow is running the first time the user saves the record..

  • Community Member Profile Picture
    on at

    then i would suggest use the javascript in place of real time workflow and refresh the page from their itself.

  • rskadk1 Profile Picture
    886 on at

    I cannot do that, I'm updating a lot of records. And that's very easy to make with a realtimr workflow. When those updates are done, I will set a "flag" that they are updated. At that point I wan't the form to be refreshed..

    It must be possible to make a very simple javascript that will update the form, when I set the flag that the workflows has completed. So when that field = yes. The form will refresh....

    For now I have the following - but I think it will need to be modified. So its called only on save. And only when the field "prerunworkflow" = true

    // Refreshpage

    function RefreshPage ()

    {

    Xrm.Page.data.refresh();

    }

  • Suggested answer
    razdynamics Profile Picture
    17,308 User Group Leader on at

    Hi Rskadk1,

    As far as i understand your requirement that you have few fields hidden by default you want that when workflow is executed and that flag is updated you would like to unhide some fields. Correct?

    Why do you want to reload page? Once you save the record form load event will fire again. Why dont you write Javascript on load of the form that will check if that flag is true than unhide fields like below.

    function onLoad()

    {

    // If it is true

    if (Xrm.Page.getAttribute("new_relationshiptype") != null && Xrm.Page.getAttribute("des1_prerunworkflowcompleted"))

    {

    if(Xrm.Page.getControl("field name")!=null)

    Xrm.Page.getControl("field name").setVisible(true)

    }

    }

    First point to remember Javascript wont fire through server side code.

    Does this help? Kindly Verify

    Best Wishes, Raz

  • rskadk1 Profile Picture
    886 on at

    Hi Raz,

    Thanks for your very detailed feedback. Your understanding is almost correct. I have a few fields "Locked" by default. And when the workflow is run (After the record is saved/created the first time) it will try to populate those fields. But however if it fails, the user should be able to manually insert a value. The workflow will however always (When al steps are run) set prerunworkflowcompleted = Yes.

    As for now the user have to reload the form for the business rules to kick in (Unlock fields if prerunworkflowcompleted = Yes). I wan't to avoid the user from reloading the entire page, when he creates the record, and it's saved the first time.

    My javascript skills is very limited, that's why I wan't a very simple javascript solution. And primary use business rules and realtime workflows.

    In conjunction to what you wrote "First point to remember Javascript wont fire through server side code". This means that a realtime workflow cannot get the form refreshed with javascript? I thought that a realtime workflow would be able to do this.

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