UI action return false

Not applicable

Hi everyone.

How do I make a UI action do nothing? By nothing, I mean don't even reload the page?

I have a button that shows up but I need it to only be clickable if a particular field is filled in. I don't want to make this a condition of the button because the button wouldn't be there unless the field was populated properly before the page loaded.. this would just mean they'd need to save the form after updating the field before the button would show up.

Instead, I want to just do something like


if (current.field == "empty")
{
     return false;
}


But that doesn't seem to be doing anything at all. It stops the rest of the UI action from processing but it still reloads the main form.

Any help would be much appreciated.
5 REPLIES 5

TJW2
Mega Guru

What if you do the opposite:

if(current.field !=''){
do your thing;
}

Or if you haven't 'saved' the record yet, you will need to run 'client-side' and use:
if (g_form.getValue('field') != '').....


Not applicable

Hi Terri,

Unfortunately that makes the screen refresh. I created the simplest of scripts in the sandbox



testThis();

function testThis(){
}


And although nothing is happening in the code, it redirects you back to the list view of the table you are in.


anshuman_bhatia
Giga Contributor

I guess writing an onsubmit client script and then returning 'false' (based on the conditions) could be a solution for your problem.

That would stop the form from being submitted.


Thank you for this. I thought of this but I told myself "nah, that can't be right. why would a client script have any impact on a UI action?" But I gave it a whirl and returning false in an onsubmit script absolutely did what I needed.

Thank you!