Redirecting to URL in UI Action Script not Working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-30-2023 04:58 AM
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 :
Thank you in Advance
Bala
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-30-2023 05:19 AM - edited 03-30-2023 05:49 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-30-2023 05:38 AM - edited 03-30-2023 05:39 AM
Update your code with below line-
action.setRedirectURL(current);//current refers to the record where you have the ui action
Thanks,
Manjusha Bangale
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-30-2023 06:23 AM
@Balaraju K B try this
var rc = cart.placeOrder();
action.setRedirectURL(rc);
Bharath Chintala
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-30-2023 07:11 AM
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.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader