Modify a cloned SC Catalog Item widget to redirect to specific URL
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-30-2018 11:49 AM
I'm looking to modify my cloned SC Catalog Item widget to redirect on submission to a specific URL. I only have two requirements:
- The redirect goes to Service Portal view of the Form page (id=form and view=sp)
- When the catalog item is submitted, it redirects to the sc_req_item table rather than the sc_request table
- Only in situations where it's a request; record producers redirect to the appropriate table
Right now, I've already cloned the OOB widget and modified the issueMessage function in the Client controller in the following way:
function issueMessage(n, table, sys_id) {
var page = table == 'sc_request' ? 'sc_request' : 'ticket';
if (c.options.page) {page = c.options.page;}
if (c.options.table) {table = c.options.table;}
//var url = spUtil.format(c.options.url, {page: page, table: table, sys_id: sys_id});
var url = "/tca?id=form" + '&view=sp' + '&table=' + table + '&sys_id=' + sys_id;
if (c.options.auto_redirect == "true") {
$window.location.href = url;
return;
As you can see, I've commented out the original url variable line and inserted my own below it. It achieves my requirement of redirecting to the SP view of the Form page. However,
- Is this the correct/Best Practice way of going about this?
- If not, what should it look like?
- How can I force a redirect to sc_req_item rather than sc_request?
Thanks in advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-19-2018 12:28 AM
Are you using a record producer or catalog items? or both? You have the option to configure the instance options, and set which successful order page you want it to redirect to. If you're using a record producer you can set the producer.portal_redirect = '?id=sc_req_item', this also requires you to check the auto-redirect on successful order in the instance options of the widget. Note that setting the instance options will affect all items you submit using that instance, but that seems to be your intended purpose.
I hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-20-2018 05:39 AM
We're using both. Most are catalog items/RITMs, but we have a couple record producers as well (Incident and Change Request).
I've messed around with the Instance Options for the SC Catalog Item widget but it's not producing the intended behavior.
- If I set a value for the Custom URL option (such as ?id=sc_req_item), nothing unique happens on redirect
- If I set a Successful Order Page, nothing unique happens on redirect
- If I set a Successful Order Table, it will always redirect to that table, which causes issues as either the record generated is not the same as the table (such as an incident RP redirecting to the sc_req_item table), or the sys_id isn't valid (such as the sys_id on submittal being tied to the sc_request record, rather than the sc_req_item record)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-21-2018 12:41 AM
Are you checking off the auto-redirect on successful order? I you don't all you should get is the notification with a link once you've submitted an item. The custom url format should have precedence over the successful order page. Did you try these options in the OOB widget?
For record producers you can add the redirect through the script field by adding the line producer.portal_redirect = '?id=sc_req_item' + <additional parameters>. This should work on jakarta and newer versions at least. I've had an issue earlier where a record producer does not trigger the issueMessage function due to number being undefined, but this should be fixed if you're using Kingston.
Have you tried console.log'ing the parameters to see what their actual values are? This might give an idea of where the issue lies.
LINKS: SC Catalog item widget Redirect after Record Producer