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

Krushna R Birla
Kilo Sage

Hi @Wayne Richmond 

 

I just wanted to clarify a few things before answering this:
1. The u_integrated_v2 field is on the core_company table, right?
2. The Vendor field on the Incident form is a reference field to the core_company table.
3. Your requirement is to make the Vendor Comments field visible when the user changes the Vendor field on the Incident form, correct? So, it will check if u_integrated_v2 is true on the core_company table for that vendor. Only then should Vendor Comments be visible; otherwise, it should not.


Please check and let me know if my understanding of your requirement is correct so that I can help you out.

 

Thanks,

Krushna Birla

Hi Krushna, that summary is correct, yes.

Bert_c1
Kilo Patron

Seems the onChange client script you have should work.  You can add:

 

var intVar = vendor.u_integrated_v2;
alert('u_integrated_v2 = ' + intVar);

to test.

Hi Bert. I did this and can confirm the Client Script pops the alert.