How to add Button in RITM- in Portal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2018 10:55 AM
Hi ,
when i click a button "Cancelled RITM" then RITM was going to be cancelled .
Script:
var appr=new GlideRecord('sysapproval_approver');
appr.addQuery('sysapproval', current.sys_id);
appr.query();
while(appr.next())
{
appr.state='rejected';
appr.update();
}
current.state=4;
current.update();
Same actions should be from PORTAL & Create Button
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2018 11:09 AM
Service Portal only exposes UI Actions inside the Form widget, if you want to expose it on the ticket page, you will need to develop a custom widget.
I have a quick tutorial that shows one way to do this:
https://serviceportal.io/create-custom-action-buttons-service-portal/
Hopefully that helps!
Nathan Firth
Founder and ServiceNow Architect
NewRocket, Inc.
nathan.firth@newrocket.com
http://serviceportal.io
http://newrocket.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2018 11:40 AM
Hi,
if we see here , i am calling two tables of data, in UI Action.
so how can i do it in Portal level script.
script: Tabel: sc_req_item
var appr=new GlideRecord('sysapproval_approver');
appr.addQuery('sysapproval', current.sys_id);
appr.query();
while(appr.next())
{
appr.state='rejected';
appr.update();
}
current.state=4;
current.update();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2018 12:47 PM
can i expect any updates please.
My script: WIDGET: TICKET FIELDS
HTML:
<button type="button" name="cancelled_ritm" class="btn btn-success btn-question" ng-click="c.action('cancelled_ritm')">${Cancelled RITM}</button>
SERVER:
var appr=new GlideRecord('sysapproval_approver');
appr.get($sp.getParameter('sysapproval', current.sys_id));
appr.query();
while(appr.next())
{
appr.setValue('state','rejected');
appr.update();
}
current.state=4;
current.update();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2018 01:35 PM
Keep in mind that the "ticket" page displays all sorts f records, not just RITM's. So you'll need to add some logic to only display when triggered on a RITM.
But you can try something like this:
var recordGR = $sp.getRecord(); // the current GlideRecord based on the table & sys_id in the URL
var appr = new GlideRecord('sysapproval_approver');
if (appr.get(recordGR.getUniqueValue())) {
appr.setValue('state','rejected');
appr.update();
}
recordGR.setValue('state',4);
recordGR.update();