setabortaction

adilalee
Tera Contributor

adilalee_0-1764700546163.png

adilalee_1-1764700565040.pngadilalee_2-1764700580026.png

this is not working i want when model is end of life then abortaction is true

 

5 REPLIES 5

Brad Bowman
Kilo Patron
Kilo Patron

What are the settings on the When to run tab?  Do you see the error message?

No i can't see error msg and abortaction also doesnot work

 

 

VaishnaviK43271
Tera Contributor

 

  1. The "End of Life" value is on the Model table (cmdb_hardware_product_model), in the field u_test.

  2. Your Business Rule is on the Hardware table (alm_hardware).

  3. The Hardware table references the Model with the field model.

So to check the u_test field on the Model record, you need to get the reference record from the model field like this:

(function executeRule(current, previous) {
    var modelRec = current.model.getRefRecord(); // get the full model record
    if (modelRec.u_test == 'End of Life') {
        gs.addErrorMessage('Model life is ended. Please choose another.');
        current.setAbortAction(true);
    }
})(current, previous);

Additional checklist:

  1. "When to run" must be Before Insert or Before Update on your Business Rule.

  2. Ensure the Business Rule is Active.

  3. Test with changing the model to a product model where u_test is "End of Life" to confirm the abort action happens.

 

Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for.

Thank You

 

YES i follow these guide lines but it doesnot work first i cannot saw error message 2nd setabortaction also doesnot work