Hide Button On Form Task

yana7
Tera Contributor

 

I'm trying to hide buttons on a form using a UI Action when the MTC field is False. I've tried several methods, but I haven't been successful yet.

This my Code

$(g_form.getControl('sysverb_record_time')).hide();
    $(g_form.getControl('assign_to_me')).hide();
    $(g_form.getControl('sysverb_cancel')).hide();
 
    g_form.removeOption('sysverb_record_time');
    g_form.removeOption('assignToMe();');
    g_form.removeOption('sysverb_cancel');

    $$('#assign_to_me')[0].hide(); //This will hide the top button
    $$('#assign_to_me')[1].hide(); //This will hide the bottom button as well
 
yana7_1-1719894971507.png

 

2 REPLIES 2

Harsh_Deep
Giga Sage
Giga Sage

Hello @yana7 ,

 

Please go into the Ui Action and in the related list you have Ui Action Visibility and Create a new entry there.
Set visibility as Exclude.

 

Please find the attachment.

Harsh_Deep_0-1719900526477.png

 

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.

Dnyaneshwaree
Mega Sage

Hello @yana7 ,

Please refer below code, compare it with your existing code and update it accordingly:

function onLoad() {
    // Check if the MTC field is false
    if (g_form.getValue('mtc') === 'false') {
        // Hide buttons using jQuery and g_form
        $(g_form.getControl('sysverb_record_time')).hide();
        $(g_form.getControl('assign_to_me')).hide();
        $(g_form.getControl('sysverb_cancel')).hide();
 
        g_form.removeOption('sysverb_record_time');
        g_form.removeOption('assignToMe();');
        g_form.removeOption('sysverb_cancel');
 
        // Ensure to check if elements exist before trying to hide them
        if ($$('#assign_to_me').length > 0) {
            $$('#assign_to_me')[0].hide(); // Hide the top button
            if ($$('#assign_to_me').length > 1) {
                $$('#assign_to_me')[1].hide(); // Hide the bottom button as well
            }
        }
    }
}

// Run the function when the form loads
onLoad();

If my solution helps you any way then mark it as accepted and helpful.

Thank You!!

Please accept my solution if it works for you and thumps up to mark it as helpful.
Thank you!!

Dnyaneshwaree Satpute
Tera Guru