How to stop Client Script to trigger when you update field from Related List

siva81
Kilo Contributor

Hi All,

I have a Client Script- OnChange which should prevent the users when they try to select the Approved status on the Change task form from the Status field. The script is working fine and showing an error message as expected when they select the Approved value from the Status field. But the problem I am facing is when the task is approved by the user from the Approvers tab that time also I am seeing the same error message as the script is written on OnChange. 

Is there a way to prevent the Client Script firing when the task is approved from the Approvers tab?

Any help is really appreciated!!

1 ACCEPTED SOLUTION

RKumar3
Tera Guru

Hi Siva,
This issue occurs when we approve an item from approver's related list and status of the item changes to "Approved" without form refresh. This is called live updating and we need to make sure that your script does not run when there is a live update on the field you have written your onChange client script on.

 

You need to add an if condition in your client script something like below and it should work.

 

if(!g_form.isLiveUpdating()){

////your code

}

 

Please mark my answer correct if it works.

 

Regards,

Rajnish Kumar

View solution in original post

16 REPLIES 16

Hi Dirk,

Thanks for your reply.

I haven't tried your solution yet. I will try and update you the results.

Thanks

Siva

 

 

siva81
Kilo Contributor

Hi Dirk,

Thank you so much for your help. Adding g_form.isLiveUpdating()) to the if section of the client script preventing the Client Script firing when the field is updated by the system.

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '' || oldValue == newValue || g_form.isLiveUpdating()) {
return;
}

 

H @siva

Thanks a lot the the feedback, I am happy that you solved the issue.

BR

Dirk

rajneeshbaranwa
Giga Guru

Why not remove Approved option from the state field conditionally using Client Script ? In that case user will not be able to see the option in the dropdown.

 

Please mark my answer correct/helpful, if it helped you

Hi Rajneeshbaranwal,

Thanks for your reply!

I can not hide the approved option completely using the client script for now because of other reasons. I would like to keep that as my last option.

Thanks

Siva