Pull field values of form to display in UI pages

gkris
Tera Contributor

Hello,

Have created a UI action (Preview button), when clicked, an UI page will pop up as preview. All this is happening before I submit the submit button.

My requirement is I need to pull certain filed values to display it in UI pages. However, I am unable to pull the field values to be displayed in UI pages.

What should be my approach for this requirement.

6 REPLIES 6

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Gagan,



So you should send some form values to the UI page and display that in UI page. Following link shows you what you want.


https://www.servicenowguru.com/system-ui/glidedialogwindow-advanced-popups-ui-pages/



Here is the script:



UI Action: Client Side


Script:



var comments = g_form.getValue("comments");


var shortDescription = g_form.getValue("short_description");



var dialog = new GlideDialogWindow("uiPageName");


dialog.setTitle("Add Task Comments");


dialog.setPreference("comments", comments);


dialog.setPreference("shortDescription", shortDescription);


dialog.render();


}



Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.


Thanks


Ankur


Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hello Ankur,



I need to preview my UI page even before I submit the form. I have got the UI action part exactly. However the challenge I am facing is I need to pull the field values from the form, So I need to write client scripts in the UI page. The link you have provided uses g:evaluate, which I feel is server script.



Regards


Gagan k


Goran WitchDoc
ServiceNow Employee
ServiceNow Employee

It's how you do it. The UI Page that shows up renders through the server, so that the reason it looks like it does. But it's how it works. Since the UI Page it self is a record on the server, the client needs to go fetch it when the user clicks on the ui action. and from there it do the server stuff.


Goran WitchDoc
ServiceNow Employee
ServiceNow Employee

Here is another example that I wrote a long time ago: It's Now or Never - A hitchhikers guide to ServiceNow and it's universe: Making your own "new Featur...



It's pretty much the same thing you want. We wanted to preview how a field on a knowledge article looked like in a ui page. So I build a UI Action for it on the article form.



Look at nr.3 which is the ui page and nr.5 which holds the UI Action