How to change the Form - view based on field value

KeerthiPraV
Tera Contributor

I have a Custom table, In that table ticket type(Choice field) have 2 values.
If i select one value it should change the view to another view, if i select 2 value it should change the view accordingly.

Can you please help me to configure it.

1 REPLY 1

Mohammed8
Giga Sage

Hi @KeerthiPraV 

What's the use-case here?

 

I tried on the Incident form using an onChange Client Script on the Category field to switch views for hardware and software:

 

function onChange(control, oldValue, newValue, isLoading) {  
if (isLoading || !newValue) {

        return;

    }

    var view = {

        "hardware": "ess",

        "software": "major_incidents",

    };

    var targetView = view[newValue.toLowerCase()];

    if (targetView) {

        switchView("section", "incident", targetView);

    }

}
 
Drawbacks:
1) Does not work when record is new
2) if record exist, need to save the record first and then proceed with change in field which pops up dialog box as shown below, after clicking leave reloads form with changed view.
 
Mohammed8_0-1768862760478.png

 

Mohammed8_1-1768863134618.png

 

I searched but could not find workaround for above mentioned draw backs 
 
Instead of switching views, you can use UI Policies to show/hide sections or fields based on values
 
If this was helpful, please mark it as helpful.
 
Regards,
Mohammed Zakir