VB Run Function Action With Multiple Params

  • 30 October 2023
  • 6 replies

Userlevel 2
Badge +8

I’m trying to follow the documentation for using a VB script with parameters: (

I have a working script which I can execute from outside of AA to add x number of business days to a date. This script is tested and working. However, I cannot get it to execute in AA.

  1. I have created a list variable for the parameters as instructed in the documentation
  2. I have added two string parameters to the list
  3. I’m using the list variable in the Parameters (optional) input for ‘Run Function’
  4. I’m saving the output to a string variable

All I get is ‘bot error’ when I run this.

Note that I have tried adding quotations around the strings before adding them to the list. Same result. Can someone please tell me where I’m doing something wrong here?

Here is the script for reference:



Best answer by JMarino 7 November 2023, 19:22

View original

6 replies

Userlevel 2
Badge +8

After much frustration with this decided to try Python:

import datetime

def date_by_adding_business_days(from_date, add_days):

    business_days_to_add = add_days

    current_date = from_date

    while business_days_to_add > 0:

        current_date += datetime.timedelta(days=1)

        weekday = current_date.weekday()

        if weekday >= 5: # sunday = 6


        business_days_to_add -= 1

    return current_date


Same setup as with the VB script: Open a session, either use a script file or manual input, call the date_by_adding_business_days and pass in the params. ‘bot error’ returns

Badge +3

@JMarino you have to consider input as array when passing list from AA.

In your VbScript change function parameter as:
Function AddWorkingDays (arguments)
    startDate = CDate (arguments(0))
    workingDays = arguments(1)

Userlevel 2
Badge +8

I’ll give this a try today and let you know.

Userlevel 2
Badge +8

@Sumit.K11 This still doesn’t work.

I tried something as simple as this just to see if I can feed in params and get something out.:

Public Function WorkingDaysFromToday(arguments) As String
    startDate = CDate (arguments(0))
    workingDays = arguments(1)
  WorkingDaysFromToday = workingDays
End Function


I still get ‘bot error’

I’m assigning a date as string to a list variable (this should be row 0) and then assigning the number 5 to the same list variable (row 1). Same setup as in my screenshot above. Same results.

Userlevel 2
Badge +8

@Sumit.K11 I finally got it to work using the following script:

Public Function WorkingDaysFromToday(arguments)

startDate = cdate(arguments(0))

DayCount = 0

workingDayCount = 0

  maxCount = cint(arguments(1))

    Do Until workingDayCount = maxCount

        If Not (Weekday(DateAdd("d", DayCount, startDate)) = 1 Or Weekday(DateAdd("d", DayCount, startDate)) = 7) Then

            workingDayCount = workingDayCount + 1 ' It's a working day!

        End If

        ' Keep count of the total number of days needed to make up the working day target

        DayCount = DayCount + 1



  DaysFromToday = DateAdd("d", DayCount - 1, startDate) ' Subtract 1 day to get the correct date

  WorkingDaysFromToday = DaysFromToday

End Function

I’d still like to get some error trapping in there.


Userlevel 2
Badge +8

@Sumit.K11 I clicked on the wrong link. Sorry you did not get credit for helping solve this!