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 :) 

Parents
  • Okaaay gentlemen... quick update... I fixed the previous error.. but i got another one. Not actually an error... just misplaced warning text

    First the error was that i put a quotation marks in the error message. Just removed that and it worked (Feels embarrassed haha)

    And the second part is that:
    I managed to get the output i want.. But only when i change the state of the object.


    I want this message to appear in the very first time the user creates this object. But i think it is not possible because the "Late Entry Days" is an automatic value and it will not be generated before saving the object for the first time, right?

    Then, this leaves me with the thought that i am putting the code in the wrong place. Currently it is in validation tab of the property "Entry Type" ..

    Soooo, any ideas or tips on how to get this message before we save the object for the first time?

    Thank you

Reply
  • Okaaay gentlemen... quick update... I fixed the previous error.. but i got another one. Not actually an error... just misplaced warning text

    First the error was that i put a quotation marks in the error message. Just removed that and it worked (Feels embarrassed haha)

    And the second part is that:
    I managed to get the output i want.. But only when i change the state of the object.


    I want this message to appear in the very first time the user creates this object. But i think it is not possible because the "Late Entry Days" is an automatic value and it will not be generated before saving the object for the first time, right?

    Then, this leaves me with the thought that i am putting the code in the wrong place. Currently it is in validation tab of the property "Entry Type" ..

    Soooo, any ideas or tips on how to get this message before we save the object for the first time?

    Thank you

Children
No Data