- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-30-2024 11:32 PM
Hi All,
i trust this email finds you well.
SITUATION
I added a new state for approvers (XXXXX). Instead of approvers going to the approval record i want them to open the change, click on a button which will open a ui page. The ui page will bring all groups approval the approver is a member of. Then the approver will select the group he wants to approve for and enter a comment. After closing the ui page, his approval for that specific group will change to XXXXX and will also add the comment.
I created the ui action (it calles the ui page and pass the sys_id of the change request)
function changeclarification() {
var gdw = new GlideDialogWindow('change_clarification_popup');
gdw.setSize(750,300);
gdw.setPreference('sys_id',g_form.getUniqueValue());
gdw.render();
}
I created the ui page.
HTML code
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<j:set var="jvar_chg_id" value="${RP.getParameterValue('sys_id')}"/>
<g:evaluate>
var usr = gs.getUserID();
var approver = new GlideRecord('sysapproval_approver'); //Querying the sysapproval_group table to get the groups are still pending for approval
approver.addQuery('parent',jvar_chg_id);
approver.addQuery('approval', 'requested');
while(approver.next()) {
var group_approval = new GlideRecord('sysapproval_approver');
group_approval.addQuery('number',approver.group);
group_approval.orderBy('sequence');
group_approval.query();
}
</g:evaluate>
<form method="POST" action="sys_ui_page.do" class="form_body form-horizontal tabs_enabled" name="sys_ui_page.do" accept-charset="UTF-8" id="sys_ui_page.do" style="padding-bottom: 10px;" onkeypress="return enterSubmitsForm(event,'false')">
<div class="row"><div class="col-xs-6"></div></div>
<div class="row">
<div class="col-xs-12">
<!-- ACTION Question START -->
<div id="element.sys_choice.label2" class="form-group " style="">
<div class="" data-type="label" choice="0" type="choice" id="label.sys_choice.label" nowrap="true">
<label onclick="return labelClicked(this);" for="sys_display.sys_choice.label" class="col-xs-12 col-md-1_5 col-lg-2 control-label" dir="ltr">
<span id="status.sys_choice.label" aria-label="" data-dynamic-title="" mandatory="true" oclass="" class="required-marker label_description"></span>
<span title="" class="label-text" data-html="false" data-original-title="" aria-expanded="false">Approval Group</span>
</label>
</div>
<div class="col-xs-10 col-md-9 col-lg-8 form-field input_controls">
<div ng-non-bindable="" class="hidden">
<input type="hidden" id="sys_original.sys_choice.label" name="sys_original.sys_choice.label" value=""></input>
</div>
<select onChange="action_changed()" aria-required="true" aria-labelledby="label.sys_choice.label" name="sys_choice.label" aria-readonly="false" aria-disabled="false" id="group_approval" ng-non-bindable="true" class="form-control" style=";" aria-label="Approval Group">
<option value="" selected="selected"> --Select-- </option>
<j:while test="${group_approval.next()}">
<option value="${group_approval.value}">${group_approval.label}</option>
</j:while>
</select>
</div>
<div class="col-xs-2 col-md-1_5 col-lg-2 form-field-addons"></div>
</div>
<!-- ACTION Question END -->
<!-- Comments Question START -->
<div id="element.task_time_worked.comments" class="form-group " style="">
<div class="" data-type="label" choice="0" type="text" id="label.task_time_worked.comments" nowrap="true">
<label onclick="return labelClicked(this);" for="sys_display.task_time_worked.comments" class="col-xs-12 col-md-1_5 col-lg-2 control-label" dir="ltr">
<span id="status.task_time_worked.comments" aria-label="" data-dynamic-title="" mandatory="true" oclass="" class="required-marker label_description"></span>
<span title="" class="label-text" data-html="false" data-original-title="" aria-expanded="false">Comments</span>
</label>
</div>
<div class="col-xs-10 col-md-9 col-lg-8 form-field input_controls">
<div ng-non-bindable="" class="hidden">
<input type="hidden" id="sys_original.task_time_worked.comments" name="sys_original.task_time_worked.comments" value=""></input>
</div>
<textarea id="task_time_worked.comments" onchange="this.isFocused=false;multiModified(this);telemetryForRecordUpdate('comments');" onkeydown="multiKeyDown(this);" style="width: 100%; resize: none; overflow: hidden; overflow-wrap: break-word; height: 153.818px;" name="task_time_worked.comments" rows="" wrap="soft" specialtype="" data-length="1000" data-charlimit="false" onfocus="this.isFocused=true;" onblur="this.isFocused=false;" class="form-control" aria-required="false" spellcheck="false" aria-label="Comments"></textarea>
</div>
<div class="col-xs-2 col-md-1_5 col-lg-2 form-field-addons"></div>
</div>
<!-- Comments Question END -->
</div>
</div>
</form>
<tr>
<td colspan="2" style="text-align:right;padding-top:10px;">
<button class="btn btn-default" onclick="closeWindow()" style="margin-right:10px;">Cancel</button>
<button class="btn btn-primary" onclick="update_ticket()">Ok</button>
</td>
</tr>
</j:jelly>
ISSUE
the ui page has the drop-down list and the comment fields, but the drop-down list has no values.
why?
am i passing the sys_id correctly?
am i populating the drop-down list correctly?
regards
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-07-2024 04:45 PM
what i did was to pass the details from the ui action to a script include. The script include did pass back all group names to ui action, which then pass it to the ui page.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-31-2024 12:13 AM
Hi @El Cuchi
I'm not entirely sure what you're trying to achieve, but here are a few things you might want to check
1. setPreference
gdw.setPreference('sys_id', g_form.getUniqueValue());
Add this line below inside the <g:evaluate>, and you can get the passed value from the UI Action.
var currentRecord = RP.getWindowProperties().get('sys_id') || '';
2. Correct the table
var approver = new GlideRecord('sysapproval_approver'); //Querying the sysapproval_group table to get the groups are still pending for approval
I'm understanding that you wanna query to the sysapproval_group instead of sysapproval_approver. So it should be:
var approver = new GlideRecord('sysapproval_group');
3. The number field.
The sysapproval_approver table does not have a number field. Make sure you're querying the right fields:
group_approval.addQuery('number',approver.group);
Cheers,
Tai Vu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-31-2024 11:17 PM
hi Timi,
thank you for your comments. i corrected the query as per below.
Here is an example of what i am trying to achieve.
CHGxxxxxxxxx
"Group approvals" tab will contain
windows requested GAPRVxxxxxx
linux requested GAPRVyyyyyy
Solaris requested GAPRVzzzzzzz
"Approvers" tab will contain
Max requested GAPRVxxxxxx
Peter requested GAPRVxxxxxx
John requested GAPRVyyyyyy
Mandy requested GAPRVyyyyyy
Max requested GAPRVzzzzzz
Jason requested GAPRVzzzzzz
In the example above, if max is the person using the ui action, the drop-down list should return the following values. windows & solaris
var usr = gs.getUserID();
var items = [];
var test = [];
var approver = new GlideRecord('sysapproval_approver');
approver.addQuery('document_id',jvar_chg_sys_id);
approver.addQuery('state', 'requested');
approver.addQuery('approver',usr);
approver.query();
while(approver.next()) {
var gapp = new GlideRecord('sysapproval_group');
gapp.addQuery('sys_id',approver.group);
gapp.query();
while(gapp.next()) {
items.push(gnapp.assignment_group);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-07-2024 04:45 PM
what i did was to pass the details from the ui action to a script include. The script include did pass back all group names to ui action, which then pass it to the ui page.