Need logic to make comments mandatory when state is changed from another state to "on hold" only on initial change

Heather White
Mega Guru

Hi Community,

     I have a requirement that the "comments" field be mandatory when the state of an incident is "on hold".  I need to create logic that makes this field mandatory only on the initial state update.  For example, if the state has been changed to "on hold" and a user goes back in to update work notes, the comments field should not be mandatory at this time as the update has already been made.

How can I accomplish this?  I have a UI policy created, but it is checking the state each time, so the comments are always mandatory.

Thank you,

Heather

 

1 ACCEPTED SOLUTION

Allen Andreas
Administrator
Administrator

Hi,

You can use an onChange client script for that field that upon change to On Hold, you can make the comments mandatory. This would only take effect onChange of that field and not if a user comes to that form without changing it, but needs to make update to another field, etc.

(EXAMPLE😞

find_real_file.png

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }
    if (newValue == 3) {
        g_form.setMandatory('comments', true);
    }
}

Please change the value 3 if "On Hold" is not 3 for your instance. 3 is the default value for the state field on Incident for On Hold.

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

View solution in original post

3 REPLIES 3

sachin_namjoshi
Kilo Patron
Kilo Patron

Configure business rules to make comment mandatory so that it works on both client and server side/

You have current and previous objects in business rules which you need to make use of.

 

Regards,

Sachin

Allen Andreas
Administrator
Administrator

Hi,

You can use an onChange client script for that field that upon change to On Hold, you can make the comments mandatory. This would only take effect onChange of that field and not if a user comes to that form without changing it, but needs to make update to another field, etc.

(EXAMPLE😞

find_real_file.png

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }
    if (newValue == 3) {
        g_form.setMandatory('comments', true);
    }
}

Please change the value 3 if "On Hold" is not 3 for your instance. 3 is the default value for the state field on Incident for On Hold.

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Thank you Allen!  This worked for me.