- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-26-2020 06:36 AM
Hi all,
I have an urgent requirement
I have to create an UI action button name as 'close' on 'Issue table' that should be visible to only users having some role. when state is resolved in issue table. It should check that all the related "issue tasks"(child table of issue table) should be closed before closing the issues. If all the tasks are closed issues should also be closed.
I tried the code below but it is not working as expected
Condition - gs.hasRole('issue_mgmt_worker')
code-
var rec = new GlideRecord('u_issue_task');
rec.addQuery('u_parent_issues', current.sys_id);
rec.addQuery('state', '3');
rec.query();
if(rec.next()){
gs.addErrorMessage('All issue taks should be closed before resolving/closing issue ' + current.number + ' record'); // use valid number field
current.setAbortAction(true);
}
else
{
current.state='3';
current.update();
}
action.setRedirectURL(current);
Solved! Go to Solution.
- Labels:
-
Major Incident Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-26-2020 06:49 AM
Hi Vijay,
Did you try adding logs to check till where it is working fine
Check is the number field a valid field?
Should it not be u_number since it is your custom table
var rec = new GlideRecord('u_issue_task');
rec.addQuery('u_parent_issues', current.sys_id);
rec.addQuery('state', '3');
rec.query();
gs.info('Open Issue Tasks' + rec.getRowCount());
if(rec.next()){
gs.info('Inside if');
gs.addErrorMessage('All issue taks should be closed before resolving/closing issue ' + current.number + ' record'); // use valid number field
current.setAbortAction(true);
}
else
{
current.state = '3';
current.update();
action.setRedirectURL(current);
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-26-2020 07:15 AM
Hi All,
Thanks for Immediate reply
I tried to execute the code with rec.addQuery('state','!=','3'); but, it is directly executing the else condition in my code
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-26-2020 07:20 AM
Hi,
Did you check the state value is 3 for closed on your custom table
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-23-2020 03:07 AM
@vijay
Hope you are doing good.
Let me know if I have answered your question.
If so, please mark appropriate response as correct & helpful so that this thread can be closed and others can be benefited by this.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-07-2020 10:44 PM
Hope you are doing good.
Did my reply answer your question?
If so, please mark appropriate response as correct & helpful so that the question will appear as resolved for others who may have a similar question in the future.
Thanks!
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader