- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2023 03:16 AM
Hi all,
Wondering if anyone can help me.
I have this pop up field, where when I click the location field, I want only active locations to show and not inactive ones.
This pop up is showing when I click the "consume" UI action, within the consumable record as shown below
Therefore there is a UI page (HTML and Client script) that controls this. I will share the scripts so hopefully you'd be able to help. Thanks
HTML:
function cancel() {
var c = gel('cancelled');
c.value = "true";
// Only destroy the window when user is on platform view
if (!isActionFromWorkspace())
GlideDialogWindow.get().destroy();
}
function actionOK() {
var total_quantity = gel('total_qty').value;
var quantity = gel('qty').value;
var asset_id = gel('alm_hardware').value;
var user_id = gel('sys_user').value;
var location_id = gel('cmn_location').value;
isActionFromWorkspace();
quantity = quantity.replaceAll(',', '');
var regex = /^\d+$/;
if (!regex.test(quantity) || isNaN(quantity)) {
alert(getMessage("Please enter a non-zero number for quantity"));
return false;
}
total_quantity = parseInt(total_quantity, 10);
quantity = parseInt(quantity, 10);
if (quantity > total_quantity) {
alert(getMessage("Please enter a number less than or equal to the number in stock"));
return false;
} else if (quantity < 1) {
alert(getMessage("Please enter a non-zero number for the quantity"));
return false;
} else {
var form = document.forms['form.' + '${sys_id}'];
addInput(form, "HIDDEN", "asset", asset_id);
addInput(form, "HIDDEN", "user", user_id);
addInput(form, "HIDDEN", "locationSysId", location_id);
return true;
}
}
/**
* Determine if the action performed was from platform or on workspace
*/
function isActionFromWorkspace() {
var fromWorkspace = getParmVal('from_workspace') === "true";
// Set the hidden input field that determined whether or not the
// submission was from platform or workspace
var c = gel('from_workspace');
if (fromWorkspace)
c.value = "true";
else
c.value = "false";
return fromWorkspace;
}
/**
* Helper function to get the parameter values from the URL
*
* @Param {string} name of the url parameter to fetch
*/
function getParmVal(name) {
var url = document.URL.parseQuery();
if (url[name]) {
return decodeURI(url[name]);
}
return;
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2023 04:35 AM
All you have to do is add a property to the ui_reference tag in the HTML:
<td><g:ui_reference name="cmn_location" table="cmn_location" query="active=true"/></td>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2023 04:48 AM
'active' is not an OOTB column on the cmn_location table. If you have added this in your environment, check the column name (u_active?) and update the query property accordingly. You can also filter a list view of locations to only show 'active' ones then copy the query from the breadcrumb and paste it within quotes on this line.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2023 04:35 AM
All you have to do is add a property to the ui_reference tag in the HTML:
<td><g:ui_reference name="cmn_location" table="cmn_location" query="active=true"/></td>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2023 04:39 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2023 04:48 AM
'active' is not an OOTB column on the cmn_location table. If you have added this in your environment, check the column name (u_active?) and update the query property accordingly. You can also filter a list view of locations to only show 'active' ones then copy the query from the breadcrumb and paste it within quotes on this line.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2023 04:57 AM
Yes, you're absolutely right!! It worked now that I changed it to u_active.
Thank you so much!!