- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2024 11:48 PM
Good day!
I have created an incident form with some custom variables, and have mapped one of the custom vars to update the impact variable with an onChange CCSript.
Then there is a new response SLA that is triggered for this incident form.
So far so good.
Now what I need to achieve is have the SLA definition change base on that custom variable.
eg.
Custom variable is response and has 3 options 14, 19, 45.
CCSript sets impact to 1 for option 14, 2 for 19 and 3 for 45.
By default the response is set to 45 and is read only for non fulfillers.
The first time the script runs that is with the submission of the inc and the SLA 45 is triggered and attached on the said inc.
Afterwards, I change the response var to 19, fill in a worknote (it is mandatory) and hit save. The impact var doesn't change and the SLA 45 def does not get cancelled. Obviously as a result the SLA 19 does not get attached on the inc.
Attached the CCSript.
Any thoughts?
Thank you in advance!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2024 02:14 AM
Hello, I managed to change the SLA depending on a question that was on the form of the incident.
So case closed!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2024 02:27 AM
I don't see any script? But the reason for the SLA not changing is because the values aren't changing, so that's no issue. The issue is in the script, but without it, it's hard to assist.
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2024 02:30 AM
Hello @Mark Manders
Thank you for the reply, I've attached the script.
function onChange (control, oldValue, newValue, isLoading) {
// Check if the form is loading or if the new value is an empty string
if
(isLoading || newValue == '') {
return;
// Exit the function if the form is loading or the new value is empty
}
// Determine the impact based on the new value of sla_response
var impactValue;
if
(newValue == 14) {
impactValue = 1;
}else if
(newValue == 19) {
impactValue = 2;
}else if
(newValue == 45) {
impactValue = 3;
}
// Set the impact field to the determined value
g_form.setValue('impact', impactValue); }
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2024 02:55 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2024 03:18 AM
Let's start with some questions you will probably answer with 'do you think I'm stupid, of course I checked that', but I've been around a while, so let's ellimate the obvious first.
I assume the impact field is on the form and not read only? That is the first check. Then the values of your field: are those indeed the values you are adding, or the display values?
You are setting 'impactValue' as variable, but when the new value is not 14, 19 or 45, it will return undefined and you are setting that, so maybe make it the current impact value, instead of just defining the variable?
Next to that, it would help to get some info from what you are having by adding logging like this:
function onChange(control, oldValue, newValue, isLoading) {
console.log('Control:', control);
console.log('Old Value:', oldValue);
console.log('New Value:', newValue);
console.log('Is Loading:', isLoading);
// Check if the form is loading or if the new value is an empty string
if (isLoading || newValue == '') {
console.log('Exiting due to loading or empty new value');
return; // Exit the function if the form is loading or the new value is empty
}
// Determine the impact based on the new value of sla_response
var impactValue;
if (newValue == 14) {
impactValue = 1;
} else if (newValue == 19) {
impactValue = 2;
} else if (newValue == 45) {
impactValue = 3;
}
console.log('Impact Value:', impactValue);
// Set the impact field to the determined value
if (impactValue) {
g_form.setValue('impact', impactValue);
} else {
console.log('No impact value set for newValue:', newValue);
}
}
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark