The CreatorCon Call for Content is officially open! Get started here.

GlideDialogWindow getting field value and passing to UI page

E_19
Giga Expert

Hi All,

I have a UI Action on Incident that launches a GlideDialog Window and at present populates a list with service catalog item via UI page.

I now need to enhance this and get the company from the incident, pass this to the UI page and then only populate service catalog items that were created for the company.

The below returns the company sys_id should I or can I convert this to name? More difficult for me is how to pass/use the company variable in the UI page

function createStdChangeDialog() {

    var dialog = new GlideDialogWindow("dialog_standard_change_template");

    dialog.setTitle("Select a Standard Change Template");

    var comp = g_form.getValue('company');

    dialog.setPreference("target",   g_form.getTableName());

    dialog.setPreference("target_id", g_form.getUniqueValue());

  alert(comp);

    dialog.render();

}

Any suggestions greatly appreciated.

Ellie

1 ACCEPTED SOLUTION

Goran WitchDoc
ServiceNow Employee
ServiceNow Employee

Hi Ellie,



First you need to send the sys_id as a preference to the UI page.



function createStdChangeDialog() {


    var dialog = new GlideDialogWindow("dialog_standard_change_template");


    dialog.setTitle("Select a Standard Change Template");


    var comp = g_form.getValue('company');


    dialog.setPreference("target",   g_form.getTableName());


    dialog.setPreference("target_id", g_form.getUniqueValue());


        dialog.setPreference("company_id", comp);  


alert(comp);


    dialog.render();


}



then you use this in you query like this:


First you fetch the value like this and you do it inside the <evaluate> tags where you query is:


var comp = RP.getWindowProperties().get('company_id');



Then add it like this if the fieldname etc. is correct:


gr.addQuery('sc_cat_item_category', comp);


or if I get you fields correct, I guess it should be
gr.addQuery('company',comp);


I would doublecheck the query in a scripts - background or xplore to verify that with a correct company sys_id you get the right stuff back.



//Göran


View solution in original post

6 REPLIES 6

Thanks Goran this helped to resolve it


Hey Goran,

I'm trying to use the solution you mentioned above.

I have a sys_ids that I want to use in a script include. But before I trigger the function in the script include, I'm rendering a UI Page using new GlideDialogWindow.

How should I go about this?

What I'm aiming to do is select one or more records from a table, click on a UI Action in the list view which then triggers a UI Page as a popup. In the popup, I need to choose from 3 options. The option I select, along with the sys_ids of the records I've chosen, needs to be passed to a script include function.

I'm struggling with passing the sys_ids. Any advice?