How to update the record using UI pages
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-08-2018 12:01 PM
I am opening a dialog box using ui action from an incident record.I am passing the sys_id of the current incident record and trying to update the same record with the values entered in the multi line field of a dialog box. But after submitting the dialog box, it is redirected to the url of my ui page.
Here is my code in UI action:
UI action:
function sendEmail(){
//Initialize and open the Dialog Window
var sysid = g_form.getUniqueValue();
var dialog = new GlideDialogWindow("notification_update");dialog.setTitle("Notification Preview");
dialog.setPreference("sysid", sysid);
dialog.render();
}
Here is my code in UI page:
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_form>
<g:evaluate var="jvar_sysid"
expression="RP.getWindowProperties().sysid"/>
<table border="0" width="100%">
<tr>
<td>
<g:ui_multiline_input_field name="notes" label="update" mandatory="true" />
</td>
</tr>
<tr>
<td>
<g:dialog_buttons_ok_cancel cancel="return onCancel();" ok="return onSubmit();"/>
<input type="hidden" id="task_sys_id" name="task_sys_id" value="${jvar_sysid}"/>
</td>
</tr>
</table>
</g:ui_form>
</j:jelly>
Client script:
function onCancel() {
GlideDialogWindow.get().destroy();
return false;
}
function onSubmit() {
var data = gel('notes').value;
// g_form.setValue('description', data);
// g_form.save();
return true;
}
processing script:
var text = notes;
createRecords();
function createRecords() {
var app = new GlideRecord("incident");
if(app.get(task_sys_id)){
app.description = text;
app.update();
}
}
//response.sendRedirect('incident.do?sys_id='+task_sys_id);
var urlOnStack = gs.getUrlOnStack();
response.sendRedirect(urlOnStack);
Please let me know any suggestions/ideas so that i can fix my script.
Thanks,
Niranjan.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-14-2018 01:33 AM
Hi Niranjan,
Any update on this?
Can you mark my answer as correct, helpful and hit like if you were able to achieve the requirement. This helps in removing this question from unanswered list and helps users to learn from your thread. Thanks in advance.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-15-2018 03:21 PM
Thanks every one,
I could achieve this using some minor modifications to the code. The problem was the sys_id of the record was not correctly passing to the ui page. I figured that out and followed this article which resolved my issue.
http://www.servicenowelite.com/blog/2013/11/24/glidedialog-window-example.
Thanks,
Niranjan.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-25-2018 07:12 AM
Hi Niranjan,
I am working on similar requirement. Could you please let me know how you passed the value of 'notes' in processing script.
Regards
Sweta Pathak