The CreatorCon Call for Content is officially open! Get started here.

After submitting Incident, Client Script stops working

cwmurphy
Mega Expert

Hello,

        I have a couple onChange Client Scripts that set two reference values based on other choices on the Incident form.   When a new Incident form is loaded, making changes to the Type, Subtype, and Category boxes will auto-populate our Business Service and Technical Service reference fields.  

Here is a screen shot of the top half of our Incident form when creating new:

find_real_file.png

As you see here, I have made changes to the Type, Subtype, Category fields and the Business/Technical Service was filled in by our Client Script:

find_real_file.png

If I change any of the values already selected on the left side of the form, the right side is set to blank and waits for proper values.   As long as this is a new record, this Client Script works without issue.   However, once saved, it stops working.   I can change the left side of the form, but nothing on the right changes as it's supposed to:

find_real_file.png

The Business Service for the above example should have been changed to: Shared Services - IT Software

The Technical Service for the above example should have been changed to: DB Hosting - Oracle

Is there something that I'm missing to have a Client Script work after a form is no longer a New Record?

1 ACCEPTED SOLUTION

cwmurphy
Mega Expert

After many hours looking into this and trying to find the reason it wasn't working, a solution has been found!   An onLoad script that set the cursor focus for the Incident Table was throwing an error when "isNewRecord" returned false.   It appears a field we put on the Incident Table a few months ago was removed.   That onLoad script was supposed to select that field.   It's now set to focus on Short Description and all of the above onLoad/onChange code works just fine.



Thank you to everyone that put in the time to debug with me.   This is the reason I enjoy being a part of this community.


View solution in original post

15 REPLIES 15

If there is a Type and Subtype, but not a Category, this code runs:


find_real_file.png


find_real_file.png



If there is a Type, Subtype, and a Category, this code runs:



find_real_file.png


find_real_file.png


Chris,



can you do one thing,add some log on second client script.



and after 18 row clear the existing u_business_service && u_technical_services values.


I get an error message stating that gs.log doesn't work in a client script and to use Alert instead.   So, I added alert info and it shows me exactly what I want it to, so long as the Incident is a new one.   After saving it, the Alerts no longer appear.


Michael Fry1
Kilo Patron

Is there any dependencies between the 3 fields?


If just the type changes, nothing will happen.   But if Type changes, and it clears the other 2 fields, these scripts won't run either.


When SubType script runs, it clear Category, which makes me think they are dependent on each other.



So if you just change Subtype, what happens?


If you just change category, what happens?


Type is a standalone Choice field.   Subtype is a Choice field, and is dependent on Type.   Category is a Choice field and is dependent on Subtype.   When the Incident is a new one, everything works.   After saving the Incident, nothing happens.