- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2023 04:04 AM
I am working on a requirement to add a message 'VIP user' to the caller field if the user selected in the reference field is VIP. I have achieved this simple configuration, but I am unable to configure it in such a way that it is limited to the Service Operations Workspace view.
If I check the global view option, then the script works as expected in all views. But I want to limit the operation to Service Operations Workspace only.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2023 11:26 AM
"workspace" is the legacy agent workspace view. There is another view used by Service Operations Workspace called "sow".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2023 12:19 PM - edited 04-11-2023 12:19 PM
To limit the application of the script to the Service Operations Workspace view only, you can add a condition to check the current view before running the script.
Here's an example of how you can modify your script to achieve this:
function onChange(control, oldValue, newValue, isLoading, isTemplate) { // Check if the current view is the Service Operations Workspace if (g_view_name != 'sn_sops') { return; } // Check if the user selected in the reference field is VIP var user = g_form.getReference('caller', function(reference) { if (reference.vip == true) { g_form.setValue('caller', reference.display_value + ' [VIP user]'); } }); }
In this modified script, we added a check for the current view using the g_view_name global variable.
If the current view is not the Service Operations Workspace (sn_sops), the script will simply return without executing further.
If the current view is the Service Operations Workspace, the script will continue to check if the user selected in the reference field is VIP, and add the 'VIP user' message to the caller field if necessary.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2023 11:26 AM
"workspace" is the legacy agent workspace view. There is another view used by Service Operations Workspace called "sow".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2023 12:19 PM - edited 04-11-2023 12:19 PM
To limit the application of the script to the Service Operations Workspace view only, you can add a condition to check the current view before running the script.
Here's an example of how you can modify your script to achieve this:
function onChange(control, oldValue, newValue, isLoading, isTemplate) { // Check if the current view is the Service Operations Workspace if (g_view_name != 'sn_sops') { return; } // Check if the user selected in the reference field is VIP var user = g_form.getReference('caller', function(reference) { if (reference.vip == true) { g_form.setValue('caller', reference.display_value + ' [VIP user]'); } }); }
In this modified script, we added a check for the current view using the g_view_name global variable.
If the current view is not the Service Operations Workspace (sn_sops), the script will simply return without executing further.
If the current view is the Service Operations Workspace, the script will continue to check if the user selected in the reference field is VIP, and add the 'VIP user' message to the caller field if necessary.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2024 10:46 AM
I couldn't refernce the global varaible g_view_name
But I did find a function that always errors in the NextUI, which while annoying is also useful 😉
var view = ''; //Sting to capture the view
try {
view = getView(); // only works in Classic UI
} catch (error) {
view = 'nextUI';
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-27-2024 11:39 PM
Hi @Abhishek Chava1 ,
By Using getReference Method is not the Best Practise to Limit in ''sow'' View and doesn't work on Service Operations Workspace , Use GlideAjax Method and get the Value then in Client Script Form, Uncheck the Global Field and in the View Field enter as ''sow'' view
Thanks
Badrinarayan