Business rule vs scheduled job

ryadavalli
Tera Expert

We have a requirement to update a flag x on the user record depending on the value on another field y.

We have 3 options:

1) Write a after BR which executes when the record is updated or inserted and update the flag x depending on y flag - Will get called with every update

2) Scheduled job (nightly) which will run right after the the user records are transformed and get all the records where field y is changed and set the flag x.

3) Write an on After transform script - This might delay the transform

Performance wise which one is better, thoughts ?

Thanks,

1 ACCEPTED SOLUTION

What you propose is perfectly do-able in the transform map script. You don't need an additional business rule. That's just overhead that can slow down your import.



target.x is available because it's part of sys_user. source.x is what came in from the import.



if (source.x == '1' || source.x == '2' || source.x == '3') {


        target.y = true;


} else {


        target.y = false;


}



Something like that sounds like a simple approach to what you described. Just make sure "Y" isn't in the field mapping.


View solution in original post

17 REPLIES 17

Chuck Tomasi
Tera Patron

The question is WHEN do you want to it to run? If you put it in a BR, it will only affect the records that are created/updated as they are done. Older records may never get updated.



The scheduled job can do a complete sweep of everything - which you may only need periodically, but some records could be out of date.



I recommend a two pronged approach to get older records up to date using a scheduled job (or fix script) that runs once and use a BR to keep values up to date going forward.


We want to go about only the record inserted/updated going forward. For that, is a BR would be effective or a scheduled job on a daily basis which will look for all the updated one for that day and set the flag to true if the field y is changed to certain value ?


With BR, every user record will be checked for the condition of the BR, but if it is a scheduled job, it will run one time and get the result set and will work on it, thats the question I have here.


Thanks,


Rayali,



You can create a business rule which triggers only when Field y is changed. That would be a better solution in this scenario.