Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

UI Action Button is not coming in Service Portal

Sahil Raina
Mega Guru

I have created 2 UI Action Buttons "Approve"& "Reject"  in sc_req_item table:

find_real_file.png

How ever when I am checking the service portal only Approve button is visible and Reject button is not visible:

find_real_file.png

Reject button is configured as below screenshot and script and when I uncheck the "Client" option it is appearing but then it is not working as expected.

find_real_file.png

SCRIPT:

function testComments() {

if (g_form.getValue('u_work_notes_input') == "") {
g_form.addErrorMessage('Please provide your rejection comments in "Work Notes" field.');

return false;
} else {
// Bypass the check if the form has been modified

//g_form.modified = false;
g_form.setValue("u_custom_app_state", "rejected");
// gsftSubmit(document.getElementById('sysverb_update'));
g_form.save();
}
}

1 ACCEPTED SOLUTION

Sahil Raina
Mega Guru

Hello All,

I have figured it out.

I have created a "OnSubmit" client script as below:

find_real_file.png

and uncheck the "Client" option from my button and written a script:

current.u_custom_app_state='rejected';
action.setRedirectURL(current);
current.update();

 

View solution in original post

8 REPLIES 8

Sahil Raina
Mega Guru

Hello All,

I have figured it out.

I have created a "OnSubmit" client script as below:

find_real_file.png

and uncheck the "Client" option from my button and written a script:

current.u_custom_app_state='rejected';
action.setRedirectURL(current);
current.update();

 

and it is working on ITIL view as well in Service Portal.

Good to know you got what was expected but I guess original question was to understand why button does not show up. Did you try achieving it with above client script?

Hello Jaspal,

Sorry, If I was unable to explain my question properly. But my intention was to make it visible in service portal and work as expected.

and yes, I made the UI action button as server side only and write the below code in UI action:

current.u_custom_app_state='rejected';
action.setRedirectURL(current);
current.update();

 

and made a client script UI Type as "ALL" and write the client side code there with my condition.