Suggessted Value

Hello community,

I deal with this - can I aviche this scenario? I have a property "Number" (int) wich is used in diffrent classes. I want to autmaticlly sugesst new number ( fo new documents)  within class and year from "Date" property. Is there any cofnig from PropertyCalculator/Advanced Value Settings  wich can handle that ?

Parents
  • Thanks sweise, but my config is that. After Evet "AfterSetProperties"

    Dim PropertyDefData: PropertyDefData = 1002        
    Dim PropertyDefNumer: PropertyDefNumer = 1230    
    
    if PropertyValues.SearchForProperty(100).TypedValue.GetValueAsLookup.Item = 129 or PropertyValues.SearchForProperty(100).TypedValue.GetValueAsLookup.Item = 130 then 
    	Dim MyDocumentClassID: MyDocumentClassID = PropertyValues.SearchForProperty(100).TypedValue.GetValueAsLookup.Item  
    
        if Not IsNumeric(PropertyValues.SearchForProperty(PropertyDefNumer).TypedValue.DisplayValue) Then
    		if PropertyValues.SearchForProperty(PropertyDefData).TypedValue.DisplayValue <> "1900-01-01" Then
    		
    			Dim yearToCheck: yearToCheck = Year(PropertyValues.SearchForProperty(PropertyDefData).TypedValue.DisplayValue)
    			Dim startDate: startDate = CDate(yearToCheck & "-01-01")
    			Dim endDate: endDate = CDate(yearToCheck & "-12-31")
    		
    			Set searchConditions = CreateObject("MFilesAPI.SearchConditions")
    			
    			Set conditionClass = CreateObject("MFilesAPI.SearchCondition")
    			With conditionClass
    			    .ConditionType = MFConditionTypeEqual
    			    .Expression.DataPropertyValuePropertyDef = 100
    			    .TypedValue.SetValue MFDatatypeLookup, MyDocumentClassID
    			End With
    			searchConditions.Add -1, conditionClass
    			
    
    			Set conditionDateFrom = CreateObject("MFilesAPI.SearchCondition")
    			With conditionDateFrom
    			    .ConditionType =  MFConditionType.MFConditionTypeGreaterThanOrEqual
    			    .Expression.DataPropertyValuePropertyDef = PropertyDefData
    			    .TypedValue.SetValue 5, startDate ' MFDatatypeDate
    			End With
    			searchConditions.Add -1, conditionDateFrom
    			
    
    			Set conditionDateTo = CreateObject("MFilesAPI.SearchCondition")
    			With conditionDateTo
    			    .ConditionType =  MFConditionType.MFConditionTypeLessThanOrEqual
    			    .Expression.DataPropertyValuePropertyDef = PropertyDefData
    			    .TypedValue.SetValue 5, endDate
    			End With
    			searchConditions.Add -1, conditionDateTo
    			
    			Set results = vault.ObjectSearchOperations.SearchForObjectsByConditions(searchConditions, 0, False)
    			
    			Dim countNumber: countNumber = results.Count 
    		
    		    Dim thisProperty : Set thisProperty = PropertyValues.SearchForProperty(PropertyDefNumer)
    		    thisProperty.TypedValue.SetValue MFDatatypeInteger, countNumber
    		    Dim oNullVer : Set oNullVer = Vault.ObjectPropertyOperations.SetProperty( ObjVer, thisProperty )
    		
    		End if
    	End if
    End If

    I make a copy of the last item with the Compliance Kit, clear the number, and set the date to 1900-01-01 because I have another property that generates the identification number. When I change and save the date, the number is then set.

    It may not be the most optimal solution, but it works.

Reply
  • Thanks sweise, but my config is that. After Evet "AfterSetProperties"

    Dim PropertyDefData: PropertyDefData = 1002        
    Dim PropertyDefNumer: PropertyDefNumer = 1230    
    
    if PropertyValues.SearchForProperty(100).TypedValue.GetValueAsLookup.Item = 129 or PropertyValues.SearchForProperty(100).TypedValue.GetValueAsLookup.Item = 130 then 
    	Dim MyDocumentClassID: MyDocumentClassID = PropertyValues.SearchForProperty(100).TypedValue.GetValueAsLookup.Item  
    
        if Not IsNumeric(PropertyValues.SearchForProperty(PropertyDefNumer).TypedValue.DisplayValue) Then
    		if PropertyValues.SearchForProperty(PropertyDefData).TypedValue.DisplayValue <> "1900-01-01" Then
    		
    			Dim yearToCheck: yearToCheck = Year(PropertyValues.SearchForProperty(PropertyDefData).TypedValue.DisplayValue)
    			Dim startDate: startDate = CDate(yearToCheck & "-01-01")
    			Dim endDate: endDate = CDate(yearToCheck & "-12-31")
    		
    			Set searchConditions = CreateObject("MFilesAPI.SearchConditions")
    			
    			Set conditionClass = CreateObject("MFilesAPI.SearchCondition")
    			With conditionClass
    			    .ConditionType = MFConditionTypeEqual
    			    .Expression.DataPropertyValuePropertyDef = 100
    			    .TypedValue.SetValue MFDatatypeLookup, MyDocumentClassID
    			End With
    			searchConditions.Add -1, conditionClass
    			
    
    			Set conditionDateFrom = CreateObject("MFilesAPI.SearchCondition")
    			With conditionDateFrom
    			    .ConditionType =  MFConditionType.MFConditionTypeGreaterThanOrEqual
    			    .Expression.DataPropertyValuePropertyDef = PropertyDefData
    			    .TypedValue.SetValue 5, startDate ' MFDatatypeDate
    			End With
    			searchConditions.Add -1, conditionDateFrom
    			
    
    			Set conditionDateTo = CreateObject("MFilesAPI.SearchCondition")
    			With conditionDateTo
    			    .ConditionType =  MFConditionType.MFConditionTypeLessThanOrEqual
    			    .Expression.DataPropertyValuePropertyDef = PropertyDefData
    			    .TypedValue.SetValue 5, endDate
    			End With
    			searchConditions.Add -1, conditionDateTo
    			
    			Set results = vault.ObjectSearchOperations.SearchForObjectsByConditions(searchConditions, 0, False)
    			
    			Dim countNumber: countNumber = results.Count 
    		
    		    Dim thisProperty : Set thisProperty = PropertyValues.SearchForProperty(PropertyDefNumer)
    		    thisProperty.TypedValue.SetValue MFDatatypeInteger, countNumber
    		    Dim oNullVer : Set oNullVer = Vault.ObjectPropertyOperations.SetProperty( ObjVer, thisProperty )
    		
    		End if
    	End if
    End If

    I make a copy of the last item with the Compliance Kit, clear the number, and set the date to 1900-01-01 because I have another property that generates the identification number. When I change and save the date, the number is then set.

    It may not be the most optimal solution, but it works.

Children
No Data