- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have a Vault Add-on the lookups up the current part description from an ERP system and updates the part's description property.
The function is based on the example from justonesandzeros.
http://justonesandzeros.typepad.com/blog/2015/02/another-way-to-update-properties.html
The code has been recently updated from Vault 2022 to 2024.
CheckIn:
File newFile = mgr.DocumentService.CheckinUploadedFile(
selectedFile.MasterId, "Update from PAI JCS: " + UpdateMessage, false, DateTime.Now,
GetFileAssociations(selectedFile, connection), null, true, selectedFile.Name, selectedFile.FileClass,
selectedFile.Hidden, uploadTicket.ToByteArray());
Using the following for file associations.
/// <summary>
/// Return list of file associations for given file.
/// http://adndevblog.typepad.com/manufacturing/2013/09/vault-2014-api-example-that-adds-a-file-and-asso...
/// </summary>
/// <param name="selectedFile">Selected file.</param>
/// <param name="connection">Current Vault Connection.</param>
/// <returns>Array of file association paramiters</returns>
private FileAssocParam[] GetFileAssociations(File selectedFile, VDF.Vault.Currency.Connections.Connection connection)
{
// Settings used in GetFileAssociationLites()
VDF.Vault.Settings.FileRelationshipGatheringSettings myFileRelationshipSettings = new VDF.Vault.Settings.FileRelationshipGatheringSettings();
myFileRelationshipSettings.IncludeAttachments = true;
myFileRelationshipSettings.IncludeChildren = true;
myFileRelationshipSettings.IncludeParents = true;
myFileRelationshipSettings.IncludeRelatedDocumentation = true;
// added to get DWF references
myFileRelationshipSettings.IncludeHiddenEntities = true;
myFileRelationshipSettings.IncludeLibraryContents = true;
// Current associations for file
System.Collections.Generic.IEnumerable<FileAssocLite> myColOfFileAssocLite =
connection.FileManager.GetFileAssociationLites(selectedFile.Id.ToSingleArray(), myFileRelationshipSettings);
// Go though each FileAssocLite to add to list
List<FileAssocParam> fileAssocParams = new List<FileAssocParam>();
if (myColOfFileAssocLite != null)
{
foreach (FileAssocLite myFileAssocLite in myColOfFileAssocLite)
{
// skip self dependency
if (!(myFileAssocLite.Typ == AssociationType.Dependency &&
myFileAssocLite.CldFileId == selectedFile.Id))
{
FileAssocParam par = new FileAssocParam();
par.CldFileId = myFileAssocLite.CldFileId;
par.RefId = myFileAssocLite.RefId;
par.Source = myFileAssocLite.Source;
par.Typ = myFileAssocLite.Typ;
par.ExpectedVaultPath = myFileAssocLite.ExpectedVaultPath;
fileAssocParams.Add(par);
}
}
}
return fileAssocParams.ToArray();
}
Should I set IncludeChildren to false if the file is a part?
Solved! Go to Solution.