The CreatorCon Call for Content is officially open! Get started here.

Redirecting to URL in UI Action Script not Working

Balaraju K B
Tera Expert

Hi Everyone,

I have created an UI Action on Custom Scoped Table and Written script to auto create an RITM by submitting the catalog item via script.

 

Issue 1 : I'm able to create the RITM using script but not able to Redirect to the Created RITM.(Please refer the script in the screenshot)

 

Issue 2 : Want to set the variable values dynamically using the current.<field_name> from the custom table which I have written the UI Action but its not working.

Please refer the below script :

BalarajuKB_0-1680177383631.png

Thank you in Advance

Bala

10 REPLIES 10

Uday_Kumar
Giga Guru

Hi @Balaraju K B You need to pass a parameter to action.setRedirectURL(); pass the parameter in between the parentesis. 

Change 16th line i.e., action.setRedirectURL(current);

Refer this onces: https://www.servicenow.com/community/developer-forum/what-is-action-setredirecturl/m-p/1745819

 

If my solution helps you please mark my Solution Accepted and Helpful.

Thanks and regards

Uday Kumar Valapudasu

manjusha_
Kilo Sage

@Balaraju K B 

Update your code with below line-

action.setRedirectURL(current);//current refers to the record where you have the ui action

 

Thanks,

Manjusha Bangale

BharathChintala
Mega Sage

@Balaraju K B  try this

 

var rc = cart.placeOrder();

action.setRedirectURL(rc);

 

If my inputs have helped with your question, please mark my answer as accepted solution, and give a thumb up.
Bharath Chintala

Ankur Bawiskar
Tera Patron
Tera Patron

@Balaraju K B 

try this

var cartDetails = cart.addToCart(item);
var checkoutInfo = cart.checkoutCart();

var parsedData = JSON.strinfify(checkoutInfo);

var reqNumber = parsedData.request_number;

var gr = new GlideRecord("sc_req_item");
gr.addQuery("request.number", reqNumber);
gr.query();
if (gr.next()) {
	action.setRedirectURL(gr);
}

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader