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

Need Help in VBScript

Former Member
Former Member
' Get Contract End Date

Dim szContractEndDate

szContractEndDate = PropertyValues.SearchForProperty( 1306 ).TypedValue.DisplayValue

Dim szDate

szDate = DateSerial(Year(Now), Month(Now), Day(Now))

Dim szDate2

szDate2 = DateAdd("d",-135,szContractEndDate)

szDate = szDate2



I want to set  szDate2 to be trigger date for email notification
  • The last line will simply put szDate2 into your szDate variable - nothing gained by that.
    You should take a look at the DateDiff function www.w3schools.com/.../func_datediff.asp
    You can use it to determine whether sDate is equal to or larger than sDate2.
    And by the way: a simple use of the Date function should suffice - it is not necessary use the DateSerial function for this purpose.

    I suppose you want to use the script in a workflow transition trigger? If so you need to add a line "AllowStateTransition = True" if your requirements are met.
  • Former Member
    Former Member
    Thank you for the quick response.

    yes, im about to use it in a workflow transition trigger.

    what i mean on ( szDate = szDate2 ) is to change current date with the result in DateAdd("d",-135,szContractEndDate)

    szDate = DateSerial(Year(Now), Month(Now), Day(Now))
    szDate2 = DateAdd("d",-135,szContractEndDate)

    Appreciate your help


  • You could boil it down to this
    Option explicit
    Dim szContractEndDate
    szContractEndDate = CDate(PropertyValues.SearchForProperty( 1306 ).TypedValue.DisplayValue)
    If DateDiff("d",Date,szContractEndDate)
    AllowStateTransition = True
    End if
  • Former Member
    Former Member
    I have attached the image of my workflow.

    So when the Pending proposal state is reached, szContractEndDate (property.value) will less 135 days i want the result to be the workflow state trigger date basis.

    Contract End Date is a future date and we want to get notified 60 days, 45 days, 30 days (total of 135) before the contract end date.

    I'm not sure maybe there's an easy on doing this.

    Appreciate your help.
  • If those workflow states are there simply for the notification sending then couldn't you just calculate the contract end date to a property and use standard notification rules to send out the notifications on the specified dates before the end date? No need to move the contract forward in the workflow for those notifications alone.
  • Former Member
    Former Member
    Appreciate your response, as i understand but correct me if im wrong that could add a lot of work if you have multiple documents that has different contract end date.

    I'm just wandering maybe there's a vbscript that could change the state current date with a property date value, so transition state trigger date will base on the property date value.

    I will try all the responses on this post and give feedback to you guys.

    Thanks,
  • It wouldn't add any work as far as I understand your situation, three notification rules are needed (these are examples, notification filters might be different in your vault):

    Class = Contract AND DaysTo(Contract end date) - this notification would dispatch for any contract 60 days before the contract end date
    Class = Contract AND DaysTo(Contract end date) - this notification would dispatch for any contract 45 days before the contract end date
    Class = Contract AND DaysTo(Contract end date) - this notification would dispatch for any contract 30 days before the contract end date
  • Former Member
    Former Member
    I must try it as well. Also, is there way we can put it on a vbscript?
  • I don't see why you would use scripting when you can use built-in product functionality for the same thing? Is there a specific reason you want to do this? (You will likely still need some scripting to calculate the contract end date to a property.)
  • Former Member
    Former Member
    Im trying to avoid giving task or extra configuration to an end user , users will not do anything on their mfiles account and that's also great. But being an admin this awesome.

    Hope you get my point.