UI Policy and Client Script ignored when applied to Journal Input field

Wayne Richmond
Tera Guru

Hi all.

 

I've created a new Journal Input field called 'Vendor comments' on the Task table. I've nested the new field with the Comments and Work notes fields on the Incident form. I only want the field to be visible when a selected Vendor is an integrated vendor. The Vendor field on the Incident form is a reference field to the core_company table and "integrated vendor" is determined by a true\false field called 'u_integrated_v2' on that record:

WayneRichmond_0-1722598376397.png

WayneRichmond_1-1722598439385.png

 

I have created a UI Policy to show\hide Vendor comments, however, it doesn't work when the field changes, only when the page is loaded. Example, on a new record, the field is hidden. When I select an integrated vendor, it should appear, but it does not:

WayneRichmond_2-1722598754864.png

WayneRichmond_4-1722598856103.png

 

When I save the record, the field appears as it should:

WayneRichmond_5-1722598886487.png

 

Furthermore, changing the Vendor at this point should hide the field, but this does not work either until the record is once again saved and the form relaoded.

 

Here is my UI Policy:

WayneRichmond_6-1722599004036.png

 

I also created an onChange Client Script to try and manage it that way, but that doesn't work either:

WayneRichmond_7-1722599224933.png

 

I know you can change journal field behaviour using UI Policies because Work notes becomes mandatory when you change the Assignment group, so I don't see why I can't show\hide my new Vendor comments field. Any thoughts?

1 ACCEPTED SOLUTION

You gave me an idea and I've got it working. I used setDisplay instead of setVisible and it works as desired:

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }

    var vendor = g_form.getReference('u_vendor');
    if (vendor.u_integrated_v2 == 'true') {
        g_form.setDisplay('u_vendor_comments', true);
    } else {
        g_form.setDisplay('u_vendor_comments', false);
    }
}

View solution in original post

8 REPLIES 8

What you have worked for me, but I don't have any UI policies trying the same.

Hi Bert. I'm not sure what you mean by "I don't have any UI policies trying the same.".

If you've created a new Journal Input field to test this, make sure you add it to the Filter Activties and put it next to Comments or Work notes, otherwise the field is independant and doesn't work like Comment and Work notes.

You show UI Policies and a Client Script, I don't know what is 'active' in your instance. Now, I have created like fields and tested, and found that g_form.setVisible() does not work on a Journal field, I'll try a UI Policy to see if I can get that to work.

 

And the UI Policy only works when the form is loaded 😞 I'm not sure at this point on how to achieve the desired behavior.

You gave me an idea and I've got it working. I used setDisplay instead of setVisible and it works as desired:

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }

    var vendor = g_form.getReference('u_vendor');
    if (vendor.u_integrated_v2 == 'true') {
        g_form.setDisplay('u_vendor_comments', true);
    } else {
        g_form.setDisplay('u_vendor_comments', false);
    }
}