- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-14-2017 08:01 AM
I want to add a 'check availability' button onto to a catalog item form, before submit, so users can check if we have an item for example
Is there a way to do this, using a yes/no is a bit ugly but having a choice button that could trigger it would be quite nice
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-14-2017 10:13 AM
How about a UI macro on a string field?
Like this:
1. Add a string field to the form.
2. Add the following onLoad script:
function onLoad() {
//The variable name to put the icon next to
g_form.setReadOnly('available', true);
var varName = 'available';
try{
//Add the icon decoration to the reference field
var varEl = g_form.getControl(varName).id;
$(varEl).insert({
after: '<span><a id="icon-check-circle" class="btn btn-default sc-ref-spacer icon-check-circle sn-tooltip-basic" title="" data-original-title="Check availability"></a></span>'
});
//Add the 'onclick' event
$('icon-check-circle').observe('click', checkAvailability);
}catch(e){}
function checkAvailability(){
//Add current user to reference field
var check = new GlideRecord('u_new_test_table');
check.addQuery('u_num', '1');
check.query();
if(check.next()) {
g_form.setValue(varName, 'The item is available.');
} else {
g_form.setValue(varName, 'The item is not available. Bummer.');
}
}
}
Notes:
1. icon-check-circle is the name of the icon. You can insert your own or go to Collaborate -> Administration -> Action icons and choose your own
2. The script is a modification of mark.stanger 's 'Add Me' UI macro for User and Group Fields
3. The whole checkAvailability function: replace it with your own code, using the relevant tables and items. In my example, I wanted to check whether the number '1' appears in a field called u_num.
Harel

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-10-2019 05:28 AM