Help with catalog item form
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2024 02:33 AM - edited 03-06-2024 02:50 AM
Hi all,
I have created a catalog item and I have two reference fields on the form: "office_location" which references the "cmn_location" table and "choose_the_software" which references the "u_software" table.
If I select "New York" as office location, I want to then be able to hide the software "Cube3D" optionfrom the choose_the_software reference field.
Can anyone help with catalog client script please?
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2024 04:09 AM - edited 03-06-2024 04:09 AM
Hi @cicgordy ,
You can create a script include and in that you can Glide record to location table and return query if name matches New York and call it in 'choose_the_software' variable reference qualifier,
I have written this in my pdi on location and software table but change it accordingly to satisfy your requirement
Script include:
var getSoftwareDetail = Class.create();
getSoftwareDetail.prototype = {
initialize: function() {},
checkSoftware: function(choice) {
gs.info("Check CHOICE" + choice);
var gr = new GlideRecord('cmn_location');
gr.addQuery('sys_id', choice);
gr.query();
if (gr.next()) {
if (gr.name == 'New York')
return "name!=3D Pinball"; // filter query from ref table
} else {
return "nameISNOTEMPTY";
}
},
type: 'getSoftwareDetail'
};
Reference qualifier:
javascript: new getSoftwareDetail().checkSoftware(current.variables.location)
Please mark this comment as Correct Answer/Helpful if it helped you.
Regards,
Swathi Sarang
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2024 05:16 AM
Hi @swathisarang98 ,
Thanks for providing this. Not sure I understood what to put instead of "check choice" + "choice" and "choice" in the line below. Can you please clarify according to the field values and names provided in my initial question?
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2024 07:11 AM - edited 03-06-2024 07:31 AM
@cicgordy , that is just info you can remove that , but choice you can use same because i am passing location sysid through that but
here also change the encoded query, like go to 'u_software' table and filter out 'name is not Cube3D' and that copy query and paste in the first return or replace above,
and in reference qualifier replace 'location' with 'office_location'
javascript: new getSoftwareDetail().checkSoftware(current.variables.office_location)
Please mark this comment as Correct Answer/Helpful if it helped you.
Regards,
Swathi Sarang