How to set the value of a variable in a variable set for different Catalog Items
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2024 03:52 PM - edited 05-09-2024 04:09 PM
Hello,
I have a requirement to set the value of a variable created in a variable set. For instance, we have a Variable Set named "Regional Accounts" variable set. And in the variable set, we have a Variable named "Location". So, I was asked to set the value of that variable "LOCATION" for a particular Catalog Item because the value of "LOCATION" variable differs by the different Catalog Items we have.
How can I achieve this please?
Thanks in advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2024 03:54 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2024 04:10 PM
Hi @SAI VENKATESH,
I have a requirement to set the value of a variable created in a variable set. For instance, we have a Variable Set named "Regional Accounts" variable set. And in the variable set, we have a Variable named "Location". So, I was asked to set the value of that variable "LOCATION" for a particular Catalog Item because the value of "LOCATION" variable differs by the different Catalog Items we have.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2024 05:57 AM - edited 05-10-2024 06:01 AM
Hi @ID NOBLE
You can write a onLoad client script within the variable set and read the current catalog name and set the location column value.
function onLoad(control, isLoad, isTemplate) {
// Get the current catalog item
var catalogItem = g_form.getParameter('sysparm_catalog_view');
// Check if the catalog item name matches a specific value
// replace the catalog item sys_id
if (catalogItem === 'sys_id of catalog1') {
// Catalog item name matches, perform desired actions
// For example, you can display a message or set a field value
g_form.setValue("location", '<LocationValue1>'); // update the corrent variable name for location field
} else if (catalogItem === 'sys_id of catalog2') {
g_form.setValue("location", '<LocationValue2>'); // update the corrent variable name for location field
}
}
-Thanks,
AshishKM
Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution