Fd.clear(); Not clearing form

Hi
We've just noticed an issue with a form that has been running well for months, is now not rendering correctly if we use fd.clear();

We show and hide fields based on class and from this morning, three of these 'show/hide' classes don't work if fd.clear(); is in the JS.

Is there another way to clear the form - I mainly use this so that if the page is refreshed, the form is cleared.

This is how I was using fd.clear

fd.spRendered(function() {

    //fd.clear();
    
    fd.field('ITSupplier').ready().then(function () {
        // sort lookup values
        fd.field('ITSupplier').orderBy = { field: 'Title', desc: false };
        fd.field('ITSupplier').refresh();
    });

Thank you

Hello @SClacherty1,

How do you show and hide fields? Are you using the code? Please share it so we could reproduce the issue.

Hi @mnikitina

I'm not 100% sure I am answering correctly.

 //Enter this invoice into Total Synergy
    function showHideTSNo() {                                                     
    if(fd.field('TSEntry').value === 'I need someone to do it') {                 
        $('.StageShow').show(); 
        }
    else {
        $('.StageShow').hide(); 
        }
    }
    
    //Is the invoice relating to a vehicle 
    function showHideVehicleY() {          
    if(fd.field('Vehicle').value === 'Yes') {
        $('.VehicleYesShow').show();  
        }
    else {
        $('.VehicleYesShow').hide();
        }
    }

    fd.field('Vehicle').$on('change',showHideVehicleY); 
    fd.field('TSEntry').$on('change',showHideTSNo);
    
   
    // Calling functions on form loading
    showHideTSNo();
    showHideVehicleY();

And then entering class into General on the display view
Plumsail screenshot 01022021

Also, clearly I have commented out the fd.clear(); because it stopped working. I had meant to remove the // when I posted :frowning:

@SClacherty1,

Does the code that show/hides fields work fine without clearing the form with fd.clear();?

Are we talking about New or Edit form?

Hi @mnikitina

Yes, the show hide works fine without the fd.clear(); - it's currently functioning well - I would just like the form to empty when it is refreshed. It is on the New form.

@SClacherty1,

Thank you for the details!

Developers confirmed that this is a bug. I will let you know as soon as it is fixed.

@SClacherty1,

As a temporary workaround, you can use this code to clear the form:

fd.spRendered(function() {
    fd.field('Attachments').ready().then(function(){
        fd.clear();
    });
    //Your code is here
});

Thank you @mnikitina
The workaround works :grinning:

1 Like