UI Macro - How to get the value of a reference field in jelly?

JLeong
Mega Sage

Good day!

 

In the incident form, I have UI macro beside the caller name. The UI macro serves as an identifier to show if the caller is a member of a specific group. When hovering the mouse over the icon, I need to show the group name.

 

When populating the incident form, how do I get the value of the caller field in jelly? 

 

<g2:evaluate var="jvar_project_name" jelly="true">
//Get the special project name, if it exsists, to display on hover of the icon
var name = "";
var userObject = g_form.getReference('caller_id');
var empID = userObject.employee_number;
gs.log("ID =" + empID,');
....
</g2:evaluate>

 

Thank you in advance.

6 REPLIES 6

g_form inside a <g2:evaluate/>? Really?

So much for

-O-
Kilo Patron
Kilo Patron

This will fetch the Caller:

 

<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
...
	<script type="text/javascript">

g_form.getReference('caller_id', u_onCallerID);

function u_onCallerID (recordSet) {
    if (recordSet.rows.length > 0) {
        var empID = recordSet.employee_number;

        console.log(empID);
    }
}

	</script>
...
</j:jelly>

 

and will print it to the browser's console.

It uses the asynchronous version of g_form.getReference; so add all code that should be executed when the result is available to function u_onCallerID.