- 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-27-2025 08:29 AM
Hello @Vidhya A ,
Do you really mean Agent Workspace? That is old.
Anyway on the interaction form there is a button that creates requests out of interactions.
That allows one to pick the Catalog Item in a portal dedicated for this, automatically copies the interaction caller into the requested for variable.
Why not just use that?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-28-2025 06:49 AM
We are using Service operations workspace, not the old agent workspace. We are using the "Create request" option and we want to copy more details from interaction to request before it is submitted, like, language, location, caller, description, etc.,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-29-2025 05:39 PM
When an item is loaded in the iframe running the swp portal, the iframe will contain information about the source record.
The Catalog Item widget "gets" the source table and sys. id. using code:
var workspaceParams = {};
workspaceParams.sysparm_parent_table =
$window.frameElement.getAttribute('parent-table') || $window.frameElement.dataParentTable;
workspaceParams.sysparm_parent_sys_id =
$window.frameElement.getAttribute('parent-sys-id') || $window.frameElement.dataParentSysId;
Change that to
var workspaceParams = {};
workspaceParams.sysparm_parent_table =
self.frameElement.getAttribute('parent-table') || self.frameElement.dataParentTable;
workspaceParams.sysparm_parent_sys_id =
self.frameElement.getAttribute('parent-sys-id') || self.frameElement.dataParentSysId;
and you have the source table and the source sys. id. and it's a GlideAjax call from there to obtaining whatever you want about the parent record - as long as it is saved (which it should be, as - if I remember right - one cannot click the "Create Request" button without 1st saving the interaction).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-27-2023 02:26 AM
I'm not sure of what kind of setup the example solution had or if workspace already sets values in localStorage, but how about creating a client script on your IMS record table that would set the localStorage value?
localStorage.setItem("lastname", g_form.getValue("field_with_value");
After that has been set, you should be able to access the value. You might want to create a onLoad script to store the value when form is viewed.
Now when you end up in the catalog item you should be able to use getItem to get that value.
Also make sure to check what values you're getting.
For example
localStorage.setItem("lastname", g_form.getValue("field_with_value");
var x = localStorage.getItem("lastname");
alert(x);
This would create an alert popup that shows you what value you've stored. Also on the catalog item you could create an alert to see what value you're getting from the local storage at that point.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-27-2023 03:34 AM
Hello @Weird Sir, thanks for response.
I am totally new to this localstorage kind of stuffs. what changes you made, also I did not created any client script on IMS record table that would set the local storage value. please help me with that client script in my scenario to set the storage value
Further how can I get its solution pls assist with screenshots, so that I can understand it with correct means and good for me to learn as well. Hope you will help me out