- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-10-2023 10:50 PM
Hi,
Need your help to remove(hide) the values starts with SNOW from the category drop down list into SP. The below script is working correctly but i should remove dynamically instead of calling removeoption for each category. If a new value(starts with SNOW) category is added in future, this code should remove it automatically from the particular record producer.
function onLoad() {
//Type appropriate comment here, and begin script below
g_form.removeOption('category', 'SNOW-Modules');
g_form.removeOption('category', 'SNOW-Compensation');
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-17-2023 01:42 AM
Instead of going with catalog client, can you try using reference qualifier to not show options starting with SNOW.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-11-2023 04:26 AM
Hello @BanuMahalakshmi
You need to Use Flow designer :-
Trigger Action Should be Created or Updated on the Table you need.
1. Flow Logic :- IF Condition Should be category 'Contains' SNOW
2. THEN :- Write your script to remove the Options.
Plz Mark my Solution as Accept and Give me thumbs up, if you find it helpful.
Regards,
Samaksh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-11-2023 04:46 AM
Approach 1: You may create custom table to store the categories for which the choices should be removed, then create a script include and pass category as input and return whether to remove the choice values or not
Script include function:
var getCategoryDependency = Class.create();
getCategoryDependency.prototype = Object.extendsObject(AbstractAjaxProcessor, {
checkCategory:function()
{
var categoryVal = this.getParameter('sysparm_category');
var gr = new GlideRecord('customtablenamehere');
//APPLY QUERY USING FIELD NAME using addQuery
gr.query();
if(gr.next())
{
return 'found';
}
else
{
return 'not_found';
}
},
type: 'getCategoryDependency'
});
Client script:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var ga = new GlideAjax('global.getCategoryDependency');
ga.addParam('sysparm_name','checkCategory');
ga.addParam('sysparm_category',newValue);
ga.getXML(responsecallback);
function responsecallback(response)
{
var ans = response.responseXML.documentElement.GetAttribute('answer');
if(ans == 'found')
{
g_form.removeOption('category', 'SNOW-Modules');
g_form.removeOption('category', 'SNOW-Compensation');
}
}
}
2. Create system property and store comma separated values of categories. In the script include using the above method call gs.getProperty() & check if the category exists or not.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2023 12:01 PM
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) {
return;
}
if(newValue.contains('SNOW')){
return false;
}
}
Using the Script you can make user to retrict those choices.
Plz Mark my Solution as Accept and Give me thumbs up, if you find it helpful.
Regards,
Samaksh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2023 06:49 AM
THanks for reply, i am getting the error message newValue.contains is not function.