onSubmit Client Script triggering when viewing record history?

MBarrott
Mega Sage

I have an onSubmit Client Script which validates fields on a form and displays messages if certain criteria isn't satisfied. 

 

However I have found that this script will trigger when trying to view the history list of the record. No changes or updates are being made to the record. 

 

This is negatively impacting our users and there shouldn't be any cause for this script to fire. 

 

Any suggestions on how to resolve this?

1 ACCEPTED SOLUTION

Michael Jones -
Giga Sage

In your client script, you can check if g_form has been modified, so that it won't trigger unless a field value was changed. 

For example, inside of your onsubmit function, you would add a line like this at the top to skip the script if no fields were modified. 

  if(!g_form.modified){
    return true;
  }
I hope this helps!
Michael D. Jones
Proud member of the GlideFast Consulting Team!

View solution in original post

4 REPLIES 4

Ankur Bawiskar
Tera Patron
Tera Patron

@MBarrott 

I was able to verify this when I Right click -> History -> List

Seems like a platform bug.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Michael Jones -
Giga Sage

In your client script, you can check if g_form has been modified, so that it won't trigger unless a field value was changed. 

For example, inside of your onsubmit function, you would add a line like this at the top to skip the script if no fields were modified. 

  if(!g_form.modified){
    return true;
  }
I hope this helps!
Michael D. Jones
Proud member of the GlideFast Consulting Team!

Hi @Michael Jones -, this did the trick perfectly! Quick easy solution. Appreciate it. 

Siddhesh Gawade
Mega Sage
Mega Sage

Hello @MBarrott ,

 

You can "g_form.modified" in you script. It will true or false value. If the form fields are changed it will return and false if not. that way you can display messages based on this value.