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 not working

Fred Abram III
Kilo Guru

Hello,

 

I am creating a new UI Action button to cancel a RITM and the associated child task as well as display an info message notifying the user that the record was canceled, however, when I click the button my page refreshes but the record is not updating. My log statements are not showing. When I try to run with the Client box checked the button does not work.

 

function cancelRITM() {
g_form.setValue('state', 7);

current.update();

gs.addInfoMessage('Task has been cancelled');

action.setRedirectURL(current);

}

 

Thanks

1 ACCEPTED SOLUTION

Oliver Stammler
Tera Guru

Hey @Fred Abram III,

you are mixing client and server side stuff in this script.
You need to do your client side stuff and then re-call the UI action by using the action name. Once you have called the action name, the server side script will be executed. 


Have a look at this ServiceNow support article for a detailed instruction: How to use client and server side code in UI actions without errors

 

If i was able to help you or even better to solve your query then please mark my comment Helpful and/or Correct.

Thanks and best regards

Oli

View solution in original post

2 REPLIES 2

Oliver Stammler
Tera Guru

Hey @Fred Abram III,

you are mixing client and server side stuff in this script.
You need to do your client side stuff and then re-call the UI action by using the action name. Once you have called the action name, the server side script will be executed. 


Have a look at this ServiceNow support article for a detailed instruction: How to use client and server side code in UI actions without errors

 

If i was able to help you or even better to solve your query then please mark my comment Helpful and/or Correct.

Thanks and best regards

Oli

Fred Abram III
Kilo Guru

Thanks, I was able to get it to work