Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

Vin Fredrick
Tera Expert

I had a very simple requirement: toggle (hide/show) a form field via an UI Action button. This is achievable - if you first check if the field is visible or not - and then set its visibility (hide it or show it). 

I've seen some Community answers on this topic - eg., can't be done, use UI Policy, etc., The one that really works is listed here

To summarize: if you really need to get this done via n UI Action - the code that works is: 

(g_form.isVisible(g_form.getGlideUIElement("FIELD_NAME"), g_form.getControl("FIELD_NAME")))

Now, coming to my use-case: 

function onCondition(){
	
	if(g_form.isVisible(g_form.getGlideUIElement("script"), g_form.getControl("script"))){ // Check if the field named "script" is current visible
		g_form.setDisplay('script',false);  // It's visible, so - hide it.
	}
	else{ 
             // The "script" field is currently NOT visible, so show it
		g_form.setDisplay('script',true);
	}

}

 

find_real_file.png

 

That's it! It's pretty basic - but I hope it helps someone. 

Comments
d_ladou
Tera Expert

Thanks Vin! Really saved my life with this one - I saw other threads saying this wasn't possible so I'm really glad I stumbled onto this. Works great in my implementation. Kudos!

kalaivani22
Tera Expert

If a field "Field1 " has to be shown in a customer order record, only when a fallout order record's state turns to "open".The customer order and fallout order are linked through customer order number. solution please?

 

Version history
Last update:
‎07-17-2022 04:13 AM
Updated by: