- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2017 05:59 AM
I have created a UI action to fetch a field in RITM catalog variables and show in Glidedialogwindow and when user enters value it needs to be updated in the field.
Using below steps:
Ui Action of client type:
function updateInput(){
var dialogClass = window.GlideModal ? GlideModal : GlideDialogWindow;
var dialog = new dialogClass("change_value_popup");
//dialog.setWidth("800");
dialog.setTitle(getMessage("Change the value with appropriate"));
dialog.setPreference('sysparm_sys_id', g_form.getUniqueValue());
dialog.render(); //Open the dialog.
}
===========================================================================================================
UI Page XML:
<?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:evaluate var="group_mailbox"
expression="RP.getWindowProperties().get('current.variables.mailbox')" />
<tr>
<td class="label">
${gs.getMessage('Please provide appropriate value:')}
</td>
<td>
<g:ui_input_field name="mailbox_name" id="mailbox_name" label="Group Mailbox Name" value="${group_mailbox}"
/>
</td>
</tr>
<tr>
<td>
<g:dialog_button id="submit_button" type="submit"
onclick="entervalue('${sysparm_id}', this)">${gs.getMessage('Submit')}</g:dialog_button>
<g:dialog_button id="cancel_button" type="submit"
onclick="closevalueWindow(this)">${gs.getMessage('Cancel')}</g:dialog_button>
</td>
</tr>
</j:jelly>
Ui Page Client Script:
function closevalueWindow() {
GlideDialogWindow.get().destroy();
}
function entervalue() {var groupmailbox = gel("mailbox_name").value;
alert(groupmailbox);
if (groupmailbox == "") {
alert("Please enter your value before submitting.");
return false;
}
var req_item = g_form.getUniqueValue();
alert(req_item);
var ga = new GlideAjax('AutomationUtils');
ga.addParam('sysparm_name', 'Changevalue');
ga.addParam('sysparm_sysid',req_item);
ga.addParam('sysparm_groupmailbox',groupmailbox);
ga.getXMLAnswer(getresponse);
function getresponse(answer){
closevalueWindow();
g_form.save();
}
}
==============================================
Script Include function:
Changevalue: function() {
var mailbox = this.getParameter('sysparm_groupmailbox');
var sysid = this.getParameter('sysparm_sysid');
var req = new GlideRecord('sc_req_item');
req.get('sysid');
req.variables.mailbox = mailbox;
req.update();
return true;
new Workflow().broadcastEventToCurrentsContexts(req, 'update', null);
},
This is failing on the update of catalog variable in RITM.
The need here is to allow the appropriate catalog variable to be shown on Glidedialogwindow for certain selection when Request was submitted(i have not yet gone to the part of querying based on selection bit) and the popup to accept the value and update the variable and workflow to be restarted from that point.
Appreciate your response.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2017 09:53 AM
I am using g_form.setValue('variable name', value) and this is working to set my solution.
Thanks for your time and help Kristen.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2017 07:06 AM
Okay, I would suggest adding some logging to your script include - add one at the beginning to ensure it's being called. Add one after your set your variables to ensure you're getting the values expected. Add one after you grab the ritm record to ensure you grabbed a record and the right record.
If all of that is working, it might be the variable set you're doing. try req.variable_pool.mailbox = mailbox;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2017 07:10 AM
Is it possible because i am performing an update in Script include on the same form but again doing a save.
It appears like req.update() is not working here.
Is there any other way for updating the catalog variables?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2017 07:17 AM
Hi Shilpa,
I think I'm confused because above you said you removed the "save" in your client script. Can you share how your code looks now? Also, what were the results of the logging?
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2017 07:22 AM
OK, will try to explain so far where i am now.
below bit in script include :
req.variables.mailbox = mailbox;
req.update();
Is trying to update the same page where i have accessed the UI Action.
For trail i passed the value back from script include to client script part and used g_form.setValue('quantity',3); [quantity field i just picked for testing here as we cannot use current.variables in client script] this works. hope this clarifies.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2017 07:50 AM
Did you try the variable_pool? Doing an update shouldn't be a problem, I do this in other UI actions that update records or create them. Have you tried, instead of a custom UI page, just invoking a limited layout for the field they need to update? I found this I'm pretty sure through ServiceNow guru, though I can't locate his article.
In the script, you see the "sysparm_view" - this references the name of the form layout I created.