Notifications
Announcements
No record found.
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
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);
}
=============
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.
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
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.
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
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?
[quote user="Nick Plourde"]
[/quote]
Xrm.Page.data.refresh() - this keeps prompting a window that says my changes have not been saved, click cancel to save.
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.
tekwise:
Are all the subject fields on the same form? If so, why not just use Business Rules?
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.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
SA-08121319-0 4
Calum MacFarlane 4
Alex Fun Wei Jie 2