Dear programmers
I have the following function, which is part of a script. The script runs on an object called "Client". The function of the script is to create other objects, called "process" every time, a date in the property "PD.EndeGJ" is reached.
The below function should extract the year (yyyy) of the property PD.EndeGJ and evaluate the correct value from the value list property "PD.Jahr".
Then, the script adds a year to the date property "PD.EndeGJ". As a consequence, the script is run one year later again.
Example:
PD.EndeGJ = 31.12.2022
-> object "process" is created and PD.Jahr in this object should be 2023 (extract 2022, add 1 year = 2023)
When copying the vault, the below function does not work anymore, unless I create a new value list and connect the property with the new value list.
It seems as there is a problem evaluating the right value from the value list, maybe because of some internal ID issues.
Function JahrWertelisteID_Ermitteln() Dim ListItemSearchResults Dim JahrID: JahrID = Vault.PropertyDefOperations.GetPropertyDefIDByAlias("PD.Jahr") Dim JahrValueListID: JahrValueListID = Vault.ValueListOperations.GetValueListIDByAlias("VL.Jahr") Dim oExpression: Set oExpression = CreateObject("MFilesAPI.Expression") Dim oSearchCondition: Set oSearchCondition = CreateObject("MFilesAPI.SearchCondition") Dim oSearchConditions: Set oSearchConditions = CreateObject("MFilesAPI.SearchConditions") Dim EndeGJ_ID: EndeGJ_ID = Vault.PropertyDefOperations.GetPropertyDefIDByAlias("PD.EndeGJ") Dim EndeGJ: EndeGJ = PropertyValues.SearchForProperty(EndeGJ_ID).TypedValue.DisplayValue Dim neuesJahr: neuesJahr = YEAR(DateAdd("yyyy", 1, EndeGJ)) 'Das Jahr von (EndeGJ + 1 Jahr) oSearchCondition.ConditionType = MFilesAPI.MFConditionType.MFConditionTypeEqual oSearchCondition.Expression.DataTypedValueValueList = JahrID oExpression.SetValueListItemExpression MFValueListItemPropertyDefName, MFParentChildBehaviorNone, Nothing oSearchCondition.Expression = oExpression oSearchCondition.TypedValue.SetValue MFilesAPI.MFDataType.MFDatatypeText, neuesJahr oSearchConditions.Add -1, oSearchCondition 'Set ListItemSearchResults = Vault.ValueListItemOperations.SearchForValueListItemsEx(JahrValueListID,oSearchConditions) Set ListItemSearchResults = Vault.ValueListItemOperations.SearchForValueListItemsEx(JahrValueListID,oSearchConditions, True, MFExternalDBRefreshTypeNone, True) IF ListItemSearchResults.Count = 1 Then JahrWertelisteID_Ermitteln = ListItemSearchResults.Item(1).ID END IF End Function
I am not a programmer, so maybe one of you guys could help me with this? Maybe the code should be changed somehow, that it works again without creating a seperate new value list every time?
Kind regards,
Dario