Ui Page: Access Client Script Variables in HTML

Mathias_Netgain
Tera Contributor

Hi,

I am trying to figure out how to access a Client Script variable in the HTML code on a UI page.

My goal is to have a g:ui_reference field on the page which is prepopulated with a sys_id (and correct display value) that is fetched from a UI Action.

If I try to set the value with gel() or document.getElementById, it wont set the proper reference, just the string value..

 

 

screenclip.PNG

1 ACCEPTED SOLUTION

@Mathias_Netgain 

To prepopulate from UI action, Please refer the sample code.

This UI page gets two URI parameter named sysparm_table_name & sysparm_sysid. In your case it should be sys_id of CI and display value. 

 

VasantharajanN_1-1671799998321.png

UI Action

VasantharajanN_2-1671800033025.png

 


Thanks & Regards,
Vasanth

View solution in original post

3 REPLIES 3

Vasantharajan N
Giga Sage
Giga Sage

You client script should be like below. 

function createRelationship(){
	alert(gel(base_ci_field).value);
	alert(gel(target_cis_input).value);
}

 


Thanks & Regards,
Vasanth

@Mathias_Netgain 

To prepopulate from UI action, Please refer the sample code.

This UI page gets two URI parameter named sysparm_table_name & sysparm_sysid. In your case it should be sys_id of CI and display value. 

 

VasantharajanN_1-1671799998321.png

UI Action

VasantharajanN_2-1671800033025.png

 


Thanks & Regards,
Vasanth

Kalyani Jangam1
Mega Sage
Mega Sage

Hi @Mathias_Netgain 

Use gel(sys_display.basic_ci_field).value=baseCIname;