RE: When is OnCurrentSaleSaved called in a VBscript?
How are you removing the link?
From the GUI or via one of your scripts?
1. From the GUI:
Can you reproduce it when scripting events are turned off?
If so, we are back to your other post. I could not reproduce that and I had some questions related to it.
If this is a real bug, then it needs fixing first. I will look into it if I can somehow figure out how to reprocude it!
2. From within one of your scripts:
If you are removing a link from within the OnCurrentSaleSaved event, then it is a different game.
(I suggest you look into doing this in the OnCurrentSaleBeforeSave event instead, but all using our own API!)
As a rule, *Save* events are called when all related data of the underlying entity is saved.
However, the partner entity of an activity link that needs updating, like in your case, the project.activeLinks fields is not part of this.
One could argue that it should be. But the potential issues with nested Save calls and COM are huge and very hard to handle so this is in fact delayed until the application is idle. From your script p.o.v, as long as you have control, anything can happen in between. But again, as long as you use the application's API, we will have a fair chance of seeing consistent resident data.
Note also in this event log, I have added a project link to the current sale:
2: 15:35:32:404 OnCurrentSaleBeforeSave (1)
3: 15:35:33:517 OnSaleFieldsChanged (1) [VT_BSTR] SaveModel, [VT_UI4]76, [VT_BSTR] UPDATED, [VT_INT]3357
4: 15:35:33:522 OnCurrentSaleFieldChanged (1) [VT_BSTR] sale.UPDATED
5: 15:35:33:536 OnCurrentSaleSaved (1)
6: 15:35:33:672 OnProjectFieldsChanged (1) [VT_BSTR] SetNumberOfLinks, [VT_UI4]76, [VT_BSTR] ACTIVELINKS, [VT_INT]2835
7: 15:35:34:494 OnProjectFieldsChanged (1) [VT_BSTR] SaveModel, [VT_UI4]76, [VT_BSTR] UPDATED, [VT_INT]2825
8: ....
9: 15:35:35:749 OnEditSaleComplete (1)
No OnCurrentProjectSaved but a OnProjectFieldsChanged with SaveModel action. This is because adding this link did not cause the current project to change. The partner project's activeLinks got updated, but it is not current. You's need the so called "New" messages to get this. I reckon New is now well over 10 years old :-)
If you add links to various Appnt, Doc, Proj and Sale, all will get their activeLinks fields updated in due time. This is normaly as soon as the application goes into Idle. Definately after your script has returned to us.
/conrad