How to add Button in RITM- in Portal

chanikya
Tera Guru

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();

find_real_file.png

 

 

find_real_file.png

 

 

Same actions should be from PORTAL  &  Create Button

find_real_file.png

7 REPLIES 7

nathanfirth
Tera Guru

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

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();

 

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();

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();