About Incident records.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2024 08:39 PM
Hi, I'm Kentaro.
I have a question about Incident records.
I want to prevent records from being closed when "Assigned to" is Null.
Therefore, I would like to implement the following functionality.
- If "Assigned to" is Null when the person in charge posts a comment, a popup will be displayed.
- If you select Yes, register the person in charge of posting the comment as "Assigned to".
I think there is no other way than using "Client Script" and "Script Include".
If there is an easy way to implement it, could you please give me an example?
Thanks,
Kentaro.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2024 10:59 PM - edited 04-21-2024 11:01 PM
You can do this by using confirm in a client script.
Basically something like this as a onSubmit client script should work:
function onSubmit() {
if (g_form.getValue('comments') != '' && g_form.getValue('assigned_to') == '') {
var answer = confirm("Would you like to register yourself as assigned to?");
if (answer) {
g_form.setValue('assigned_to', g_user.userID);
}
}
}
Edit: added check for comments not empty and assigned_to being empty.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2024 11:04 PM
you can use javascript confirm box with Ok and Cancel
If you wish to see Yes, No then you need to use UI page
Sample script using onChange client script on comments
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading) {
return;
}
var answer = confirm("Would you like to register yourself as assigned to?");
if(answer == true){
g_form.setValue('assigned_to', g_user.userID);
}
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader