How to hide button from form on condition?

IamAmolB
Tera Guru

Hi Experts,

I have written this code but it is not able to run can you please suggest what to do any update on below code. please suggest

find_real_file.png

No error No warnings.

still not able to run. please suggest.

1 ACCEPTED SOLUTION

Hi Amol,



Search for the ui action that you want to hide.


Open it, you will find condition field in it. You can mention your condition for the visibility of that ui action there.


Below is the snapshot for reference.




UI Action form.jpg





Raj


View solution in original post

22 REPLIES 22

xuan
Giga Contributor

Hi


I tried this one within a scoped app.


It doesnt seem to be working.


Do you know how to fix it?



Cheers,


Xuan


Hi!


I am trying something similar.


In my case, I want to hide the "Close"-button on Change Request IF the change is an Emergency Change, State is in "Review" and The Change Request has tasks that is still open.



I have written a Client Script but I can not seem to get it to work..



function onLoad() {


  var sysid = g_form.getUniqueValue();


  var tsk = new GlideRecord('change_task');


  tsk.addQuery('change_request',sysid);


  tsk.addQuery('active',true);


  tsk.query();


  if (state == 0 && type == 'emergency' && tsk.hasNext()){


  document.getElementById('state_model_move_to_closed').style.display = 'none';


  }


   


}



Please help!


Hi Mathias,



No need to do that in a client script. You can do that in the condition of the button like the "correct answer" is shown in this thread. Let me know if you need more help.



//Göran


How do I specify the condition that all tasks must first be closed?


you can make a function(script include) that you call in the condition field and that does that check for you and return true/false depending if there is any active tasks or not.



//Göran