Ok I've worked out how to get the variable name for IEdmEnumeratorVariable8::GetVar()
var variable = (IEdmVariable5)Vault.GetObject(EdmObjectType.EdmObject_Variable, control.VariableID);
Answers to my other questions would still be appreciated
Ok, I'll throw you another bone...
Notice what they do with the ppoData array in the OnCmd call, like (but not exactly like) this post.
You basically need to to auto-save the datacard after user is done with the datacard using a similar method.
Check out these card refresh flags...specifically EdmCF_CloseDlgOK
Hope this helps,
Thanks For your input Tim! Are you suggesting that I override the behaviour of the ok button entirely? I think that might complicate things a little too much, and cause the kinds of problems I'm trying to avoid. If only there were an EdmCmdType.EdmCmd_AfterCardButton or something similar.
It would be cool if edmCF_CloseDlgOK was already set to indicate that the save is going to fail, but I guess it's more for me to set if I want to influence the dialog's behaviour. It appears all the validation and error checking will occur after the EdmCmd_CardButton event hook.
I might just stick to manually validating so that I don't do anything like renaming the file if I know the datacard will fail to save. I haven't encountered any errors yet, so it's probably a bit premature to try and handle them.
No, not overriding the beavior of the ok button. Passing back the changed poCmd struct will merely automate pressing the "save changes/ok" button on the datacard. Kinda neat to see it happen. Pretty quick too.
Yes, all error checking will happen after the OnCmd is finished and passed back to EPDM event handler.
If your addin is trying to save the datacard on a file that is not checked out: The user will receive an error to that effect
If your addin checks in the file via the OnCmd command but also passes back an altered poCmd struct with the edmCF_CloseDlgOK then you will receive an error saying the operation failed to save card because the file was not checked out. Here's why:
Order of operations in pseudo code:
- OnCmd fires
- Check file out (file is indeed checked out)
- Do something with its datacard (datacard contents are indeed modified)
- Check file in (file is checked in)
- Modify the poCmd struct passing it the edmCF_CloseDlgOK
- OnCmd exits and passes back the poCmd struct to be evaluated
- poCmd struct is evaluated by EPDM event handler & event handler issues the edmCF_CloseDlgOK (save the datacard contents) command
- ERROR!!! You tried to modify card values for a file not checked out by you. Card cannot be saved because file was checked in...during step 5
This was quite eye opening to understand that's how things happen in addins but it is useful to know
Hope this is valuable,
Thanks for the info. I'm sure I'll be coming back to this in the future
Other than errors, no the card should save if the file is checked out. If the variables are version free, they should save also. I guess it could be a permission blocking the save.
You could also use the cardinput hook.
'Register to receive a notification when a data card variable value changes
You are going down the right path.