- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-05-2024 11:47 PM
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-07-2024 01:46 PM
You can use getControl(). The only thing, it doesn't work on Service Portal. So as long as you are not using portal, it should be fine.
function onSubmit() {
var priority = g_form.getValue('priority');
var priorityControl = g_form.getControl('priority');
if (priority <= 2 && (g_form.isNewRecord() || priorityControl.changed))
return confirm(getMessage('High priority ticket will notify global team. Do you confirm on submitting a high priority ticket?'));
}
The other option is as suggested by JP to use onChange, which will run when the priority is changed by user. The only thing is, user needs to save again after the popup.
Please mark this response as correct or helpful if it assisted you with your question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-06-2024 03:54 PM
Hi Bowie,
If I understand well, you want to warn only if the priority changes to 1 or 2.
If so, I would rather go with a client script of type onChange:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '' || g_form.isNewRecord())
return;
else if (newValue <= 2)
return confirm(getMessage('High priority ticket will notify global team. Do you confirm on submitting a high priority ticket?'));
}
JP

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-06-2024 05:08 PM
You can probably use another condition g_form.isNewRecord()
For ex. if (g_form.isNewRecord() && priority<=2)
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-06-2024 06:04 PM
Thank you, this is great.
However, it does not cover the scenario where engineer change an existing ticket to P2/P1.
I created a similar script using State to track it, but still does not completely cover the above scenario

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-07-2024 01:46 PM
You can use getControl(). The only thing, it doesn't work on Service Portal. So as long as you are not using portal, it should be fine.
function onSubmit() {
var priority = g_form.getValue('priority');
var priorityControl = g_form.getControl('priority');
if (priority <= 2 && (g_form.isNewRecord() || priorityControl.changed))
return confirm(getMessage('High priority ticket will notify global team. Do you confirm on submitting a high priority ticket?'));
}
The other option is as suggested by JP to use onChange, which will run when the priority is changed by user. The only thing is, user needs to save again after the popup.
Please mark this response as correct or helpful if it assisted you with your question.