- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2023 09:17 AM
Hi,
I have 2 reference variables. Variable A and Variable B. Variable A is a reference to cmn_cost_center. Variable B is a reference to a custom table and has a reference qualifier for Variable A. When the user selects an option from Variable A it populates Variable B with a list of items associated to Variable A for the user to select. That is working correctly.
Here is what I cannot seem to get to work:
If the user selects an option from Variable A that does not have any associated items to Variable B then Variable B should be hidden.
What is the best way to hide Variable B if it does not get populated?
Thank you in advance for any assistance,
Diana
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2023 02:43 AM
Hi Diana,
This script wont work, you have to write a GlideAjax and call a script include. In there you need to mimic the same query as your Reference Qualifier (u_active=true^u_type=opex_id^u_cost_center='+ current.variables.cost_center;) and check if there are any options present to be shown in variable B, if this count is more than 0 then return back a flag value based on which you can show variable B

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2023 09:22 AM
Hello @Diana27
How are you populating the existing variable A values in variable B? is it client script? can you post the script you are using?
Ideally you can check in the same script and if there are no items, then you can hide the variable B.
Thank you,
Ali
Thank you,
Ali
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2023 09:27 AM
Hi Ahmmed,
I am using a reference qualifier:
javascript: var query = ''; query+= 'u_active=true^u_type=opex_id^u_cost_center='+ current.variables.cost_center;
Thank you,
Diana
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2023 09:22 AM
Make Variable B hidden by default(onload)
Write a Client script that rinds on change of Variable A, check if there are values for Variable B (You might need a Glide Ajax Call here), And if there are Values for Variable B then show it, otherwise leave it hidden.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-13-2023 09:34 AM
Hi Anurag,
I've created a catalog onChange client script for Variable A to check the length of Variable B and to hide it if it is 0. But it is always hiding Variable B. It doesn't see that there are options that have not been selected.
In the sample below cost_center is Variable A and opexid is Variable B.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var ccenter='';
var opex ='';
ccenter = g_form.getValue('cost_center').length;
opex = g_form.getValue('opexid').length;
if (ccenter != 0 && opex == 0){
g_form.setDisplay('opexid',false);
}
}
Thank you,
Diana