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

Problem with VBScript

Hello,

 the attached script should calculate the property value in a certain class within a certain workflow and state. The script works inside the  loop, but the "if" condition is wrong. In what way could it be remade?

Dim dtToday
Dim documentClass
Dim iWorkflow
Dim iWorkflowState


documentClass = PropertyValues.SearchForProperty(100).TypedValue.DisplayValue
iWorkflow = PropertyValues.SearchForProperty(38).TypedValue.DisplayValue
iWorkflowState = PropertyValues.SearchForProperty(39).TypedValue.DisplayValue


if documentClass = "Mileage Status" or documentClass = "Employee Car"  and iWorkflowState = "2.1 Mileage Status" and iWorkflow = "Employee Car Process" then

dtToday = Now
Dim dtLastDay
dtLastDay = DateSerial(Year(dtToday), Month(dtToday) + 1, 0)


if dtToday = dtLastDay then
dtLastDay = DateSerial(Year(dtToday), Month(dtToday) + 2, 0)
end if

Output = dtLastDay

else
' '

end if

Parents
  • I'm not really sure what you're asking.  I don't see a loop.  Do you get an error?  Is the logic for the and/or conditions incorrect?  You don't have a fallback value for "Output", but I guess you don't want a value in other situations...

    I would personally change the code in a few ways, but they probably won't help with your specific issue:

    • Add Option Explicit at the top of the script, to force variable declaration.
    • I would use the actual lookup IDs in the code rather than checking the class / state names, as these can change too easily.
Reply
  • I'm not really sure what you're asking.  I don't see a loop.  Do you get an error?  Is the logic for the and/or conditions incorrect?  You don't have a fallback value for "Output", but I guess you don't want a value in other situations...

    I would personally change the code in a few ways, but they probably won't help with your specific issue:

    • Add Option Explicit at the top of the script, to force variable declaration.
    • I would use the actual lookup IDs in the code rather than checking the class / state names, as these can change too easily.
Children
No Data