- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2022 01:22 AM
After the creation of a Request Item in the Portal, the user is redirected to the Order Status of the REQ, according to this:
What I want to achieve, its that the user should be redirected to the Request Item-page: sp?id=ticket&table=sc_req_item&sys_id=xxxxxxxxx
If I select 'ticket' in the Page Route Map, the user is redirected to the REQ-ticket and not the RITM-ticket.
I see there are various ways to achieve this, one of the alternatives is to clone the SC Catalog Item-widget, and change the client script as described here: How to dynamically redirect users to Requested Item page instead of SC Order Status page? - Customer...
But I'm not sure if this is the right way?
Any step by step instructions to do this would be highly appreciated.
Solved! Go to Solution.
- Labels:
-
Service Portal Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2022 09:42 AM
1.) Enter sp_page.list in the Filter Navigator and hit Enter
2.) Enter sc_cat_item in the ID column and hit Enter
3.) Open the record shown in the screenshot
4.) Scroll down and click the column that holds the SC Catalog Item-Widget
5.) Copy the Sys ID of the Column Page
6.) Enter sp_instance.do in the Filter Navigator
7.) Continue on step 2 of my previous post where it explains to set the column with the help of the sys_id you just copied.
Hope this helps you 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2022 07:51 AM
In order for this to work, you have to create a new sibling widget instance next to the 'SC Catalog Item' Widget Instance on the 'sc_cat_item' Page:
- Copy the SysID of the Column
- Add a new Instance (sp_instance) and select the Column manually by filtering via sys_id on the magnifying glass
- Order: 999
Widget: SC Request Redirect (see below)
Column: 1 (was set in step 2)
The 'SC Request Redirect'-Widget:
Name: SC Request Redirect
Server script:
(function() {
if (input && input.action == 'get_redirect_info') {
var scReqItemGr = new GlideRecord('sc_req_item');
scReqItemGr.addQuery('request', input.request);
scReqItemGr.setLimit(2); // only redirect of there is exactly one ritm in the request
scReqItemGr.query();
if (scReqItemGr.next() && !scReqItemGr.hasNext()) {
data.page = 'ticket';
data.table = scReqItemGr.getRecordClassName();
data.sys_id = scReqItemGr.getUniqueValue();
} else {
data.page = 'sc_request';
data.table = 'sc_request';
data.sys_id = input.request;
}
data.redirect_url = 'id=' + data.page + '&is_new_order=true&table=' + data.table + '&sys_id=' + data.sys_id;
}
})();
Client controller:
api.controller=function($rootScope, $location) {
var c = this;
// This event is emitted by the 'SC Catalog Item'-Widget once the item is submitted.
// The 'auto_redirect' has to be set to 'false' (string!) int the instance options of the 'SC Catalog Item'-Widget
$rootScope.$on('$sp.sc_cat_item.submitted', function($event , data) {
if (data.table == 'sc_request') {
c.server
.get({ action: 'get_redirect_info' , request: data.sys_id })
.then(function (response) { $location.search(response.data.redirect_url); });
} else if (data.redirect_portal_url) {
$location.search(data.redirect_portal_url);
} else {
$location.search('id=form&table=' + data.table + '&sys_id=' + data.sys_id);
}
});
};
Now you only have to set the following in the Instance for the 'SC Catalog Item' widget:
By default the 'SC Catalog Item' widget will automatically redirect to the sc_request page, but if you set auto_redirect to false, it will then submit the event captured by the 'SC Request Redirect' Widget.
Please let us know if this solved your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2022 03:25 AM
The best solution of all! Worked like a charm, non customized solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2022 05:28 AM
You're welcome 🙂
If you do not need any further assistance, please mark the answer as the "solution" to close the thread.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2022 04:09 AM
Hello Markus,
Thank you for your answer. Can you please describe the steps as it was meant to be read by a newbie. I'm not really sure where to find the SysID of the Column. And what column.
Thank you in advance!