Block Business Rule from UI Action Workspace Client Script

Abhijit Das7
Tera Expert

Rephrased Version:

Hi Everyone,

We have a specific field on the Work Order form, along with a UI Action (Ready for Dispatch) and a Before Update Business Rule.

Currently, whenever a user enters a value in this field and clicks Save, the Business Rule validates the field value. If the value is valid, the record is saved; otherwise, the Business Rule aborts the save operation.

However, I have observed that the same Before Update Business Rule also executes when a user modifies the field value and clicks the Ready for Dispatch UI Action without saving the form first.

My requirement is:

  • If the field value is changed and the user clicks Save, the Business Rule should execute and perform its validation.
  • If the field value is changed but the user clicks Ready for Dispatch without saving the form, the Business Rule should not execute.

Is there a way to prevent or bypass a specific Business Rule from running when the Ready for Dispatch UI Action is triggered from a Workspace Client Script?

Thanks.


2 REPLIES 2

NagaChandaE
Mega Sage

Hi Abhijit,

Before trying to bypass the Business Rule from the Ready for Dispatch UI Action, I would first check whether the requirement itself is correct.

If the field value is invalid, the Business Rule should stop the save—whether the user clicks Save or Ready for Dispatch. The Ready for Dispatch action also saves the record, so allowing an invalid value only through that button can create data inconsistency.

I would ask the business this question:

“Should the user be allowed to dispatch a Work Order if this field has an invalid value?”

  • If No, then keep the Business Rule running. The current behavior is correct.

  • If Yes, then the Business Rule condition needs to be changed based on the business scenario—for example, only validate the field in certain states or when certain conditions are met.

I would not recommend blocking the Business Rule only for the Ready for Dispatch UI Action. The same record can be updated through Save, list edit, integrations, scripts, or other UI Actions. If you bypass the rule only for one button, invalid data may still enter through another path.

You can add a simple client-side validation in the UI Action to show the user an error before submitting, but that should only improve the user experience. The Business Rule should remain as the server-side validation.

So, instead of bypassing the Business Rule, clarify the actual business requirement and update the Business Rule condition if needed.

If you found this helpful, please mark it as Helpful and Accept as Solution

 

HasanM
Kilo Sage

Hi @Abhijit Das7 

You can do this by setting a session flag in the Ready for Dispatch UI action. The Business Rule skips its validation only when that flag is set.

  1. UI Action (Ready for Dispatch), server script:
try {
    gs.getSession().putClientData('skip_wo_validation', 'true');
    current.update();
} finally {
    gs.getSession().putClientData('skip_wo_validation', '');
}
// rest of your Ready for Dispatch logic
  1. Workspace Client Script on the same UI action:
function onClick(g_form) {
    g_form.submit('ready_for_dispatch'); // your UI action's Action name
}
  1. Before Update Business Rule, add this to the Condition:
gs.getSession().getClientData('skip_wo_validation') != 'true'

How it works:

  • Save: no flag is set, so the Business Rule runs and validates the field as it does now.
  • Ready for Dispatch: the flag is set just before the update, so the Business Rule is skipped.
  • The flag is cleared in the finally block, even if the update fails, so the next normal save is validated again.

Avoid current.setWorkflow(false) here. It skips every Business Rule on the update, not just this one.

I tested this on a PDI: a normal save was blocked by the rule, the flagged update went through, and the next normal save was blocked again.

Hope this helps, please mark it as helpful or accept it as the solution.