Button show on display form depending on special status (field choice)

Hello everyone,

I'm looking for hidding a button on a display form depending on a status which is a SP choice field. So I've found a topic similar and apply it to my case.

My problematic is : I would like to apply it on a "or" condition

Explanation : if one of the listed status already selected then show button, if not so, let it hide.

fd.spRendered(function(vue) {
    function showHideButton() {
        if (fd.field('pr_Status').value === 'APPROVED by budget...')
        && fd.field('pr_Status').value === 'APPROVED by proc...')
        && fd.field('pr_Status').value === 'ACCEPTED by legal...')
        && fd.field('pr_Status').value === 'ACCEPTED by legal without...')
        && fd.field('pr_Status').value === 'FINANCE, ok...')}
        
        {
            //show control
            fd.control('Button3').hidden = false;
        } else {
            //hide control
            fd.control('Button3').hidden = true;
        }
    }

    //call function on form load
    showHideButton();

    //call function on field change
    fd.field('pr_Status').$on('change', showHideButton)
});

What have I done wrong ?

Maybe the "or" condition liste are not correctly named ? is it a "}" problem ?

Thanks in advance for the ideas,

Hi @lolopixxx,

The OR operator works the same as the AND operator, but it's || instead of &&. Try this:

function showHideButton() {
    if (fd.field('pr_Status').value === 'APPROVED by budget...'
    || fd.field('pr_Status').value === 'APPROVED by proc...'
    || fd.field('pr_Status').value === 'ACCEPTED by legal...'
    || fd.field('pr_Status').value === 'ACCEPTED by legal without...'
    || fd.field('pr_Status').value === 'FINANCE, ok...') {
        //show control
        fd.control('Button3').hidden = false;
    } else {
        //hide control
        fd.control('Button3').hidden = true;
    }
}

thanks ! it perfectly workin ! :smiley:

1 Like