Change field behavior

Hello,

I would like to configure my Form to change another fields behavior once one of the options in the screenshot is selected. Where should I place the JavaScript code for that? I know how to program a button by entering the code in the "OnClick" property, but I wasn't able to figure out how to implement this with a Choice Field.

Thank you,

Hello @joaovicentini,

Welcome to Plumsail Community!

You can add a function that will be executed when the value of the field changes:

fd.spRendered(function() {

    fd.field('Field1').$on('change', function(value) {
        //log new value to browser's console
        console.log(value);
    });
    
});

That works for all fields. Please learn more in our documentation.

Thank you for your response @mnikitina

I am testing what you suggested, but I am not sure where the code needs to go in Design Forms.

I have entered the following function code to the JavaScript option:

fd.spRendered(function() {

function changefield() {
    if (fd.field('Priority').value == 'High') {
         fd.field('Business_x0020_Unit').value = 'ARS IS Team';
    }
}

});

Now, I need to call that function whenever the Priority Field is changed:

fd.field('Priority').$on('change',changefield);

Where do I enter the code above to call the function?

Thank you again

Hello @joaovicentini,

I'm sorry, didn't notice that you use Forms Designer for Classic UI. It has a different API so the code must be:

//call function when field value changes
fd.field('Priority').change(function(){
      if (fd.field('Priority').value() == 'High') {
         fd.field('Business_x0020_Unit').value('ARS IS Team');
    }
});

Paste the code to the JavaScript editor. Learn more about Forms Designer API in our documentation. If you have any question regarding Forms Designer usage please email us at support@spform.com