Help in UI page, values to be passed in Processing script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2022 04:43 AM
I am new to UI page , Below code is working,
But i want the data to be updated in Server side[ processing script ], PLease help me how to do so
<td style="width:25%">
<g:form_label>
Select CI:
</g:form_label>
</td>
<td style="width:60%">
<g:ui_reference name="user_ref" id="user_ref" table="cmdb_ci" />
</td>
</tr>
<tr>
<td>
<g:dialog_buttons_ok_cancel ok_id="submitData" ok="return continueOK()" ok_type="button" ok_text="${gs.getMessage('Okay')}" ok_style_class="btn btn-primary" cancel_type="button" cancel_id="cancelData" cancel_style_class="btn btn-default" cancel="return continueCancel()"/>
</td>
Client script :
function continueOK() {
var gdw = GlideDialogWindow.get();
var user = gel('user_ref').value;
var sys_id = gdw.getPreference('sys_id');
var app = new GlideRecord("sc_task");
if (app.get(sys_id)) {
app.cmdb_ci = user;
app.update();
}
GlideDialogWindow.get().destroy();
}
function continueCancel() {
GlideDialogWindow.get().destroy();
}
Processing Script : What to type here so that the records can be updated here
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2022 08:50 AM
Hi,
the following has to be changed:
- wrap your table in a g:ui_form
- add a hidden input that stores the sc_task SysID
- change the type of the ok button from "button" to "submit"
Here is the full code:
HTML:
<g:ui_form>
<table>
<tr>
<td style="width:25%">
<g:form_label>
Select CI:
</g:form_label>
</td>
<td style="width:60%">
<input type="hidden" name="task_sys_id" id="task_sys_id" />
<g:ui_reference name="user_ref" id="user_ref" table="cmdb_ci" />
</td>
</tr>
<tr>
<td>
<g:dialog_buttons_ok_cancel ok_id="submitData" ok="return continueOK()" ok_type="submit" ok_text="${gs.getMessage('Okay')}" ok_style_class="btn btn-primary" cancel_type="button" cancel_id="cancelData" cancel_style_class="btn btn-default" cancel="return continueCancel()"/>
</td>
</tr>
</table>
</g:ui_form>
Client script:
function continueOK() {
var gdw = GlideDialogWindow.get();
var user = gel('user_ref').value;
gel('task_sys_id').value = gdw.getPreference('sys_id');
}
function continueCancel() {
GlideDialogWindow.get().destroy();
}
Processing script:
var app = new GlideRecord("sc_task");
if (app.get(this.task_sys_id)) {
app.cmdb_ci = this.user_ref;
app.update();
}
Please let us know if this helped you.