- 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
‎04-27-2023 02:22 AM
Can you share the other part of the solution, the Interaction onChange of Opened for?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-27-2023 03:36 AM
Hi thank you for your response, I am not aware about this other part as I am new to such asks please help me to create this other part and requesting your assistance to allign me with steps to follow to get this acheived.
Please help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-27-2023 03:39 AM
localStorage here acts like a super global g_scratchpad.
Just like when using g_scratchpad, you need to do two things:
- add the data to it in a display Business Rule
- consume that data in Client Scripts.
With local storage it is the same, you need to do two things:
- add the data to it in a Client Script on Interaction - this would be the missing piece I am talking about and which @Weird is talking about.
- consume the data in a Catalog Client Script.
Just remember that this is super global, so if you have two Create Requests open, there might be trouble.
A complete solution would store the data separately per Create Request tab.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-27-2023 03:42 AM
Also, even in the post you referenced, the very last entry talks about creating an onChange Client Script too on Interaction.