- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-27-2023 01:28 AM - edited ‎04-28-2023 12:21 AM
Dear Team,
I am following the below-solved URL to achieve that same requirement and tried the steps and script as provided in this:
In my case, I need to populate 'requestor' instead of 'requested for' of catalog item. Accordingly, I modified the onload catalog client script (screenshot and script below) as provided in the above URL-
Script:
function onLoad() {
//Type appropriate comment here, and begin script below
var reqContact = localStorage.getItem("lastname");
if (reqContact)
g_form.setValue('requestor', reqContact);
localStorage.clear();
}
After saving and testing, found it does not work as expected. Expectation is when user clicks on button 'Create Request' on Agent Workspace IMS record, it redirected user to a Service Catalog contains all Catalog items, then user selects any Catalog item per their requirement to create a request under that respective IMS record and when that catalog item form opens then its variable 'requestor' (part of a variable set in several catalog items and is of reference type Variable with Default Value set as 'javascript:gs.getUserID()' i.e., Currently logged in user) should reflect the same name as of 'opened_for' of its respective Interaction Record in Agent Workspace. But this is not working as expected as shown in below screenshots.
My testing Result:
Here Interaction record Opened for is 'David Miller'
when clicked on 'Create Incident', the 'service catalog' page opens on Agent workspace (shown in below screenshot)
Then here clicked on a catalog item- 'Access Change Request', it opens form but 'Requestor' of the form is Currently logged in user NOT David Miller (screenshot below)
This is intended to be the same as Opened for of Interaction record per Onload catalog client script written (screenshot and script provided above) because this request is opening through the 'Create Request' button on the Interaction record in the Agent workspace.
Please help me get this accomplished with a correct script to implement and steps.
Thanks in advance
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-27-2023 05:49 AM - edited ‎04-27-2023 05:50 AM
In the 1st script you only need to set the value.
You are setting it but also clearing it outright.
Of course because of the clearing, the other script will find no value.
You could also use sessionStorage in place of localStorage.
Thus the 1st script (Interaction onChange of opened_for) would be:
function onChange (control, oldValue, newValue, isLoading, isTemplate) {
sessionStorage.setItem('openedFor', g_form.getValue('opened_for'));
}
The 2nd script onLoad Catalog Client Script would be:
function onLoad () {
var openedFor = sessionStorage.getItem('openedFor');
if (openedFor)
g_form.setValue('requestor', openedFor);
sessionStorage.removeItem('openedFor');
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-03-2023 04:41 AM
That can be easily solved by declaring a default value for the variable. Hopefully it is a reference to user. In that case the default value should be
javascript: gs.getUserID()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-03-2023 04:42 AM
Note that : is an actual semicolon.
Just that this forum does not allow semicolon.
The whole world allows it, SN thinks it is more secure like that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-03-2023 05:24 AM
Thanks @-O- sir,
Pls help with the initiating steps to follow so that I can understand it and accordingly implement.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-03-2023 12:07 PM
Have a look at some variables that already exist in a Personal Developer Instance. For instance variable caller_id in Catalog Item Password Reset:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-23-2025 01:54 AM - edited ‎05-23-2025 01:54 AM
Hi, @-O-
The sessionStorage works fine. I have a follow up question. In agent workspace, there can be multiple interactions that can be worked. What happens, when the multiple interactions are modified and request is submitted for all of those catalog? The latest sessionStorage will be used for all the tickets, which might bring some issues. Any way to handle this?
Thanks in advance.