GlideModalForm Set a Field Value on the form

Matthew Knight
Tera Guru

I have created a UI action to display a GlideModalForm once clicked. This all works as expected but when I try to use either the addParm or setPreference options to preset a field to certain value it continues to remain blank.

I have included my script below:

MatthewKnight_0-1700822716987.png

 

The Modal is displayed but the description field remains empty

MatthewKnight_1-1700822767558.png

Appreciate any assistance here as the addParm or setPreference options are not working to achieve this.

1 ACCEPTED SOLUTION

Totally my bad, I misunderstood the requirements.

What you need has nothing to do with any UI Page or UI Macro.

What you need is to use parameter named sysparm_query; e.g:

var gmf = new GlideModalForm('Create Purchase Order', 'x_icaew_work_items_purchase_order');
gmf.setPreference('sysparm_query', 'description=Some description');
gmf.setPreference('sys_id', '-1');
gmf.render();

Basically that is the parameter that forms will look at to set initial values.

 

I'm assuming x_icaew_work_items_purchase_order is the name of the table containing Purchase Order records that you want to create.

View solution in original post

29 REPLIES 29

You're welcome and thanks for marking the correct answer! 😄

Hi Kilo,

 

I to have same requirement but in my case i need attachment and worknote from enhancement to this dialog (create Story).

Can you give me some input how we can have attachment and worknote as well ?

 

Thanks

Pramod Pandey

@Pramod Pandey2 can you describe the full requirements?

Tai Vu
Kilo Patron
Kilo Patron

Hi @Matthew Knight 

Let's try the below, it should do the trick.

Screenshot 2023-11-24 at 18.38.23.png

How to pass value in GlideModal setPreference UI macro

 

Cheers,

Tai Vu

Hi @Tai Vu 

Thank you for your response. I have tried this but this is not working either.

I am initiating the GlideModalForm from a UI action so am unsure how the UI Macro is meant to interact with the rendered GlideModalForm. 

The example provided was for a GlideModal so not sure if the API interacts differently.

Thank you for your input.

Kind regards