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

2 If VBScript

I need some help with my script.

My script should be checking 2 properties

If PropVal is not "Self" the other value (Contact) should be Null or empty.

Option Explicit

Dim szPropertyName, szPropVal
szPropertyName = PropertyDef.Name
szPropVal = PropertyValue.GetValueAsUnlocalizedText


If not szPropVal = "Self" then
Dim szContactVal : szContactVal = PropertyValues.SearchForProperty(1257).TypedValue.DisplayValue

If szContactVal <> "Self" Then
Err.Raise MFScriptCancel, "ContactVal should be empty."

End if
End if

Thank you.

Parents
  • Hi eihr0921,
    I have a question so that we can give you a proper solution.

    What data type is the property definition that holds the value of "Self"?

    If this is a list, you could use the metadata card configuration to hide the Contact property definition is the "Self" item is selected; assuming you are on a current version of M-Files. This would remove the need for scripting. 

    If it is text-based, then you would place a validation script in the Contact property definition; which I can help you create the script.

    -Sean

Reply
  • Hi eihr0921,
    I have a question so that we can give you a proper solution.

    What data type is the property definition that holds the value of "Self"?

    If this is a list, you could use the metadata card configuration to hide the Contact property definition is the "Self" item is selected; assuming you are on a current version of M-Files. This would remove the need for scripting. 

    If it is text-based, then you would place a validation script in the Contact property definition; which I can help you create the script.

    -Sean

Children
  • Actually i can do it on the configuration, but unfortunately this properties are implemented long enough that might affect old documents. I mistyped my validation script, but you're right it will be text-based or string. Here is the example below.

    If the user selected the a value that is not "Self" on Property1, then Property2 should be empty. 

    But this only applies if Property1 has a value. 

    Option Explicit

    Dim szPropertyName, szPropertyval1
    szPropertyName = PropertyDef.Name
    szPropertyval1 = PropertyValue.GetValueAsUnlocalizedText


    If not szPropertyval1  = "Self" then
    Dim szPropertyval2 : szPropertyval2 = PropertyValues.SearchForProperty(1257).TypedValue.DisplayValue

    If isNull (szPropertyval2) = False Then
    Err.Raise MFScriptCancel, "szPropertyval2 should be empty."

    End if
    End if

    Thank you in advance.