Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

HR Agent Workspace for HR Case Management: Automatically refresh the page when fields are updated

psypniew
Giga Guru

Hi Community,

 

    I have a Business Rule which updates 2 HR Case Fields values:

  •  State -> Work in Progress,
  •  Assigned to -> HRlegal Test

 

psypniew_0-1754064004357.png

 

When these fields are updated, I need to refresh the Form in the HR Agent Workspace for HR Case Management to see the "Preview Document" Button (displayed when State changes to Work in Progress). 

psypniew_1-1754064072673.png

How to automatically refresh the form to be able to see the Button, please ?

 

Best Regards,

Paul

 

 

1 ACCEPTED SOLUTION

psypniew
Giga Guru

Hi Community,

 

I resolved the issue by creating a Client Script on HR Case table, onChange 'Assigned to'. It saves/reloads the form.

HR Case with New Hire Contract CDI Service: Automatically save/reload the HR Case form when 'Assignment Group' is changed to 'HR Legal' and 'Assigned to' changed.

 

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

    if (g_form.getValue('assignment_group') === '16fda1321ba0621063b2a8e8b04bcb20' && g_form.getValue('hr_service') === '06f70487874356103c66cbf5cebb354f') {
        // Save the form and reload after save completes
        g_form.save(function() {
            location.reload();
        });
    }
}

 

Best regards,

psypniew

View solution in original post

2 REPLIES 2

abirakundu23
Giga Sage

Hi @psypniew ,
Please check the below thread:
https://www.servicenow.com/community/developer-forum/refreshing-the-incident-page/m-p/1608133/page/2

Please mark helpful and correct answer if it's worthy for you.

psypniew
Giga Guru

Hi Community,

 

I resolved the issue by creating a Client Script on HR Case table, onChange 'Assigned to'. It saves/reloads the form.

HR Case with New Hire Contract CDI Service: Automatically save/reload the HR Case form when 'Assignment Group' is changed to 'HR Legal' and 'Assigned to' changed.

 

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

    if (g_form.getValue('assignment_group') === '16fda1321ba0621063b2a8e8b04bcb20' && g_form.getValue('hr_service') === '06f70487874356103c66cbf5cebb354f') {
        // Save the form and reload after save completes
        g_form.save(function() {
            location.reload();
        });
    }
}

 

Best regards,

psypniew