- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2023 02:08 PM
Hello -
I have a UI Action that is checking for field values and then taking action from there. If the field does not contain a specific value, then go ahead and proceed. This was working great, however, the issue is that now the requirement is for this field to be a List type field, so I have created a new List type field that is referencing a table that contains the different choices. I am not quite sure how to script this for a list-type field.
Here is how it was prior to being a List-type field (accounting_close_code is the field that needed to be replaced for a List-type field):
if (g_form.getValue('accounting_close_notes') == '' && g_form.getValue('accounting_close_code') != "No Accounting Action Required") {
g_form.setMandatory('accounting_close_notes', true);
swal("Missing Information", "Please complete required fields prior to closing", "error");
return false; // Abort submission
}
Here is what I tried, but it is not working:
if (g_form.getValue('accounting_close_notes') == '' && g_form.getDisplayValue('accounting_close_code_list').toLowerCase().indexOf('no accounting action required') == -1) {
g_form.setMandatory('accounting_close_notes', true);
swal("Missing Information", "Please complete required fields prior to closing", "error");
return false; // Abort submission
}
Hoping this is possible within just the UI Action and my script is just incorrect ?
Thanks!!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2023 02:42 PM - edited 09-14-2023 02:43 PM
Hello @jlaue,
You could add this :
g_form.addInfoMessage('Close notes: '+g_form.getValue('accounting_close_notes');
g_form.addInfoMessage('Close code: '+ g_form.getDisplayValue('accounting_close_code_list'));
You could add these to the code to see what it returns, later we'll figure out if you're not getting the values right.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2023 02:28 PM
UI actions usually run Server side code, g_form is used for client side. You should be able to use current.field_name instead of g_form.getValue('field_name') I'd also recommend referencing the GlideRecord API documentation and checking how other UI actions are coded in your instance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2023 02:42 PM - edited 09-14-2023 02:43 PM
Hello @jlaue,
You could add this :
g_form.addInfoMessage('Close notes: '+g_form.getValue('accounting_close_notes');
g_form.addInfoMessage('Close code: '+ g_form.getDisplayValue('accounting_close_code_list'));
You could add these to the code to see what it returns, later we'll figure out if you're not getting the values right.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-15-2023 11:19 AM
Thanks! That helped a lot, I was able to get it sorted using the sysID for the one value I was checking.
g_form.getValue('accounting_close_code_list') != "d91302d11bd1f15096a79602b24bcbc2"
