Hello,
I have a JS code which runs on Account form onLoad and rollup field onChange - and copies the value from a rollup field to a temp field. I am using that temp field as a trigger in my workflow to set the account status accordingly.
However, I have noticed that whenever the system updates the rollup field, it does copy over to the temp field fine, BUT does not trigger the workflow since the form does not save after the temp field updates. I added lines of code to autosave. But it is not working as expected. Note that I do have auto-save turned on in System Settings, but the save does not trigger when the temp field populates.
function new_openopp () { var formOP = Xrm.Page.getAttribute("opendeals").getValue(); Xrm.Page.getAttribute("openopportunitiestemp").setValue(formOP); function AutoSaveForm() { if (Xrm.Page.ui.getFormType() == 2) { //only for form update var intervalId = window.setInterval( function () { window.clearInterval(intervalId); Xrm.Page.data.entity.save() }, 3000); } }}
Is there anything missing here? Would appreciate any help here.
Thanks,
Aneeqa
The blog post on how to manage AutoSave using JavaScript might help.
CRM 2013: JavaScript – How to Manage Form AutoSave - Microsoft Dynamics CRM Community
If this answers your question, please check it as verified.
What I meant by saying "Restructuring the cycle", that you will revamp all of this business (populate rollup field into temp field" by using another approach.
If you want to copy data from Rollup field (datatype Numbers) to another field with same datatype , you can use this approach in Business rules.
But If you work with two different fields types, so you can do a business rule also, to work with Rollup field ,for example
If rollup field greater than x , so put in Temp field a flag (lets say True)
Create this business rule with scope "Entity"
Then they will trigger your workflow
Do you mean using a business rule to populate temp field and that triggering the workflow?
But rollup field change cannot trigger workflow or business rule - that is the limitation. Can you please tell what you mean by restructuring the cycle?
Thanks,
Yes, you can re structured this cycle with WF, or Plugins
If I could update temp field with a workflow, I would not have gone with any other option. I cannot trigger the workflow with update of a rollup field, hence I had to do JS. But JS is not enabling the temp field update with form closed - which means that the user would need to go back to the form, open it - to enable JS to kick into action and run the workflow.
Ok JS not help in this situation because its a client side
Try to do your business in plugin or Custom Activity ,
Or you can do a workflow to update temp field then run the main workflow based on this field.
Hey,
Moving the save line in the first function helped. However, is there anyway to have the temp field populated when the form is NOT open? If the form is closed when rollup changes, the temp field does not populate. Since I have the code added to form onLoad as well, so when I open the account form, the temp field populates, form saves and status updates. But this is not a practical way.
How do I get the temp field to update from rollup with the form closed?
You may want to recalculate the rollup field in JavaScript, then copy the value to the temp field. This will ensure that you always have the correct value - vjcity.blogspot.com/.../refreshing-rollup-field-using-javascript.html
Hi,
as I understand you work with OnChange event to take the value from rollup field to temp field
and then the temp field trigger a workflow
so my question here is it save temp field when you open the record?
and also, did you try to move the save line under the last line in new_openopp function?
Daivat Vartak (v-9d...
225
Super User 2025 Season 1
Muhammad Shahzad Sh...
106
Most Valuable Professional
Eugen Podkorytov
87