UI action to open a new form in the dialog window.

davjohn
Kilo Expert

Hi Team,

I would like to know how can i use a UI action to open form in the dialog window ?

1.UI action on the incident form.

2.Clicking on it should open a new record form of a custom table (u_team_activities)

3. Team activities table will be a related list under the incident form.

4.Clicking on submit should create a record in the team activites (u_team_activites) table and record should show up in the related list.

Need advise.

1 ACCEPTED SOLUTION

sajin1
Tera Expert

Hi David,

 

This below code will work for your requirement.

function showMyForm(){
//Get the table name and sys_id of the record
var tableName = 'problem_task';
var sysID = -1;
var incSysid = g_form.getUniqueValue();
alert(incSysid);



//Create and open the dialog form
var dialog = new GlideDialogForm('Create Problem Task', 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', 'default'); //Specify a form view
dialog.addParm('problem task', 'true'); //Add or remove related lists
dialog.setLoadCallback(function(iframeDoc) {
// To get the iframe: document.defaultView in non-IE, document.parentWindow in IE
var dialogFrame = 'defaultView' in iframeDoc ? iframeDoc.defaultView : iframeDoc.parentWindow;
dialogFrame.g_form.setValue('u_incident', incSysid);
dialogFrame = null;
});
dialog.render(); //Open the dialog
}

View solution in original post

5 REPLIES 5

Cody Smith _ Cl
Tera Guru

Hello,

 

Check out this post about Glide Dialog Windows, https://www.servicenowguru.com/system-ui/glidedialogwindow-advanced-popups-ui-pages/  And adding references. https://www.servicenowguru.com/system-ui/ui-macros/adding-referenced-records-leaving-form/

They are both really helpful. I also came across this post from community that looks to be similar to what you're doing.

https://community.servicenow.com/community?id=community_question&sys_id=7d0a8369db5cdbc01dcaf3231f96...

 

If my answer was helpful, or solved your issue, please mark it as Helpful / Correct.
Thank you,
Cody Smith
 

Hi Cody,

The community post that you posted is exactly what i wanted but can you help me to understand how will i make sure that the record that was created by submitting from the dialogue window is tagged to that incident ?

 

I see that a record is getting created but unable to link it to the parent incident.

How are you setting up your related list? Or how are you linking the 2? 
My suggestion would be to add a "Parent Incident" or some other field to the u_team_activities table, where when you open that dialogue you set the new field as a reference to whatever record you just opened it from. 

Then on the incidents related list have it look for all records on the u_team_activities table with its own record as the reference.