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)

Script to refresh leads page

(0) ShareShare
ReportReport
Posted on by

Is there a java script code where when the user hits the save button, it refreshes the lead record?

*This post is locked for comments

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

    Something weird is happening.

    I basically have a workflow which triggers when a field is modified and a field is equals to YES.

    Then I have this Javascript on the Form OnSave function...but it doesn't seem to behave the way I want it to.

    Even though the workflow checks if the field Value is YES then change the status of the lead to qualify, it also occurs when the field value is NO on certain occasions. I'm so puzzled by this, can anyone chime in?

    ==================

    function ReloadFormAfterSave(eventArgs) {

    var formId = Xrm.Page.ui.getFormType();

    alert(formId);

    if (formId == "2") { // in my case, I only want the reload to occur when updating

       setTimeout(function () {

           var id = Xrm.Page.data.entity.getId();

           var entityLogicalName = Xrm.Page.data.entity.getEntityName();

           Xrm.Utility.openEntityForm(entityLogicalName, id);

       }, 500);

    }

    }

    =============

  • Suggested answer
    Nick Plourde Profile Picture
    on at

    Hi teckwise,

    First, what version of CRM are you using?

    Anyhow, I would not use that to refresh your form. In the sdk of CRM 2013+ you have a function for that, Xrm.Page.data.refresh().

    Even without javscript, if your workflow is sync and scope is organization, after the save your value should be refreshing automatically. I'm currently working with CRM 2013 sp1 rollup 3 and it's working well.

  • Community Member Profile Picture
    on at

    Hi Nick, its CRM Online 2015 and it's not working as expected because I have an workflow running in the background that isnt insync w the save button which iw why im using javascript

  • MilindP Profile Picture
    1,019 on at

    Why do you want to refresh the page .... .does it for running onload function?

    if that is the case you can do following,

    Put the modified on field on the form and keep it hidden.  And on change of the ModifiedOn field call the function which executed for Onload of the form.

    Now when user updates the form and click on Save, the value in the ModifiedOn changes which triggers your unload function.

  • Community Member Profile Picture
    on at

    well the workflow is working by changing the lead status to qualified but does NOT refresh the lead when the workflow executes in the background. I thought perhaps refreshing the page will allow the new status to appear and would make sense for it to happen when the user hits save button

  • Community Member Profile Picture
    on at

    HI, thanks for this suggestion. I just tried it and it's still acting weird. If the user saves the form more than once within the minute, then the modified on doesn't change. The time doesn't go down to second, but minute.

    Secondly, the darn workflow is supposed to check if the value for the option list is yes and then qualify the lead. On certain situations, I am still able to qualify the lead when the option list is NO. Which makes me think the value on the backend isn't updating?

  • Community Member Profile Picture
    on at

    [quote user="Nick Plourde"]

    Hi teckwise,

    First, what version of CRM are you using?

    Anyhow, I would not use that to refresh your form. In the sdk of CRM 2013+ you have a function for that, Xrm.Page.data.refresh().

    Even without javscript, if your workflow is sync and scope is organization, after the save your value should be refreshing automatically. I'm currently working with CRM 2013 sp1 rollup 3 and it's working well.

    [/quote]

    Xrm.Page.data.refresh() - this keeps prompting a window that says my changes have not been saved, click cancel to save.

  • Community Member Profile Picture
    on at

    Ok - is there a way to qualify leads using javascript instead? I'll deactivate the work flow and just use Javascript that basically checks if the FLAG field equals YES, then change the status of the lead to Qualify.

  • Verified answer
    Cyclefitness Profile Picture
    on at

    tekwise:

    Are all the subject fields on the same form?   If so, why not just use Business Rules?

  • Suggested answer
    Nick Plourde Profile Picture
    on at

    Why don't you use a Sync Workflow? It acts like a sync plugin, so after the save when the page refresh automatically you'll see the change.

    Check this post to do it in javascript: community.dynamics.com/.../qualify-leads-without-creating-an-opportunity-via-a-soap-request

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