Client Script to Set values When Incident State changes to closed for a particular caller

Michael Nash2
Mega Expert

I need assistance with a Client Script to Set values When Incident State changes to closed for a particular caller.

 

I need to set the fields as follows when the Incident state changes to closed.

Close Code - Closed/Resolved by caller

Close Notes - Closed by Caller (Joe Soap)

Closed by -  Caller (Joe Soap)

9 REPLIES 9

Sujit Poojari1
Tera Contributor

Hi Michael,

I'm assuming you are manually closing the incidents created by API with caller as "Application Manager".

To remove the alert, you may comment the alert line in the script.

//alert(stateValue);

And in order to execute this client script for only incidents in which caller is "Application Managers", you can add a condition in the script as below:
if(newValue==7 && caller == 'bdf7f0d5db19874009cffd141d961968')


Regards,
Sujit Poojari

Michael Nash2
Mega Expert

Hi Sujit

 

We are not closing this manually, it will be closed from Application Manager via the API.

 

I will test the above and let you know.

Hi Michael,

Does the given script work for you?

If yes, would you mind mark the answer correct or helpful to close the thread.

 

Thanks.

Michael Nash2
Mega Expert

Hi, 

 

The script is working to a point for when i manually close the incident. (It fills in the correct data)

 

But as soon as i click update it removes the data and sells me its an 'invalid update'.

 

Please see the screenshots, the script is not working at all however when the Application manager API changes the state to closed.

Hi Michael,

 

If you're updating the record via web-services using REST or SOAP you'll need to use a business rule to automate the fields. Clients scripts run when users are interacting with the form via the client (web browser), i'm assuming your user, Joe Soap, is a web services only user updating the record via the SOAP API so he (it?) is not interacting with the form via the client.

 

You should be able to use a before update business rule triggered when the incident state changes to closed and the updated by user is Joe Soap. You can then use the actions tab to set the field values, no need to script anything to fulfill this.

 

I've made a few assumptions here so feel free to correct me if i've got the wrong end of the stick.

 

Cheers

Dave