How to Make Custom UI action Disable on condition

Kruthik M Shiva
Tera Contributor

Hi All,
I have created a custom UI action for one of the forms and I have a requirement that once it is clicked by user it should be hidden/disable from that form. It should be hidden/disable even if opens the same record again. Please provide pointers on this like what needs to be done.

1 ACCEPTED SOLUTION

SANDEEP28
Mega Sage

@Kruthik M Shiva As you are trying to send email using UI action. You can create one Boolean field (True/False) in table on which you have created UI action. After your email sending code, you can add below code to update that boolean field in script section.

 

Field label- Email sent  

 

Code- 

current.email_sent = true;

current.update();

action.setRedirectUrl(current);

 

Put below expression in condition field

current.email_sent == false;

 

So now you have identifier as "Email sent" which will tell you that work of your UI action is completed and you can use the same in condition field of UI action to hide/show the UI action on form.

 

If I could help you with your Query then, please hit the Thumb Icon and mark as Correct !! 

View solution in original post

4 REPLIES 4

Arpan Baishya
Kilo Sage

Hi @Kruthik M Shiva,

When you click the custom UI Action, do any of the record fields get set to a different value than before? If yes, we could probably use that as part of the UI Action condition and limit visibility.

Hi @Arpan Baishya ,
Thanks for replying, No once that UI action is clicked an email will be sent with some catalog item. In the current form nothing will be set.

Hi @Kruthik M Shiva 


Well, even if nothing changes on the current record, you could check if something unique is happening with respect to the current record in the backend (which is probably why you don't want to display the UI Action again for that record). For example - an associated record from another table that can serve as a flag for displaying the UI Action or not.

If that's the case, you could write a function that performs this check and returns true/false, and include it in a Script Include. And then call it from the Condition field.

Since I am not fully aware of the specifics of the problem, I'm trying to give you a sense of direction in which you may want to proceed. Hope that helps.

 

SANDEEP28
Mega Sage

@Kruthik M Shiva As you are trying to send email using UI action. You can create one Boolean field (True/False) in table on which you have created UI action. After your email sending code, you can add below code to update that boolean field in script section.

 

Field label- Email sent  

 

Code- 

current.email_sent = true;

current.update();

action.setRedirectUrl(current);

 

Put below expression in condition field

current.email_sent == false;

 

So now you have identifier as "Email sent" which will tell you that work of your UI action is completed and you can use the same in condition field of UI action to hide/show the UI action on form.

 

If I could help you with your Query then, please hit the Thumb Icon and mark as Correct !!