- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-05-2017 03:12 AM
Hi All,
I am working on amending the release module to fit our needs so that we can move our release processes into Servicenow.
On the release form there will be a CI field (reference to the cmdb_ci table), however sometimes when the release is being raised the CI may not have been created. What we can is through the click of a UI Action that a pop up box will load with the Business Services CI type form for the user to submit a new CI which they will then be able to select from the CI field.
Is this possible using GlideDialogWindow bringing up a set view of the form? or does a UI page need to be created?
Does anyone have any example code on how to achieve this?
Below is the form that we would need to be displayed in the pop up:
Obviously we won't need all the fields displayed on the pop-up but could create a new view to only display the ones we want.
If we know what some of the information will always be is there a way to not show these fields on the pop up, but sill have them populated with pre-defined information when the record is submitted?
Any help is greatly appreciated.
Thanks
Sam
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-05-2017 08:10 AM
Hi Sam,
Have a look here: https://www.servicenowguru.com/system-ui/glidedialogwindow-advanced-popups-ui-pages/
And also here: https://www.servicenowguru.com/system-ui/ui-macros/adding-referenced-records-leaving-form/
I used the second link from mark.stanger to create a work plan for my change request form.
See below, relies heavily on his work
It should definitley get you started.
<?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="jvar_guid" expression="gs.generateGUID(this);" />
<j:set var="jvar_n" value="add_edit_work_plan_${jvar_guid}:${ref}"/>
<a id="${jvar_n}" onclick="addEditWorkPlanPop('${ref}')">
<img border="0" src="images/icons/user_profile.gifx" title="${gs.getMessage('Add/Edit Work Plan')}" alt="${gs.getMessage('Add/Edit Work Plan')}"/>
</a>
<script>
//OnClick function for UI macro
function addEditWorkPlanPop(reference){
var s = reference.split('.');
var referenceField = s[1];
var v = g_form.getValue(referenceField);
var cr = g_form.getUniqueValue();
//If work plan field is empty then pop open an 'Add Work Plan' dialog
if(v == ''){
var dialog = new GlideDialogForm('Add Work Plan', 'u_change_work_plan', setWPField);
dialog.setSysID('-1'); //Pass in -1 to create a new record
dialog.addParm('sysparm_query','u_change_request='+cr); //Set change request sys id in work plan
}
//Else pop open an 'Edit Work Plan' dialog for the populated user record
else{
var dialog = new GlideDialogForm('Edit Work Plan', 'u_change_work_plan', setWPField);
dialog.setSysID(v); //Pass in reference sys_id to edit record
}
dialog.addParm('sysparm_view', 'default'); //Specify a form view
dialog.addParm('sysparm_form_only', 'false'); //Remove related lists
dialog.render(); //Open the dialog
dialog.save();
//Callback function executed from dialog submit
function setWPField(action, sys_id, table, displayValue){
//Set the work plan field with the popup work plan
g_form.setValue(referenceField, sys_id);
}
}
</script>
</j:jelly>
Harel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-05-2017 08:10 AM
Hi Sam,
Have a look here: https://www.servicenowguru.com/system-ui/glidedialogwindow-advanced-popups-ui-pages/
And also here: https://www.servicenowguru.com/system-ui/ui-macros/adding-referenced-records-leaving-form/
I used the second link from mark.stanger to create a work plan for my change request form.
See below, relies heavily on his work
It should definitley get you started.
<?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="jvar_guid" expression="gs.generateGUID(this);" />
<j:set var="jvar_n" value="add_edit_work_plan_${jvar_guid}:${ref}"/>
<a id="${jvar_n}" onclick="addEditWorkPlanPop('${ref}')">
<img border="0" src="images/icons/user_profile.gifx" title="${gs.getMessage('Add/Edit Work Plan')}" alt="${gs.getMessage('Add/Edit Work Plan')}"/>
</a>
<script>
//OnClick function for UI macro
function addEditWorkPlanPop(reference){
var s = reference.split('.');
var referenceField = s[1];
var v = g_form.getValue(referenceField);
var cr = g_form.getUniqueValue();
//If work plan field is empty then pop open an 'Add Work Plan' dialog
if(v == ''){
var dialog = new GlideDialogForm('Add Work Plan', 'u_change_work_plan', setWPField);
dialog.setSysID('-1'); //Pass in -1 to create a new record
dialog.addParm('sysparm_query','u_change_request='+cr); //Set change request sys id in work plan
}
//Else pop open an 'Edit Work Plan' dialog for the populated user record
else{
var dialog = new GlideDialogForm('Edit Work Plan', 'u_change_work_plan', setWPField);
dialog.setSysID(v); //Pass in reference sys_id to edit record
}
dialog.addParm('sysparm_view', 'default'); //Specify a form view
dialog.addParm('sysparm_form_only', 'false'); //Remove related lists
dialog.render(); //Open the dialog
dialog.save();
//Callback function executed from dialog submit
function setWPField(action, sys_id, table, displayValue){
//Set the work plan field with the popup work plan
g_form.setValue(referenceField, sys_id);
}
}
</script>
</j:jelly>
Harel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-06-2017 05:40 AM
Hi Harel,
Thanks for the above information. I've managed to created a glide dialogue window from a UI action that seems to have done the trick:
function showMyForm(){
//Get the table name and sys_id of the record
var tableName = 'cmdb_ci_service';
var sysID = -1;
//Create and open the dialog form
var dialog = new GlideDialogForm('Create CI', tableName); //Provide dialog title and table name
dialog.setSysID(sysID); //Pass in sys_id to edit existing record, -1 to create new record
dialog.addParm('sysparm_view', 'release'); //Specify a form view
dialog.addParm('sysparm_form_only', 'true'); //Add or remove related lists
dialog.render(); //Open the dialog
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-06-2017 10:54 AM
Good.
Please mark an answer as correct so it is removed from the unanswered questions list.
harel