- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā01-09-2019 08:18 AM
hi team,
pls find below code, from ui action i am passing 2 values to ui page
dialog.setPreference("commentstext", requestfor); //Pass in comments for use in the dialog
dialog.setPreference("modeldisplayname", modelname); //Pass in short description for use
commentstext is working fine, but modelname value is not printing please suggest.
ui action:
function commentsDialog() {
//Get the values to pass into the dialog
var modelidsysid = '';
var modelname = '';
var requestfor = g_form.getDisplayBox("requested_for").value;//Initialize and open the Dialog Window
var ci = g_form.getReference('cmdb_ci',doAlert); // doAlert is our callback function
function doAlert(ci) { //reference is passed into callback as first arguments
modelidsysid = ci.model_id;
var model = new GlideRecord('cmdb_model');
model.addQuery('sys_id',modelidsysid);
model.query();
alert('outsideif' + modelidsysid);
if(model.next()){
modelname = model.display_name;
alert(modelname);
}
}
alert(modelname+ 'is model name');
var dialog = new GlideDialogWindow("task_comments_dialog"); //Render the dialog containing the UI Page 'task_comments_dialog'
dialog.setSize(1250,500);
dialog.setTitle("Add Task Comments"); //Set the dialog title
dialog.setPreference("commentstext", requestfor); //Pass in comments for use in the dialog
dialog.setPreference("modeldisplayname", modelname); //Pass in short description for use in the dialog
dialog.adjustBodySize();
dialog.render(); //Open the dialog
}
ui page:
<!-- Get values from dialog preferences passed in -->
<g:evaluate var="jvar_commentstext"
expression="RP.getWindowProperties().get('commentstext')" />
<g:evaluate var="jvar_modeldisplayname"
expression="RP.getWindowProperties().get('modeldisplayname')" />
<!-- Set up form fields and labels -->
<div class="task-comment-dialog-container">
<table width="90%" class="">
<tr id="description_row" valign="top">
<td colspan="2">
<!-- Short description value used as a label -->
${jvar_commentstext}
${jvar_modeldisplayname}
</td>
</tr>
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā01-09-2019 02:53 PM
There was a typo in the earlier code
function commentsDialog() {
//Get the values to pass into the dialog
var modelidsysid = '';
var modelname = '';
var requestfor = g_form.getDisplayBox("requested_for").value;//Initialize and open the Dialog Window
var ci = g_form.getValue('cmdb_ci');
var ga = new GlideAjax("TogetModelName");
ga.addParam("sysparm_name", "getmodel");
ga.addParam("cmdb_ci", ci );
ga.getXMLWait();
alert( ga.getAnswer() );
// alert(modelname+ 'is model name');
var dialog = new GlideDialogWindow("task_comments_dialog"); //Render the dialog containing the UI Page 'task_comments_dialog'
dialog.setSize(1250,500);
dialog.setTitle("Add Task Comments"); //Set the dialog title
dialog.setPreference("modeldisplayname", modelname);
dialog.setPreference("commentstext", requestfor); //Pass in comments for use in the dialog
dialog.adjustBodySize();
dialog.render(); //Open the dialog
}
I just tested in my personal instance and i was able to see the model in pop up.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā01-09-2019 08:58 AM
In the ui action please update the code as follows
function commentsDialog() {
//Get the values to pass into the dialog
var modelidsysid = '';
var modelname = '';
var requestfor = g_form.getDisplayBox("requested_for").value;//Initialize and open the Dialog Window
var ci = g_form.fetValue('cmdb_ci');
var ga = new GlideAjax("TogetModelName");
ga.addParam("sysparm_name", "getmodel");
ga.addParam("cmdb_ci", ci );
ga.getXMLWait();
alert( ga.getAnswer() );
// alert(modelname+ 'is model name');
var dialog = new GlideDialogWindow("task_comments_dialog"); //Render the dialog containing the UI Page 'task_comments_dialog'
dialog.setSize(1250,500);
dialog.setTitle("Add Task Comments"); //Set the dialog title
dialog.setPreference("modeldisplayname", modelname);
dialog.setPreference("commentstext", requestfor); //Pass in comments for use in the dialog
dialog.adjustBodySize();
dialog.render(); //Open the dialog
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā01-09-2019 09:11 AM
hi dvp,
now i got alert correctly but in my ui page it is not showing still
<!-- Get values from dialog preferences passed in -->
<g:evaluate var="jvar_commentstext"
expression="RP.getWindowProperties().get('commentstext')" />
<g:evaluate var="jvar_modeldisplayname"
expression="RP.getWindowProperties().get('modeldisplayname')" />
<!-- Set up form fields and labels -->
<div class="task-comment-dialog-container">
<table width="90%" class="">
<tr id="description_row" valign="top">
<td colspan="2">
<!-- Short description value used as a label -->
${jvar_commentstext}
${jvar_modeldisplayname}
</td>

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā01-09-2019 02:53 PM
There was a typo in the earlier code
function commentsDialog() {
//Get the values to pass into the dialog
var modelidsysid = '';
var modelname = '';
var requestfor = g_form.getDisplayBox("requested_for").value;//Initialize and open the Dialog Window
var ci = g_form.getValue('cmdb_ci');
var ga = new GlideAjax("TogetModelName");
ga.addParam("sysparm_name", "getmodel");
ga.addParam("cmdb_ci", ci );
ga.getXMLWait();
alert( ga.getAnswer() );
// alert(modelname+ 'is model name');
var dialog = new GlideDialogWindow("task_comments_dialog"); //Render the dialog containing the UI Page 'task_comments_dialog'
dialog.setSize(1250,500);
dialog.setTitle("Add Task Comments"); //Set the dialog title
dialog.setPreference("modeldisplayname", modelname);
dialog.setPreference("commentstext", requestfor); //Pass in comments for use in the dialog
dialog.adjustBodySize();
dialog.render(); //Open the dialog
}
I just tested in my personal instance and i was able to see the model in pop up.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā01-10-2019 03:10 AM
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā01-09-2019 08:56 AM
not working still it throws alert as null, can you please see ui action once if i am assigning correctly or not