Hi all,
I am currently creating a script to get the properties from the object class found in the a loop. Kindly find my code below.
What i have achieved is looping through a document and found Assignment relationship in the document. And then i looped through the Assignment to find the assignment class with ID 62. Next i wanted to get the properties from the assignment class ID 62 and copy into the document. I could not find the correct code to get the properties from the assignment class ID 62 (the one highlighted in red). Anyone has any idea do let me know. Thanks
Dim related : Set related = Vault.ObjectOperations.GetRelationships(objVer,MFRelationshipsModeAll)
Dim obj : Set obj = CreateObject("MFilesAPI.ObjVer")
For Each obj in related.GetAsObjVers
If obj.type = 10 Then 'object type of assignment
Dim oLookup : Set oLookup = CreateObject("MFilesAPI.ObjVer")
For Each oLookup in Vault.ObjectPropertyOperations.GetProperty(obj,100).TypedValue.GetValueAsLookups
Dim CurrentClass_DefID : CurrentClass_DefID = Vault.ObjectPropertyOperations.GetProperty( obj,100).Value.GetLookupID()
If (CurrentClass_DefID = 62) Then 'the desired assignment class
dim ExternalDocumentPV: set ExternalDocumentPV = PropertyValues.SearchForProperty( 1017 )
dim Lookup: set Lookup = ExternalDocumentPV.value.GetValueAsLookups().Item(1)
dim ExternalDocumentObjID : Set ExternalDocumentObjID = CreateObject("MFilesAPI.ObjID")
ExternalDocumentObjID.SetIDs Lookup.ObjectType, Lookup.item
'Get "External Document" object's version and properties
dim ExternalDocumentVersionAndProps
set ExternalDocumentVersionAndProps = vault.ObjectOperations.GetLatestObjectVersionAndProperties(ExternalDocumentObjID,true)
'Search for property that has "Tender Name","Tender Ref. No.","Client/Consultant" alias from External Documents metadata card
dim Test_test, STATUS_COMPLETED
set Test_test = ExternalDocumentVersionAndProps.Properties.SearchForPropertyEx(MFilesAPI.MFBuiltInPropertyDef.MFBuiltInPropertyDefLastModifiedBy, False)
set STATUS_COMPLETED = ExternalDocumentVersionAndProps.Properties.SearchForPropertyEx(MFilesAPI.MFBuiltInPropertyDef.MFBuiltInPropertyDefStatusChanged, False)
Dim AM
AM = PropertyValues.SearchForProperty(1189).TypedValue.GetValueAsUnlocalizedText()
if Test_test.Value.GetValueAsUnlocalizedText() = AM then
'err.raise mfscriptcancel, "Sama"
Dim oPropVals : Set oPropVals = CreateObject ("MFilesAPI.PropertyValues")
Dim oPropVal : Set oPropVal = CreateObject ("MFilesAPI.PropertyValue")
oPropVal.PropertyDef = 1638 'The ID your date property.
Dim dDate : dDate = STATUS_COMPLETED ' or use something like: 'Format(Date,"dd-mm-yyyy")' or any calculation you like on www.w3schools.com/.../func_formatdatetime.asp
oPropval.TypedValue.SetValue MFDatatypeDate, dDate
oPropVals.Add -1, oPropVal
Call Vault.ObjectPropertyOperations.SetProperties( ObjVer, oPropVals )
else
err.raise mfscriptcancel, "tak Sama"
end if
end if
Next
End if
Next