Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to run an onchange client script for a field which does not exist in the table but exist on form

Yash38
Kilo Guru

I'm using a common field on both Incident form and incident task form, 

on incident form i have written an on change client script to make the work notes mandatory whenever this fields value changes.

but in order achieve the same on incident task form im not able write an on change client script for this field as its originally created on incident table and not on the incident task.

 

How can i achieve this

 

Thanks in advance

2 ACCEPTED SOLUTIONS

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @Yash38 

 

What i understood is, you writing CS on Incident table but you want to apply the same in Incident task as well? If this is this the case It will NOT work. bcz worknotes on Inc and Inc task are extending from Task tables , so if your write CS on Task table then it will work for Inc task but it wil be global change and may impact other modules atleast change and Prb.

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

View solution in original post

If I understand you correctly, you have a dot walked field from incident on incident task. And when a user makes a change to the dot walked field on the incident task record, you want the work notes to be mandatory on incident task.If this is correct, then you cannot track client side changes on the dot walked field on Incident Task. You can use UI policy and in the filter conditions dot walk to the incident field, but again, you cannot track if that field has changed before updating the record.

  1. One solution will be to have the field created on the task table and track the changes there.
  2. The second solution, create a new field on the Incident task and then sync it with the corresponding field on the Incident. You can then run the Client script or UI policy on the Incident task table.
  3. The Third solution (quite custom), create a display business rule and save the dot-walked value in a scratchpad variable. Then create an onSubmit client script, and validate if the form value has changed by comparing it to the scratchpad value. If the value has changed, then you can prompt the user to add a worknote. Once filled in, you can update the form value as required. 

View solution in original post

9 REPLIES 9

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @Yash38 

 

What i understood is, you writing CS on Incident table but you want to apply the same in Incident task as well? If this is this the case It will NOT work. bcz worknotes on Inc and Inc task are extending from Task tables , so if your write CS on Task table then it will work for Inc task but it wil be global change and may impact other modules atleast change and Prb.

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Hi @Dr Atul G- LNG , if i select Task as a table then in onchange client script im not able to find the field i created on incident table, 
my only requirement is when this field value changes on Incident Task form, work notes should get mandatory
the only catch here is the field is originally created on Incident table and we have used it on incident task form by dot walking

Hi Mate,

 

if i select Task as a table then in onchange client script im not able to find the field i created on incident table, 

Atul: When you create the CS on task table, you can see only field of Task Table only. But the impact of that CS will be on child as well. 
my only requirement is when this field value changes on Incident Task form, work notes should get mandatory
the only catch here is the field is originally created on Incident table and we have used it on incident task form by dot walking

 

So in this case , if i create a CS on work notes on INC table and did not select the inhertied that it will get impact from task table else it will.

LearnNGrowAtul_0-1705925399572.png

 

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

If I understand you correctly, you have a dot walked field from incident on incident task. And when a user makes a change to the dot walked field on the incident task record, you want the work notes to be mandatory on incident task.If this is correct, then you cannot track client side changes on the dot walked field on Incident Task. You can use UI policy and in the filter conditions dot walk to the incident field, but again, you cannot track if that field has changed before updating the record.

  1. One solution will be to have the field created on the task table and track the changes there.
  2. The second solution, create a new field on the Incident task and then sync it with the corresponding field on the Incident. You can then run the Client script or UI policy on the Incident task table.
  3. The Third solution (quite custom), create a display business rule and save the dot-walked value in a scratchpad variable. Then create an onSubmit client script, and validate if the form value has changed by comparing it to the scratchpad value. If the value has changed, then you can prompt the user to add a worknote. Once filled in, you can update the form value as required. 

Amit Verma
Kilo Patron
Kilo Patron

Hi @Yash38 

 

Please have a look on the below post and see if it helps :

https://www.servicenow.com/community/developer-forum/using-client-script-from-parent-table-in-child-...

 

Thanks & Regards

Amit Verma


Please mark this response as correct and helpful if it assisted you with your question.