- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2023 04:56 AM
Hi Community,
I need help in developing client script.
Please consider below scenario:
When I select "Singapore" as a choice from the field "Please select the region you are in:"
Then the records in field "Please select the Service you are having issue with:" must only start from SGP.
The field "Please select the Service you are having issue with:" is a Reference field to cmdb_ci table.
Please help me construct a On Change Client Script that modifies the data i.e starts with SGP .
Thanks in Advance,
Hritik.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2023 12:25 AM - edited 11-17-2023 12:29 AM
Hi @Hritik
Okay there you go! 😋
javascript:"operational_status=1^sys_class_name=cmdb_ci_appl^ORsys_class_name=cmdb_ci_service^ORsys_class_name=cmdb_ci_service_technical^ORsys_class_name=cmdb_ci_service_business^nameSTARTSWITH" + current.variables.please_select_the_region_you_are_in.toString();
Cheers,
Tai Vu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2023 06:11 AM
Hi Peter,
The reference Qualifier is working.
But we have 17 choices. Could you please let me know how can we achieve easily for 17 choices ?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2023 06:21 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2023 06:18 AM
Hi @Hritik
From where the list choice of the "Please select the region you are in:" is getting data from?
If the Country Name is Choice Text and the Country Code is Choice Value.
Example: Singapore (Text Label) and SGP (Value)
Then, you can simply put this line into the Reference Qualifier.
javascript:"nameSTARTSWITH" + current.variables.please_select_the_region_you_are_in;
In the other hands, you can create your own script include to validate with IF Else statement, or do the query to the data table in which you're getting data for the country to get the Country Code.
var CLCatalogItemUtils = Class.create();
CLCatalogItemUtils.prototype = {
initialize: function() {},
getCIReferenceQual: function(country_code) {
var query = '';
switch (country_code) {
case "Singapore":
query = 'nameSTARTSWITHSGP';
break;
case "Vietnam":
query = 'nameSTARTSWITHVN';
break;
//add more cases, etc
default:
query = 'sys_id=-1';
break;
}
return query;
},
type: 'CLCatalogItemUtils'
};
javascript:new CLCatalogItemUtils().getCIReferenceQual(current.variables.please_select_the_region_you_are_in.tostring());
Cheers,
Tai Vu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2023 09:20 AM
Hi @Tai Vu ,
Thank you.
I used the first approach and applied as reference qualifier. But there are also other conditions to be put it:
Reference Qualifier only works before javascript;.
Could you please let me know if this is the correct way for writing script include ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2023 09:43 AM
Reference Qualifier I am trying to work:
operational_status=1^sys_class_name=cmdb_ci_appl^ORsys_class_name=cmdb_ci_service^ORsys_class_name=cmdb_ci_service_technical^ORsys_class_name=cmdb_ci_service_business; javascript: "nameSTARTSWITH" + current.variables.please_select_the_region_you_are_in
it seems the condition is only working before javascript;