Hide/Display fields in the modal(g_modal.showFields) for Suspend ( HR case) and Suspend case( HR task) UI action in HR Agent workspace.

Pooja Kulkarni
Tera Contributor

Hello,

We have customized the UI page 'HR Suspend Dialog' which is being called from the 'Suspend' and 'Suspend case' UI action. As per the customization, Work notes field is NOT displayed always. It is displayed only when certain suspension reason is selected. We want the same functionality in HR Agent workspace as well.

If we look into the OOTB code for workspace , Work notes field has been defaulted and displayed always with below code:

https://devxxxx.service-now.com/sys_ui_action.do?sys_id=b65370019f22120047a2d126c42e701d&sysparm_view=&sysparm_record_target=sys_ui_action&sysparm_record_row=1&sysparm_record_list=sys_id%3Db65370019f22120047a2d126c42e701d%5EORDERBYorder&sysparm_record_rows=1


find_real_file.png
I want to display work notes field only when certain reason is selected. Please advice.

1 ACCEPTED SOLUTION

Muhammad Khan
Mega Sage
Mega Sage

Hi Pooja,

 

Consider it as a workaround to fulfill your requirement. You can try to show two modals

  1. Take Reason
  2. Take Work Notes

When user has provided the reason for which you want to show the work notes field, show another modal to take work notes from user. See the below script for reference.

function onClick(g_form) {

    var type = [{
        type: 'choice',
        name: 'u_type',
        label: 'New Type',
        mandatory: true,
        value: getMessage(' -- Select -- '),
        choices: [{
                displayValue: 'Best',
                value: 'Best'
            },
            {
                displayValue: 'Bad',
                value: 'Bad'
            }
        ]
    }];

    var workNote = [{
        type: 'textarea',
        name: 'work_notes',
        label: 'New Type',
        mandatory: true,
        value: getMessage('Work notes')
    }];


    g_modal.showFields({
        title: 'Enter New Values',
        fields: type,
        size: 'lg',
        height: 'md'
    }).then(function(selectedType) {

        if (selectedType.updatedFields[0].value == 'Best') {
            g_modal.showFields({
                title: 'Enter New Values',
                fields: workNote,
                size: 'lg',
                height: 'md'
            }).then(function(newWorkNote) {
                g_form.setValue('u_type', selectedType.updatedFields[0].value);
                g_form.setValue('work_notes', newWorkNote.updatedFields[0].value);
                g_form.save();

            });

        } else {
            g_form.setValue('u_type', selectedType.updatedFields[0].value);
            g_form.save();
        }

    });

}

View solution in original post

9 REPLIES 9

Hi @Muhammad Khan ,

Thank you for the workaround!
Please let us know how to display Date/Time field using g_modal.showFields.

 

Hello! I have same requirement, did you find something related to display date/time picker in Workspace modal?

Is it possible to use 1 modal. The customer doesn't like the 2 modals. Is it possible to show/hide the field in 1 modal? Thanks

royi
Tera Contributor

Hi Muhammad Khan 

 

How can we use the reference qualifier in the UI action where I'm using the same modal code.

I need to show the service offerings based on service (Parent) 

if I select the service, it should show the service offerings related to that service. Is it possible ?

 

 

Thanks

 

dhanuja v
Tera Contributor

Hi royi 
Did you get the solution for this? I am having the similar requirement .Can you help on this?