GlideModalForm: has anyone used addParm or setPreference?

tahnalos
Kilo Sage

One of my ongoing tasks is to find a way to create dialogs to pop up to prompt users to enter additional information before they can access a ticket.   Someone recently pointed me to GlideModalForm, which has a lot of prebundled options on how you want the dialog to work.   Seems to be working fine except I'm missing a critical piece of information:

I need to pass additional information to the dialog itself opened in GlideModalForm, and the documentation suggests to use either addParm and setPreference.   The only issue is that the documentation is very vague on how to use this (which is why I loved the wiki so much more), and that examples provided by others seem to suggest that addParm and setPreference only allows for certain arguments on how the window is to look, and not whether to pass information from one form to another (these examples use sysparm_* variables so I don't think that is correct).   Can anyone shed some light to me for this?

Thanks

1 ACCEPTED SOLUTION

adam_faulkinber
Kilo Expert


var d = new GlideModalForm('Create New incident', 'incident');


d.setOnloadCallback(populateModal);


d.render();



function populateModal(){


        //Access GlideModal g_form


        var d_form = window.frames["dialog_frame"].g_form;


        d_form.setValue('caller_id', g_user.userID);


       


        //Access GlideModal Scratchpad


        var d_scratchpad = window.frames["dialog_frame"].g_scratchpad;


        d_scratchpad.myVar = 'Scratchpad Value';


}





You have to access the Modal using window.frames["dialog_frame"].


View solution in original post

13 REPLIES 13

adam_faulkinber
Kilo Expert


var d = new GlideModalForm('Create New incident', 'incident');


d.setOnloadCallback(populateModal);


d.render();



function populateModal(){


        //Access GlideModal g_form


        var d_form = window.frames["dialog_frame"].g_form;


        d_form.setValue('caller_id', g_user.userID);


       


        //Access GlideModal Scratchpad


        var d_scratchpad = window.frames["dialog_frame"].g_scratchpad;


        d_scratchpad.myVar = 'Scratchpad Value';


}





You have to access the Modal using window.frames["dialog_frame"].


So assuming if I use a scratchpad to pass the object to the GlideModalForm, does that mean I need a second client script onLoad to populate that value?



Thanks


Sorry, I misread your code.   Turns out I only need the Glide Form version.



Thanks, this worked like a charm.


Sorry for the confusion.   I just threw scratchpad in there because I was using it in my script and thought I'd include it in case you needed it.   You would need a client script on the target form to use the scratchpad if you didn't already have one.