Pocessing a BO in AfterSave event


Author
Message
Ger Cannoll
Ger Cannoll
Advanced StrataFrame User (628 reputation)Advanced StrataFrame User (628 reputation)Advanced StrataFrame User (628 reputation)Advanced StrataFrame User (628 reputation)Advanced StrataFrame User (628 reputation)Advanced StrataFrame User (628 reputation)Advanced StrataFrame User (628 reputation)Advanced StrataFrame User (628 reputation)Advanced StrataFrame User (628 reputation)
Group: StrataFrame Users
Posts: 430, Visits: 507
Afte I save a BO, I need to do additional processing of the BO, updating some other tables and logging before and after data.

It would apear that the 'AfterSave' event is probably the best place to do this, but I cannot access rows marked for deletion.

I can copy the BO in the BeforeSave event (and then process it in the AfterSave Event) , but am having difficulty processing Deleted Records , as I cannot see them in the BO ( I have the OnlymarkAsDeleted option set when Deleting rows so they are not removed from the Database until I save) . Also when this flag is set, the AfterDeleteEvent still fires , even though the row will not have been physically removed from the Database table yet.

Any ideas appreciated
Ivan George Borges
Ivan George Borges
Strategic Support Team Member (3.4K reputation)Strategic Support Team Member (3.4K reputation)Strategic Support Team Member (3.4K reputation)Strategic Support Team Member (3.4K reputation)Strategic Support Team Member (3.4K reputation)Strategic Support Team Member (3.4K reputation)Strategic Support Team Member (3.4K reputation)Strategic Support Team Member (3.4K reputation)Strategic Support Team Member (3.4K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
Hi Gerard.

It looks like even though you are giving an OnlyMarkAsDeleted value, the record will be deleted from the BO's internal data table. From the Help file:

DeleteCurrentRow(OnlyMarkAsDeleted) - When OnlyMarkAsDeleted is given a value of True, the current row is deleted within the internal data table only and a Save() must be executed before the changes are reflected back to the server. This is recommended when deleting a large number of records.

As for the AfterDelete, it looks like the Delete event occurs, even if it is only marked for such, and the AfterDelete should then be triggered.


Ger Cannoll
Ger Cannoll
Advanced StrataFrame User (628 reputation)Advanced StrataFrame User (628 reputation)Advanced StrataFrame User (628 reputation)Advanced StrataFrame User (628 reputation)Advanced StrataFrame User (628 reputation)Advanced StrataFrame User (628 reputation)Advanced StrataFrame User (628 reputation)Advanced StrataFrame User (628 reputation)Advanced StrataFrame User (628 reputation)
Group: StrataFrame Users
Posts: 430, Visits: 507
Hi Ivan. Thanks for replying.

So how would I have access to the rows that are eventually  deleted from the database , in that they dont seem to be accessible from the Business Object. I need some way of accessing a row if it is 'actually'  deleted from the database. The AfterDelete event is not enough as it could be 'Undone'
Ivan George Borges
Ivan George Borges
Strategic Support Team Member (3.4K reputation)Strategic Support Team Member (3.4K reputation)Strategic Support Team Member (3.4K reputation)Strategic Support Team Member (3.4K reputation)Strategic Support Team Member (3.4K reputation)Strategic Support Team Member (3.4K reputation)Strategic Support Team Member (3.4K reputation)Strategic Support Team Member (3.4K reputation)Strategic Support Team Member (3.4K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
Not sure, but if you need some custom action on deleting, maybe you could hide the Delete button from the SF toolbar and add your own. Then you could do whatever you need, even create a boolean flag on your table for Deleted, set this flag as true when the user pressed your Delete button and deal with whatever you want to do in the AfterSave, definetely deleting the rows and taking the actions you need.
Ger Cannoll
Ger Cannoll
Advanced StrataFrame User (628 reputation)Advanced StrataFrame User (628 reputation)Advanced StrataFrame User (628 reputation)Advanced StrataFrame User (628 reputation)Advanced StrataFrame User (628 reputation)Advanced StrataFrame User (628 reputation)Advanced StrataFrame User (628 reputation)Advanced StrataFrame User (628 reputation)Advanced StrataFrame User (628 reputation)
Group: StrataFrame Users
Posts: 430, Visits: 507
Hi Ivan.

I cannot see anyway within the BusinessObject to trap a Delete when I have the OnlyMarkAsDelted flag set . How do users capture Audit Type data where you would want to write away Deleted records to an Audit table ?

As there does not seem to be a way within the Business Object to do what I want to do, I have been looking at processing the raw dataTable behind the Business Object . This seems to have all the Rows in it , even deleted ones which will be marked as deleted. My thoughts are as follows:

1. On the BeforesaveEvent, Copy the CurrentDatatable to a 'BeforeSave' table
2. Let SF Save the BO as normal
3. In the AfterSave event, do some Post Processing on the 'Beforesave' table


 This seems like a lot of work, and if there is another way of doing this with Business Objects, maybe somebody could jump in. If anybody has inserted auditing type functionality, it looks like they would already have done this sort of thing.
Ivan George Borges
Ivan George Borges
Strategic Support Team Member (3.4K reputation)Strategic Support Team Member (3.4K reputation)Strategic Support Team Member (3.4K reputation)Strategic Support Team Member (3.4K reputation)Strategic Support Team Member (3.4K reputation)Strategic Support Team Member (3.4K reputation)Strategic Support Team Member (3.4K reputation)Strategic Support Team Member (3.4K reputation)Strategic Support Team Member (3.4K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
I cannot see anyway within the BusinessObject to trap a Delete when I have the OnlyMarkAsDelted flag set . How do users capture Audit Type data where you would want to write away Deleted records to an Audit table ?


What about using the BeforeDelete, throwing your own Delete Confirmation message, if Delete was confirmed, you would have the record standing right there for you to do whatever.
Ger Cannoll
Ger Cannoll
Advanced StrataFrame User (628 reputation)Advanced StrataFrame User (628 reputation)Advanced StrataFrame User (628 reputation)Advanced StrataFrame User (628 reputation)Advanced StrataFrame User (628 reputation)Advanced StrataFrame User (628 reputation)Advanced StrataFrame User (628 reputation)Advanced StrataFrame User (628 reputation)Advanced StrataFrame User (628 reputation)
Group: StrataFrame Users
Posts: 430, Visits: 507
Hi Ivan

Even if I do this, because I have the OnlyMarkAsDeleted set, the record is deletd from the BO (but not from the Database Table yet), but the user can Undo changes, which means the Deleted record is Undeleted. Still back to the situation where I cant , or dont want to anyway, do anything until the Backend Database tables have been updated.

I suppose ideally what I am looking for is the Business Object  (or some version of  it ) just prior to the database Update which has both the New,Modified and deleted rows in it).

I would have thought that anybody who is logging Audit type stuff must have already done this ?
Ivan George Borges
Ivan George Borges
Strategic Support Team Member (3.4K reputation)Strategic Support Team Member (3.4K reputation)Strategic Support Team Member (3.4K reputation)Strategic Support Team Member (3.4K reputation)Strategic Support Team Member (3.4K reputation)Strategic Support Team Member (3.4K reputation)Strategic Support Team Member (3.4K reputation)Strategic Support Team Member (3.4K reputation)Strategic Support Team Member (3.4K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
Yeah, I haven't tried OnlyMarkAsDeleted on a maintenance form. I did it when programmatically deleting many records.

The way I would go would be, as I said, to use the BeforeDelete, get that record on a temp BO and deal with it AfterSave. In the case of an Undo, nothing would have to be done.

But I guess someone else who has approached this in a different maner might jump in and give you some other ideas.

Cheers.
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search