New to PDM API, and am working on a add-in to create custom references to legacy data. Everything seems to be working well, but I want to make the process a little quicker/fluid. Is there a way to prevent the dialog boxes from showing when a file has a newly created a reference?
image.png
Can I assume you are checking in from the API? Or does the user initiate the check in then you have an add-in with a hook on before check in that does the custom refs?
The IEdmFile5::UnlockFile() function takes an options flag value. I haven’t used this one specifically so I’m not sure which one you want to use. The times I’ve used flags the jargon is foreign to me so it’s a bit of trial and error mixed with web searches on the terms to see what others have done.
hope that’s more help than hindrance.
Edit: Sorry, I misunderstood. I thought it was the Reference File Dialog from the check in that was showing up. After a second look at the image I realized its the add custom ref that’s showing the RFD. Can you share what code you have? Just looking at the example in the help, I’m wondering if you can try commenting out the .ShowDlg() call, wouldn’t need the CreateTree then which is a requisite to ShowDlg(). Not sure this will work though, IIRC I’ve ran into situations where the next action fails if the ShowDlg is not called.
//Add the file that is copied to the clipboard as a custom reference to the selected file
foreach (int ID in ppoFileIdArray)
{
addCustRefs.AddReferencesClipboard(ID);
addCustRefs.CreateTree((int)EdmCreateReferenceFlags.Ecrf_Nothing);
addCustRefs.ShowDlg(this.Handle.ToInt32());
retCode = addCustRefs.CreateReferences();
}
Maybe this will help you. https://github.com/erppdm/SWPAW/tree/master/AHK/MoreExamples/Demo09
Thanks for the quick response, Ben. I’m mimicking the portion of this example that adds the custom references.
I’ll fiddle with some dialogs and let you know!
Thanks for this resource. I will give it a look! Looks a bit different than mine.
IEdmAddCustomRefs addCustRefs = (IEdmAddCustomRefs)vault.CreateUtility(EdmUtility.EdmUtil_AddCustomRefs);
Int32[] ppoFileIdArray = new Int32[parentFilePaths.Count];
IEdmFile5 file = null;
IEdmFolder5 parentFolder = null;
int i = 0;
foreach (string FileName in parentFilePaths)
{
file = vault.GetFileFromPath(FileName, out parentFolder);
if (!file.IsLocked)
{
file.LockFile(parentFolder.ID, poCmd.mlParentWnd, (int)EdmLockFlag.EdmLock_Simple);
}
ppoFileIdArray[i] = file.ID;
i++;
}
Boolean retCode = false;
//Add the file that is copied to the clipboard as a custom reference to the selected file
foreach (int ID in ppoFileIdArray)
{
addCustRefs.AddReferencesClipboard(ID);
addCustRefs.CreateTree((int)EdmCreateReferenceFlags.Ecrf_Nothing);
//addCustRefs.ShowDlg(poCmd.mlParentWnd);
retCode = addCustRefs.CreateReferences();
}
// Check in the file
file.UnlockFile(poCmd.mlParentWnd, "Custom reference added");
Feeling a bit silly. My code literally tells me what it’s doing, and I just glazed over it.
Commented the two dialogs and now they don’t show. Maybe I should take a break from debugging…
//Add the file that is copied to the clipboard as a custom reference to the selected file
foreach (int ID in ppoFileIdArray)
{
addCustRefs.AddReferencesClipboard(ID);
addCustRefs.CreateTree((int)EdmCreateReferenceFlags.Ecrf_Nothing);
//addCustRefs.ShowDlg(poCmd.mlParentWnd);
retCode = addCustRefs.CreateReferences();
}
// Check in the file
file.UnlockFile(poCmd.mlParentWnd, "Custom reference added");
//Display current custom file references
//retCode = addCustRefs.ShowEditReferencesDlg(ref ppoFileIdArray, poCmd.mlParentWnd);
Thanks again for the suggestion, Ben. Sometimes I have to ask stupid questions to get smart answers.
Marked your suggestion correct as it was the easiest, but I think Ulf’s was an excellent suggestion as well. I just am too lazy to implement a different method.
Those are my lines! Happens more than I want to admit. That’s why I have been told about rubber duck debugging buddy.
LOL. I have not heard of that, but am glad that I now know about it.