Hi Nikolas,
I've done the following:
[ExtensionOf(tableStr(CustTable))]
final class CustTableX_Extension
{
public void insert(DirPartyType _partyType, Name _name,boolean _updateCRM)
{
ttsbegin;
next insert(_partyType, _name, _updateCRM);
CustChangesBusinessEvent::newFromCustTable(this,'insert').send();
ttscommit;
}
public void delete()
{
ttsbegin;
next delete();
CustChangesBusinessEvent::newFromCustTable(this,'delete').send();
ttscommit;
}
public void update(boolean _updateSmmBusRelTable, boolean _updateParty)
{
ttsbegin;
next update(_updateSmmBusRelTable, _updateParty);
CustTable custTableOld = this.orig();
if(custTableOld.Currency != this.Currency ||
custTableOld.PaymTermId != this.PaymTermId ||
custTableOld.TaxGroup != this.TaxGroup ||
custTableOld.name() != this.name() ||
{
CustChangesBusinessEvent::newFromCustTable(this, 'update').send();
}
ttscommit;
}
}
I think i did what u suggested. However,
1. For the delete, you mentioned that i should send the event before the super, but i called it after the super with wrapping it with the transaction and it works
2. As you noticed, I'm using the same business event, But i added a new flag to the contract that specifies the action type. Is this a good practice, or should i build a new event for each action (create/update delete)?
3. Let's say i now want to detect changes for the following
3A: customer primary delivery postal address (Create,update and delete)
3B: customer primary electronics address (create update and delete)
3C: when we create a new contact for the customer , or delete it , or update certain field in it
3D: when we create a new primary electronics address for the customer contact or delete it , or update certain field in it
what would be the best place for each one and should i create a new business event for one of those 4 cases?