How do I add a force refresh rule to this business rule after SetAbrtAction is true?

ChuanYanF
Tera Guru

Dear experts,

 

I am facing a problem where currently if I did not tick the value_certified box for metric data task, it will abort the action but it wont force a refresh rule to refresh the page, so user have to refresh the page manually to go back to the previous state, but in the loading page it shows that the task has moved forward to awaiting approval state. So if I want to make the page refresh or force reload the page after it has check and the message also appear after it refresh and remain back in the in progress state. How can i do so?

ChuanYanF_1-1749534696781.png

 

ChuanYanF_0-1749534638867.png

 

1 ACCEPTED SOLUTION

ChuanYanF
Tera Guru

Instead of modifying the Business Rule, I added a query in the UI Action for Request Approval button, where I defined as follow:

if (!current.value_certified) {
    gs.addErrorMessage("Please select the check box to certify and acknowledge that the information provided by you is accurate.");
    action.setAbortAction(true); // Stop the action from continuing
} else {
    current.setValue('state', 3);
    current.update();
    action.setRedirectURL(current); // Redirect to the same form
}

View solution in original post

7 REPLIES 7

Chaitanya ILCR
Kilo Patron

Hi @ChuanYanF ,

you can create onSubmit client script for this

keep the BR as is 

create a onSubmit Client Script which does the same validation 

and if you condition is not satisfied as mentioned in the message(certify checkbox is not checked)

return false in the script

use method location.reload()  to reload the form

 

it might alert something like this 

 

ChaitanyaILCR_0-1749606782413.png

 

 

 

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

 

Hi Chaitanya, I tried using OnSubmit script but it does not work, but I am trying the onChange client script, but it also does not work, can you help me check my script??

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

    var checkboxValue = g_form.getValue('value_certified');

    if (checkboxValue !== 'true') {
        g_form.showFieldMsg('value_certified', 'Please check the box to certify before submitting for approval.', 'error');
        alert('Please select the check box to certify and acknowledge that the information provided by you is accurate.');

        // Revert the state change
        g_form.setValue('state', oldValue);

        // Optional: force refresh if needed (use only if state gets stuck visually)
        // setTimeout(() => location.reload(), 100);
    }
}

ChuanYanF
Tera Guru

Instead of modifying the Business Rule, I added a query in the UI Action for Request Approval button, where I defined as follow:

if (!current.value_certified) {
    gs.addErrorMessage("Please select the check box to certify and acknowledge that the information provided by you is accurate.");
    action.setAbortAction(true); // Stop the action from continuing
} else {
    current.setValue('state', 3);
    current.update();
    action.setRedirectURL(current); // Redirect to the same form
}