Vbscript - Type mismatch

Hi guys

I got a problem  with the following script after copying a vault (full backup) to another server.

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)

In my environment it works, but not in the new one. It always says when triggering the workflow state with the script: type mismatch.

There is a property "Ende GJ" (date) where it should be added 1 year when running the script.

Someone knows why the exact same script doesn't work in the new vault?

Kind regards,

Dario

Parents
  • Here is the whole function of the script. Maybe the problem can also relate to the value list VL.Jahr which contains also deleted values?

    unction 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

  • Hi Dario,

    The detailed error message has information on which line of the script causes the error. This is quite helpful when debugging. Type mismatch often goes back to the variable used in that line. You may have to backtrack and perhaps temporarily insert a line with "Err.Raise MFScriptCancel, <your variable>" to check the content of that variable and compare it to the required input in the line that causes the error.

    In line 11 of the function you use EndeGJ as input. Is EndeGJ a valid date in a format that is recognized by the DateAdd function?

    BR, Karl

Reply
  • Hi Dario,

    The detailed error message has information on which line of the script causes the error. This is quite helpful when debugging. Type mismatch often goes back to the variable used in that line. You may have to backtrack and perhaps temporarily insert a line with "Err.Raise MFScriptCancel, <your variable>" to check the content of that variable and compare it to the required input in the line that causes the error.

    In line 11 of the function you use EndeGJ as input. Is EndeGJ a valid date in a format that is recognized by the DateAdd function?

    BR, Karl

Children
No Data