How to Minimize the Gap between two Fields

JaganN971616731
Tera Contributor

Hello community,

 

I have a requirement that when the CAB required is checked the CAB date and CAB recommendation field should be visible. I have achieved the functionality using UI policy. However when the form load initially there is a gap(marked with red square) between two fields(CAB required and Outage required). Can you please suggest the code how to minimize the gap between two fields.

When unchecked:

JaganN971616731_0-1713510504780.png

 

When checked:

JaganN971616731_1-1713510504784.png

 

Code in UI policy:

function onCondition() {
    g_form.setVisible('cab_date_time'false);
    g_form.setVisible('cab_recommendation'false);
}

 

Thanks & Regards,

Jagan

1 ACCEPTED SOLUTION

Hi @JaganN971616731 ,

 

In UI policy, there are two scripts: one that executes if a condition is met, and a second one that executes when the condition is not met. In the "Execute If False" script, you would write the opposite logic of the "Execute If True" script. Please check below example 

 

AstikThombare_0-1713515086684.png

 

AstikThombare_1-1713515126579.png

 

Execute if true Script -

 

 

function onCondition() {
    g_form.setDisplay('u_cab_date_time', true);
}

 

 

Execute if false Script -

 

 

function onCondition() {
    g_form.setDisplay('u_cab_date_time', false);
}

 

 

When Form is Loaded 

 

AstikThombare_2-1713515225052.png

 

When Cab required is checked

 

AstikThombare_3-1713515272418.png

 

When the 'Cab Required' checkbox is unchecked

AstikThombare_4-1713515363394.png

 

             If my reply helped with your issue please mark helpful 👍 and correct ✔️ if your issue is resolved.

 

                         By doing so you help other community members find resolved questions which may relate to an issue they're having

 

 

Thanks,

Astik

 

 

 

 

 

 

 

View solution in original post

3 REPLIES 3

Astik Thombare
Tera Sage

Hi @JaganN971616731 ,

 

You need to understand difference between setDisplay() and setVisible() . both are used to hide fields on form but there is difference which is explained in below points -

 

 setDisplay()

 

If the field is hidden, the space is used to display other items. that means below field like, if sub status of the incident is not displaying then assignment group will display on that blank space.

 

setVisible()

 

If the field is hidden, the space is left blank. You can see the change on the form clearly.

 

Please make changes to your code as below

 

 

 

function onCondition() {
    g_form.setDisplay('cab_date_time', false);
    g_form.setDisplay('cab_recommendation', false);
}

 

 

 

             If my reply helped with your issue please mark helpful 👍 and correct ✔️ if your issue is resolved.

 

                            By doing so you help other community members find resolved questions which may relate to an issue they're having

 

 

Thanks,

Astik

 

Hi @Astik Thombare 

 

When I create a new CR initially the fields are visible on the UI. After making the Boolean true and then false the fields are not visible(working as expected). My requirement is that when you create a new CR the fields should not be visible on the UI. Over make the Boolean true it should be visible.

JaganN971616731_0-1713513726941.png

After make it true and then false:

JaganN971616731_1-1713513843504.png

Regards,

Jagan

Hi @JaganN971616731 ,

 

In UI policy, there are two scripts: one that executes if a condition is met, and a second one that executes when the condition is not met. In the "Execute If False" script, you would write the opposite logic of the "Execute If True" script. Please check below example 

 

AstikThombare_0-1713515086684.png

 

AstikThombare_1-1713515126579.png

 

Execute if true Script -

 

 

function onCondition() {
    g_form.setDisplay('u_cab_date_time', true);
}

 

 

Execute if false Script -

 

 

function onCondition() {
    g_form.setDisplay('u_cab_date_time', false);
}

 

 

When Form is Loaded 

 

AstikThombare_2-1713515225052.png

 

When Cab required is checked

 

AstikThombare_3-1713515272418.png

 

When the 'Cab Required' checkbox is unchecked

AstikThombare_4-1713515363394.png

 

             If my reply helped with your issue please mark helpful 👍 and correct ✔️ if your issue is resolved.

 

                         By doing so you help other community members find resolved questions which may relate to an issue they're having

 

 

Thanks,

Astik