How can I suspend business processors?

Hi,

I have my business processors all set up and working fine but I’ve now hit a situation where I want to suspend their operation briefly.

Basically I’m making changes to a table server-side via a TDAMemDataTable and I’m using dynamic select to only retrieve the few columns I’m interested in. I then make the necessary changes and apply the updates.

The issue is that this particular table has a business process with server rules associated with it and these rules are automatically being run when the updates are applied.

Unfortunately, because I’m using dynamic select, most of the columns aren’t present so, when my business logic tries to access these columns via the interface, it throws errors all over the place.

How can I temporarily suspend the business processor logic so that it doesn’t run as I don’t want nor need it to in this particular instance?

Thanks.

BusinessProcessor is always used, so you can’t disable it.
Even when it isn’t dropped to the service form, it is created automatically because it contains update for processing changes.

You can empty BusinessRulesID so it won’t use Business Helper Classes.

Can you create a simple testcase that shows your problem, pls?
You can attach it here or send to support@.

Thanks,

Not sure I have the time to create a test case right now I’m afraid although I’ll try to describe it a little better.

The table in question is called “Contacts”. As I said, I’ve created business rules for the table in question, using a TContactsServerRules class derived from the automatically generated TContactsBusinessProcessorRules. This class does various validation and processing and is attached to a business processor component via its BusinessRulesId property.

This is all great and works perfectly fine but what I now need to do is use the same table in another way.

I need to retrieve a large number of records from this table and modify a specific field within each of these records.To that end I’ve created a separate TDAMemDataTable, connected to this table, and on which I’m using dynamic select as I only want to retrieve a few columns for each row for performance reasons.

This is fine, except when I attempt to apply the updates, the business logic in the above class is being executed. This logic is using the strongly typed class properties to access various columns of the table during its processing but of course, as I’ve only retrieved a few specific columns, the remaining columns aren’t present and the indexes of those that are aren’t correct.

All I need is to completely prevent this business logic from running in this case. I understand what you’re saying, i.e. if I remove or disable the TDABusinessProcessor component I’m using then the framework will simply create one automatically for me but are you saying I should simply remove the BusinessRulesID property from my existing business processor and this would then prevent the logic from executing?

yes, you can simply assign empty string to BusinessRulesId. after this, your business logic will be removed.

I just tried this but it seems I can’t remove it after the component has been created as the logic still runs - obviously at this point it’s too late and the class has already been “attached” to the business processor. If I remove it at design time then it works and the logic doesn’t execute.

This does appear to be a limitation of the way the strongly typed classes work. They depend on all columns in the table being present in the data table. If dynamic select is used to limit the columns retrieved then some columns won’t be present at all and the remaining ones won’t have the correct indexes in the strongly typed classes.

That’s not a criticism - I understand why this is the case, it just presents problems when I want to use dynamic select on a table which has such logic assigned to it via the helper classes.

It depends on the event you are using for changing BP properties.
You can use OnBusinessProcessorAutoCreated event and assign your business logic when it is needed.

Aha that’s useful to know. At present I’ve dropped my own BP components on the service module and assigned the BusinessRulesID. Are you saying that, if I don’t need to alter any other properties of these components, then I could just remove them altogether and use this event to assign my rules to the automatically generated ones instead? Would be a little cleaner I guess.

yes, it is one from possible solutions: remove BP and assign required properties in autogenerated version.
other solution: remove assigned BusinessRulesID in OnBeforeProcessDeltas event from existing BP.