This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Automatically Filling a document property from an object's properties

For the past week or so I have been trying to come up with a script to automatically fill the property 'Sums Assured' from the an object named(member) obj id(121)'s property named Total sum Assured ('1097'). The object member has a connection to an external database from which I am picking individual members and it works just fine, however I would like to automatically get the properties that members have automatically filled when I select the specific member from the dropdown list on documents that refer to the member object.

property on document: 
Member property (1117)                                                    Member object id - (121)
sums assured - (ID)1242                                                  Property: total sum assured - ID -(1097)
  • Hi,

    It is really hard to understand your question...
    Since people in community are helping your question voluntarily, you should make effort in describing your questions as clear as possible.

    This is how i see your situation:


    If I'm understanding it correctly, then you can set currently selected Member object's Total Sum assured PropertyValue to Document object's "Sums assured" automatic calculation script like this:


    Const iMember_PD = 1117 ' Property Definition of Member
    Const iExtMemberSum_PD = 1097 'Property definition of "Total Sum assured"

    dim oMember_PV
    set oMember_PV = PropertyValues.SearchForProperty(iMember_PD)

    if not oMember_PV.value.IsNULL() then

    'Get lookup
    dim oMember_Lookup
    set oMember_Lookup = oMember_PV.value.GetValueAsLookup

    'Create ObjID
    dim oObjID: Set oObjID = CreateObject("MFilesAPI.ObjID")
    oObjID.ID = oMember_Lookup.item 'ID for related Member object
    oObjID.Type = oMember_Lookup.ObjectType 'related member ObjType

    'Get Latest version of external object
    dim oMember_ObjVer
    set oMember_ObjVer = vault.ObjectOperations.GetLatestObjVer(oObjID,true)

    'Get "Total Sum assured" Property value of external object
    dim oExtMemberSum_PV
    set oExtMemberSum_PV = Vault.ObjectPropertyOperations.GetProperty(oMember_ObjVer, iExtMemberSum_PD)

    'Set found value as output
    Output = oExtMemberSum_PV.value.Value
    end if


    Script above uses Document object's Member property Lookup value to find the latest ObjVer of selected Member object. Then we can use found ObjVer to retrieve PropertyValue of Total Sum assured and output it's property value.