The M-Files Community will be updated on Tuesday, April 2, 2024 at 10:00 AM EST / 2:00 PM GMT and the update is expected to last for several hours. The site will be unavailable during this time.

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

Validating a value list entry

Hello helpful community 
Good day to you :) 

I have faced an error that i don't exactly know how to solve it, if anyone would give me a tip I would be very thankful :) 

I have here a class called "Progress notes" This class has multiple properties. the important once are [Entry Type, Late Entry days, Late Entry reason]



Now, the late entry date is getting calculated automatically using this code:

Dim oCreatedUtc : oCreatedUtc = PropertyValues.SearchForProperty(20).TypedValue.Value
Dim oEnteredUtc : oEnteredUtc = PropertyValues.SearchForProperty(1071).TypedValue.Value
Output = DateDiff("d",oEnteredUtc,oCreatedUtc)


Now, what i wanted to do as well is to make the "Entry Type" be "Late Entry" if the "Late Entry Days" is bigger than one.

So, if the user put "Addendum" I will throw an error and prevent him from saving the changes.

Thus, i tried to add this code in the "Entry Type" property as a validation:

Dim PropertyValues : Set PropertyValues = Vault.ObjectPropertyOperations.GetProperties(ObjVer)
Dim dayscount : dayscount = PropertyValues.SearchForProperty(4868).TypedValue.Value
'Dim EntryType : EntryType = PropertyValues.SearchForProperty(5510).TypedValue.Value

if dayscount > 0 and (PropertyValue.TypedValue.DisplayValue) <> "Late Entry" Then
	Err.Raise mfscriptcancel , "Entry Type must be "Late Entry Type" " & vbCrLf & "Please change the Entry Type to save the process"
end if

But i keep getting this error:



Note that this code worked when i applied it to the property "Late Entry Reason" where i put this code as validation and it works:

Dim PropertyValues : Set PropertyValues = Vault.ObjectPropertyOperations.GetProperties(ObjVer)
Dim oCreatedUtc : oCreatedUtc = PropertyValues.SearchForProperty(20).TypedValue.Value
Dim oEnteredUtc : oEnteredUtc = PropertyValues.SearchForProperty(1071).TypedValue.Value

if DateDiff("d",oEnteredUtc,oCreatedUtc) > 0 and Len(PropertyValue.TypedValue.DisplayValue) < 20 then
	Err.Raise mfscriptcancel , "You need to provide reason for late entry! " & vbCrLf & "Reason for Late Entry should have minimum of 20 characters."
end if


But why it is not working the same way in "Entry Type"? Am I missing something somewhere? Is it because Entry type is a list not a normal text?


Thank you in advance for your efforts and response :)