Hide table based on field value

Hello,

We're using Plumsail HelpDesk deployed to on-premise SharePoint Server 2019. We would like the table highlighted in the screenshot below to be hidden whenever the Status field is different than 'Draft'.

We have entered the following code under the JavaScript option of the Edit form, but it doesn't seem to be working correctly:

fd.field('Status').value(function(){
if (fd.field('Status').value != 'Draft') {
$('.table-submit').hide();
}
});

Is that some something you can help us with, please?

I was wondering if this is something you guys can help me with :slight_smile:

Thank you!

Hi Joao! I will look into this and contact you soon.

Joao, please try the code below:

fd.spRendered(() => {

    function hideShowSubmit() {
        if (fd.field('Status').value !== 'Draft') {
            // hide
            $('.table-submit').hide();
        } else {
            //show
            $('.table-submit').show();
        }
    }

    // Calling hideShowSubmit when the Status field value changes
    fd.field('Status').$on('change',hideShowSubmit);

    // Calling hideShowSubmit on form loading
    hideShowSubmit();

});

Hi @Evgeniy , thank you for the detailed response. The code you shared did not work and when I check the browser console, it says "fd.spRendered is not a function". I did a little research for this error in the Plumsail Community and people were saying this command does not work in Forms Designer application. See screenshot of the error:

As you advised, I placed the code under the JavaScript snippet - see screenshot:

Do you have any other suggestions on how this code would work in Forms Designer? THank you!

Please try the code below, it is based on this solution.

function hideShowSubmit() {
  if (fd.field('Status').value() != 'Draft') {
    // hide
    $('.table-submit').hide();
  } else {
    //show
    $('.table-submit').show();
  }
}
 
// Calling hideShowSubmit when the user changes the status
fd.field('Status').change(hideShowSubmit);
 
// Calling hideShowSubmit on form loading
hideShowSubmit();

issue resolved! Thank you so much! I really appreciate your help!