Add an additional choice field to 'change_confirm_reason' ui page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2022 08:29 PM
Hi, I have a need to add an additional choice field to 'change_confirm_reason' ui page which will be copied to a custom field, 'Cancel Reason' on Change request form.
Thank you in advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2022 08:59 PM
you can use jelly tag <g:ui_choice_input_field> for this
check this
How to create "choice" field on "UI PAGE"
If my response helped please mark it correct and close the thread so that it benefits future readers.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2022 08:35 PM
Thank you @Ankur Bawiskar
I am now able to create the choice, however having difficulties copying it to 'Work notes' field.
Here is my code snippet:
_________________________________________________________
HTML
_________________________________________________________
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g:ui_choice_input_field id="choice_id" name="choice_name"
label="${gs.getMessage('Select Cancel Code')}">
<option value="none">${gs.getMessage('--None--')}</option>
<option value="1">ABC</option>
<option value="2">CDE</option>
<option value="3">EFG</option>
<option value="4">HIJ</option>
<option value="5">JKL</option>
</g:ui_choice_input_field> <br> </br>
<g:dialog_reason_ok_cancel dialog_id="change_confirm_reason"
textarea_id="change_confirm_reason_text"
textarea_label="${gs.getMessage('Reason')}"
textarea_label_title="${gs.getMessage('A reason is required to cancel this change')}"
textarea_name="change_confirm_reason_text"
textarea_onkeyup="enableButton()"
textarea_onchange="enableButton()"
textarea_style="height:auto; width: 100%; resize: vertical;"
textarea_title="${gs.getMessage('Enter the reason here')}"
ok_action="invokePromptCallBack"
ok="return invokePromptCallBack('onPromptComplete');"
cancel="return invokePromptCallBack('onPromptCancel');"
/>
</j:jelly>
_________________________________________________________
Client script:
_________________________________________________________
function invokePromptCallBack(source) {
var gm = GlideModal.get();
var type = typeof (source) === 'string' ? 'cancel' : 'ok';
var pref = (type === 'ok') ? 'onPromptComplete' : 'onPromptCancel';
var textArea = $('change_confirm_reason_text');
var cancelCode = $('choice_id');
g_form.setValue('work_notes', cancelCode);
if (!textArea) {
gm.destroy();
return false;
}
var f = gm.getPreference(pref);
if (typeof (f) === 'function') {
try {
f.call(gm, textArea.value.trim());
} catch (e) {}
}
gm.destroy();
return false;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2022 10:18 PM
Glad to know that my comment helped.
Please mark my response as correct and helpful to close the thread.
The discussion can continue on your follow up question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2022 10:20 PM
update as this to get the choice values
<g:ui_choice_input_field id="choice_id" name="choice_id"
and also this
var cancelCode = gel('choice_id').value;