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

Using g_form.getValue in a UI Macro

Brian Broadhurs
Tera Contributor

I have a UI macro associated with the company field on the Task table which generates a list of Incidents for the company (I have cloned and hacked the OOTB user_show_incidents UI Macro which is associated with the Caller field on the Incident table). I have created a custom table - Incident Task - which is an extension of the Task table - these records can only be created via a UI Action on the Incident form, so the Parent field is always set to the "owning" Incident. The Incident Task form displays the Company field from the parent Incident record (I don't copy the value of the Company field from the Incident to the children Incident Tasks).

Now for my issue - in my UI Macro script I do a g_form.getValue('company'); When the macro is called from the Incident form, this works fine, but when the macro is called from a child Incident Task form, I get a different value, even though the displayed value is the same - and I can't fathom how to use this value to get the reference to the core_company table that I need in my script.

Can anyone point me in the right direction?

Brian Broadhurst

2 REPLIES 2

Brian Broadhurs
Tera Contributor

Hi,

I finally got the script to work using:

var s = reference.split('.');
var formName = s[0];
var fieldName = reference.substr(reference.indexOf(".") + 1);
var v = g_form.getValue(fieldName);

That takes everything after the first "." as the field name, so it doesn't matter if it being called by the parent or the child.


Mark Endsley
Tera Guru

You actually can use g_form in a UI Macro

https://www.youtube.com/watch?v=ivP3bl7r0Ws