Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-07-2025 04:57 AM
Dear Members,
We have OnClick UI action on Incident record & below is the script which return the Ticket to Helpdesk group whenever required and then helpdesk agent transfer the ticket to other group.
We need to limit this UI Action in such a way that if the the ticket already returned 5 times to Helpdesk group. This UI Action should be freeze or disappear from the ticket so the ticket cannot be return anymore.
Please advise in the script what to add to achieve this case.
Script:
function ReturnToHelpdesk() {
if (g_form.getValue("work_notes") == "") {
g_form.setMandatory("work_notes", true);
g_form.clearMessages();
g_form.setValue('state',1);
getMessage("Work Note", function(msg) {
g_form.addErrorMessage(msg, "error");
});
}
gsftSubmit(null, g_form.getFormElement(), 'Return_To_Help_Desk');
}
if (typeof window == 'undefined')
Default();
function Default() {
var GroupName = gs.getProperty('Help Desk');
current.assignment_group = GroupName;
current.update();
action.setRedirectURL(current);
}
Solved! Go to Solution.
1 ACCEPTED SOLUTION
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-07-2025 05:26 AM
you need to have a custom integer type field to store the count and then increment it from server side each time button is clicked
UI Action condition
Your Existing UI Action Condition && current.u_count <= 5
Script Update
function Default() {
var GroupName = gs.getProperty('Help Desk');
current.assignment_group = GroupName;
current.u_count = current.u_count + 1;
current.update();
action.setRedirectURL(current);
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Regards,
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
5 REPLIES 5
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2025 03:07 AM
Hi All,
Thanks for your solution. I have followed Ankur's suggestion which have fulfilled my need.
Many Thanks