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

VBS code to get the value of a value list as cases

Hello Everyone

I was wondering is there a code where i can convert the option of the list into a number using VBS code?

For example i have this list:: 5 options. and i want each option to get a certain amount of days using the SELCT function.


Using this code:


Function GetDay(iPDRehabfrequancy)
Select case iPDRehabfrequancy
case 1
GetDay = 7
case 2
    GetDay = 3
case 3
    GetDay = 2
case 4
    GetDay = 14
case else
    GetDay = 0
End select
End Function

How can i tell M-files to see if the option choosed is 1 or 2 or 3? based on the data that has been picked from the list above?

I tried Cint(left)) function and it keeps giving me type mismatch..

Is there a way to perform this?

Thank you

  • You need to get the propertyvalue as lookup-ID and then use that lookupID to determine the case. Here is an example from a situation where I needed to get the Workflow State ID. You should be able to adapt it to your purpose:

    'script example that tests whether a lookup property is related to the object, whether it is empty and whether it has been serialised.
    'if all good, it retrieves the lookupID from that property.
    If PropertyValues.IndexOf(39) > -1 Then
       'object has the property - check its not null
       If Not PropertyValues.SearchForProperty(39).TypedValue.IsNull() Then
          ' check that its initialised
          If Not PropertyValues.SearchForProperty(39).TypedValue.IsUninitialized() Then
             Dim iWorkFlowStateId : iWorkFlowStateId = PropertyValues.SearchForProperty(39).TypedValue.GetLookUpId()
          End If
       End If
    End If

  • Hoo, that's interesting. Will give it a try.
    Thank you very much sir :)