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

passing values from a form to ui page through a ui action

himanshuverma
Kilo Explorer

Hi all

I am trying to redirect from a form to a ui page through a ui action.

the UI page contains the same fields as the form.

I want to display the values from the corresponding form on the ui page fields.

How can i pass the values from the form to ui page on pressing UI action button and display it on the corresponding fields of ui page?

Thanx in advance

Regards

Himanshu

5 REPLIES 5

geoffcox
Giga Guru

You can use a client side UI Action to pass variables to a UI Page.

Here is a sample script for the UI action. The UI Action's Onclick field would contain "do_call_ui_page()"



function do_call_ui_page(){
var comment_block = g_form.getValue('variable_1');
var v1 = g_form.getValue('variable_1');
var v2 = g_form.getValue('variable_2');
var gDialog = new GlideDialogWindow("Your UI Page");
gDialog.setTitle('Your UI Page Title');
gDialog.setPreference('table','this_table');
gDialog.setPreference('v1',v1 + '' || ''); // convert to string and OR with empty string
gDialog.setPreference('v2',v2 + '' || '');
gDialog.render();
}


Then you can retrieve the variables on the UI Page:


<g:evaluate var="jvar_v1" expression="RP.getWindowProperties().get('v1')" />
<g:evaluate var="jvar_v2" expression="RP.getWindowProperties().get('v2')" />


These variables can then be referenced somewhere in the html of your UI page:


<span id="var1">${jvar_v1}</span>
. . .
<span id="var2">${jvar_v2}</span>


I hope this helps!

Cheers,
Geoff.


Hello Geoff,

 

Do you know how I can access the form data in the client script section of the UI Page? Also how can I then fill data on the form from the UI Page?

 

Thanks,

Andrew

Did you got solution 

himanshuverma
Kilo Explorer

Thanx man, your code is working perfectly. . 🙂