Jump to content

Tom Wellige

Root Moderator
  • Posts

    4,310
  • Joined

  • Last visited

  • Days Won

    117

 Content Type 

Profiles

SwyxPEDIA Wiki

Zendesk Integration

Persistent Variables

Longest Waiting

VBScript build in functions

GSE build in functions (VBScript)

Server Script API (VBScript)

GSE build in functions (Lua)

Server Script API (Lua)

Function Collection (VBScript)

Function Collection (Lua)

IPS Integration

Jira Service Integration

Forums

Blogs

Downloads

Everything posted by Tom Wellige

  1. Lua → VBScript This function returns true if the given user is logged in and free. Please see the Introduction chapter for some usage instructions. ------------------------------------------------------------------ -- IsUserFree -- -- Checks if given user is free or not. -- -- Parameter: -- sNumber extension -- -- Return: -- boolean ------------------------------------------------------------------ function IsUserFree( sNumber ) PBXScript.OutputTrace ("-------------> IsUserFree ( sNumber = " .. sNumber .. " )") local bReturn = false local oUsers = nil oUsers = PBXScript.GetUserByAddress(sNumber) if (oUsers ~= nil) then for i = 1, #oUsers do PBXScript.OutputTrace ("Found user '" .. oUsers[i]:Name() .. "' with current state '" .. oUsers[i]:State() .. "'") bReturn = (oUsers[i]:State() == 2) end end PBXScript.OutputTrace ("bReturn = " .. tostring(bReturn)) PBXScript.OutputTrace ("<------------- IsUserFree") return bReturn end This function makes use of the Server Script API functions PBXConfig.GetUserByAddress() to resolve all users in the given group and PBXScript.OutputTrace() to write trace information into the SwyxServer trace file. This function was converted from VBScript into Lua from the initially posted version in this forum topic.
  2. Lua → VBScript This function returns true if the current script user has an unconditional redirection to a user configured, where the current call already has been (in his call routing). Please see the Introduction chapter for some usage instructions. ------------------------------------------------------------------ -- IsRedirectionLoopConfigured -- -- Checks if the undonditional redirection target of the script user is -- already in the PreviousScripts list, i.e. the call was previously already in that user's call routing. -- -- Parameter: -- -- Return: -- boolean ------------------------------------------------------------------ function IsRedirectionLoopConfigured() PBXScript.OutputTrace ("-------------> IsRedirectionLoopConfigured") local bReturn = false if PBXUser.UnconditionalRedirect() then local sRedirectToUser = GetUserNameFromExtension(PBXUser.UnconditionalRedirectNumber()) local tScripts = nil tScripts = PBXScript.PreviousScripts() if (tScripts ~= nil) then for i = 1, #tScripts do PBXScript.OutputTrace ("PreviousScript.username = " .. tScripts[i].username) if (tScripts[i].username == sRedirectToUser) then PBXScript.OutputTrace ("Found redirection target in the PreviousScripts list. So this is most likely a loop!") bReturn = true end end end end PBXScript.OutputTrace ("bReturn = " .. tostring(bReturn)) PBXScript.OutputTrace ("<------------- IsRedirectionLoopConfigured") return bReturn end This function makes use of the function GetUserNameFromExtension() to get the username of the destination the current script user has an unconditional redirection configured to. Afterwards it uses the Server Script API function PBXScript.PreviousScripts() to search the username in the list of previous call routing scripts. Once this function returns true the idea is to disabled the unconditional redirection to prevent a loop. if IsRedirectionLoopConfigured() then PBXUser.UnconditionalRedirect(false) end There is another function IsLoopConfigured() available, following another approach to identify an existing call loop. Please take a look into the How to avoid loops topic for more details. This function was converted from VBScript into Lua from the initially posted version in this forum topic.
  3. Lua → VBScript This function returns true if the call was redirected/transferred by a certain user (extension) or list of extensions, separated by ; (semikolon). Please see the Introduction chapter for some usage instructions. ------------------------------------------------------------------ -- IsRedirectedFromByNumber -- -- Returns true if the current call is redirected by any of the numbers -- given in the semicolon separated list. It also returns the number that -- redirected the call. -- -- Parameter: -- sNumbers semicolon separated list of all numbers -- -- Return: -- boolean, -- true - call redirected from given number -- false - call not redirected from given number -- string -- empty if call wasn't redirected by anyone from the list, -- otherwise the extension that redirected the call. ------------------------------------------------------------------ function IsRedirectedFromByNumber( sNumbers ) PBXScript.OutputTrace ("------> IsRedirectedFromByNumber ( '" .. sNumbers .. "' )") local bReturn = false local sReturn = "" local sName = "" local tNumbers = StringSplitToTable(sNumbers, ";") for i = 1, #tNumbers do PBXScript.OutputTrace ("Checking extension: " .. tNumbers[i]) sName = GetUserNameFromExtension(tNumbers[i]) PBXScript.OutputTrace ("Found username: " .. sName) if (sName ~= "") then if IsRedirectedFromByName(sName) then PBXScript.OutputTrace ("Call is redirected from this user") bReturn = true sReturn = tNumbers[i] else PBXScript.OutputTrace ("Call is not redirected from this user") end end end PBXScript.OutputTrace ("bReturn = " .. tostring(bReturn)) PBXScript.OutputTrace ("sReturn = " .. sReturn) PBXScript.OutputTrace ("<------ IsRedirectedFromByNumber") return bReturn, sNumber end This function makes use of the function GetUserNameFromExtension() to get the username for a given extension, and also the function IsRedirectedFromByName() to then check if the call is redirected/transferred from that user. It makes also use of the Server Script API function PBXScript.OutputTrace() to write trace information into the SwyxServer trace file. It also uses the GSE build-in helper function StringSplitToTable() to find the caller number in the data from the file. Please note: from SwyxWare v13.27 on it is possible to have call routing also for groups and not just users. This function can not be extended to identify the new groups as well, so it can identify users only. This function was converted from VBScript into Lua from the initially posted version in this forum topic.
  4. Lua → VBScript SwyxWare 13.26 This function checks if the current call was redirected by a given user. Please see the Introduction chapter for some usage instructions. ------------------------------------------------------------------ -- IsRedirectedFromByName -- -- Checks if current call is redirected by a given user. -- -- Parameter: -- sUserName name of user to check if call is redirected from -- -- Return: -- boolean true - call was redirected by given user -- false - call was not redirected by the given user ------------------------------------------------------------------ function IsRedirectedFromByName (sUserName) PBXScript.OutputTrace ("----------> IsRedirectedFromByName ( sUserName = " .. sUserName .. " )") local bReturn = false local tScripts = nil tScripts = PBXScript.PreviousScripts() if (tScripts ~= nil) then for i = 1, #tScripts do PBXScript.OutputTrace ("PreviousScript.username = " .. tScripts[i].username) if (tScripts[i].username == sUserName) then PBXScript.OutputTrace ("This is a redirected call from " .. sUserName) bReturn = true end end end PBXScript.OutputTrace ("bReturn = " .. tostring(bReturn)) PBXScript.OutputTrace ("<--------- IsRedirectedFromByName") return bReturn end This function makes use of the Server script API function PBXScript.PreviousScripts() to check if the call has been transferred by the given user (defined by his name) and PBXScript.OutputTrace() to write trace information into the SwyxServer trace file. Please note: this function makes use of obsolete functionality in the PBXScript.PreviousScripts() table which was replaced in SwyxWare v13.27 to identify users and groups, instead of users only. There is an updated version of this function available, IsRedirectedFromByNameEx, which makes use of the new functionality. A usage example of this function could be the following: Boss redirects all his calls to his secretary. The secretary redirects all her calls to the operator because she has to leave the office. So, when calling the boss directly one would end up at the operator. For the operator it would be useful to know if this is such a "boss" call. So, all you have to do is to call this function with the name of the boss user and afterwards e.g. manipulate the text being shown in the SwyxIt! display. if IsRedirectedFromByName("Mr. Boss") then PBXCall.CallingPartyName ("BOSS - " & PBXCall.CallingPartyName()) end Another usage of this function can be found in the function IsRedirectedFromByNumber(). This function was converted from VBScript into Lua from the initially posted version in this forum topic.
  5. Lua → VBScript The following function returns true if the current script user can be found in the list of users, where the current call has already been. Please see the Introduction chapter for some usage instructions. ------------------------------------------------------------------ -- IsLoopConfigured -- -- Checks if current script user is in the PreviousScripts list, -- i.e. the call was previously already in that user's call routing. -- So chances are high that this is a loop. -- -- Parameter: -- -- Return: -- boolean true - found in PreviousScripts list -- false - not found in PreviousScripts list. ------------------------------------------------------------------ function IsLoopConfigured () PBXScript.OutputTrace ("-------------> IsLoopConfigured") local bReturn = IsRedirectedFromByName(PBXUser.Name()) PBXScript.OutputTrace ("bReturn = " .. tostring(bReturn)) PBXScript.OutputTrace ("<------------- IsLoopConfigured") return bReturn end This function makes use of the IsRedirectedFromByName() function, which is also part of the VBScript Function Collection. It also makes use of the Server Script API function PBXScript.OutputTrace() to write trace information into the SwyxServer trace file. This function was converted from VBScript into Lua from the initially posted version in this forum topic.
  6. Lua → VBScript This function returns true if all members of the given group are logged off. Please see the Introduction chapter for some usage instructions. --------------------------------------------------------------------- -- Name: IsGroupLoggedOff -- ================ -- -- Checks if all members of a given SwyxWare user group are logged off. -- -- Parameter -- sGroup group number or name -- -- Return: -- boolean True - all members of the given group are logged off (or status can't be requested) -- False - at least one member of the given group is logged on ---------------------------------------------------------------------- function IsGroupLoggedOff ( sGroup ) PBXScript.OutputTrace ("-------------> IsGroupLoggedOff ( sGroup = " .. sGroup .. " )") local bReturn = true local oUsers = nil oUsers = PBXScript.GetUserByAddress(sGroup) if (oUsers ~= nil) then for i = 1, #oUsers do PBXScript.OutputTrace ("Found user '" .. oUsers[i]:Name() .. "' with current state '" .. oUsers[i]:State() .. "'") if (oUsers[i]:State() > 1) then bReturn = false end end end PBXScript.OutputTrace ("bReturn = " .. tostring(bReturn)) PBXScript.OutputTrace ("<------------- IsGroupLoggedOff") return bReturn end This function makes use of the Server Script API functions PBXConfig.GetUserByAddress() to resolve all users in the given group and PBXScript.OutputTrace() to write trace information into the SwyxServer trace file. Please note: if you are on SwyxWare v13.27 (or higher) and need to know if all users of the group the current script is running for are logged in/off, you can also use the new Server Script API function PBXGroup.IsLoggedIn(). This function was converted from VBScript into Lua from the initially posted version in this forum topic.
  7. Lua → VBScript This function returns true if the current script user has an unconditional redirection to an external destination enabled. Please see the Introduction chapter for some usage instructions. ------------------------------------------------------------------ -- IsExternalRedirectionConfigured -- -- Checks if there is an unconditional call forwarding configured to an -- external number. The function checks if the configured unconditional -- call forwarding starts with the configured public line access. -- -- Parameter: -- -- Return: -- boolean true - external redirection configured -- false - no external redirection configured ------------------------------------------------------------------ function IsExternalRedirectionConfigured() PBXScript.OutputTrace "-------------> IsExternalRedirectionConfigured" local bReturn = false local tConfig = nil local sPublicLineAccess = "" tConfig = PBXScript.GetPBXConfig() sPublicLineAccess = tConfig.publicaccessprefix PBXScript.OutputTrace ("Configured public line access: " .. sPublicLineAccess) -- check forwarding if (PBXUser.UnconditionalRedirect()) then PBXScript.OutputTrace ("Unconditional call forwarding configured to " .. PBXUser.UnconditionalRedirectNumber()) if (StringLeft(PBXUser.UnconditionalRedirectNumber(), StringLen(sPublicLineAccess)) == sPublicLineAccess) then PBXScript.OutputTrace ("External call forwarding configured") bReturn = true else PBXScript.OutputTrace ("Internal call forwarding configured") end else PBXScript.OutputTrace ("No unconditional call forwarding configured") end PBXScript.OutputTrace ("bReturn: " .. tostring(bReturn)) PBXScript.OutputTrace ("<------------- IsExternalRedirectionConfigured") return bReturn end This function makes use of the Server Script API function PBXScript.GetPBXConfig() to get the configured public line access. Afterwards it uses PBXUser.UnconditionalRedirect() and PBXUser.UnconditionalRedirectNumber() to check if a redirection is enabled and configured to a number starting with the public line access. It also uses PBXScript.OutputTrace() to write trace information into the SwyxServer trace file. It also uses the GSE build-in helper functios StringLeft() and StringLen(). This function was converted from VBScript into Lua from the initially posted version in this forum topic.
  8. Lua → VBScript This function returns true if the call was transferred by another user and is not a direct call. Please see the Introduction chapter for some usage instructions. ------------------------------------------------------------------ -- IsCallTransferred -- -- Checks if the current call was transferred to the current user, -- i.e. was in some other user's call routing before. -- -- Parameter: -- -- Return: -- boolean true - call was transferred -- false - call is a direct call ------------------------------------------------------------------ function IsCallTransferred () PBXScript.OutputTrace ("-------> IsCallTransferred()") local bReturn = false local tScripts = nil tScripts = PBXScript.PreviousScripts() if (tScripts ~= nil) then PBXScript.OutputTrace ("PBXScript.PreviousScripts() item count = " .. tostring(#tScripts)) bReturn = (#tScripts > 0) end PBXScript.OutputTrace ("bReturn = " .. tostring(bReturn)) PBXScript.OutputTrace ("<------- IsCallTransferred()") return bReturn end This function makes use of the Server script API function PBXScript.PreviousScripts() to check if the call has been in some other call routing scripts before (if so, it must have been transferred) and PBXScript.OutputTrace() to write trace information into the SwyxServer trace file. This function was converted from VBScript into Lua from the initially posted version in this forum topic.
  9. Lua → VBScript This function returns true if at least one member of the given group is busy. Please see the Introduction chapter for some usage instructions. ------------------------------------------------------------------ -- IsAtLeastOneMemberOfGroupLoggedOff -- -- Returns true if at least one member of the given group is busy. -- -- Parameter: -- sGroup group number or name -- -- Return: -- boolean true - at least one member of group logged off -- false . all members of the group logged in ------------------------------------------------------------------ function IsAtLeastOneMemberOfGroupLoggedOff ( sGroup ) PBXScript.OutputTrace ("---------> IsAtLeastOneMemberOfGroupLoggedOff ( " .. sGroup .. " )") local bReturn = false local oUsers = nil oUsers = PBXScript.GetUserByAddress(sGroup) if (oUsers ~= nil) then for i = 1, #oUsers do PBXScript.OutputTrace ("Found user '" .. oUsers[i]:Name() .. "' with current state '" .. oUsers[i]:State() .. "'") -- state 1 = logged off if (oUsers[i]:State() == 1) then bReturn = true end end end PBXScript.OutputTrace ("bReturn = " .. tostring(bReturn)) PBXScript.OutputTrace ("<--------- IsAtLeastOneMemberOfGroupLoggedOff") return bReturn end This function makes use of the Server Script API functions PBXConfig.GetUserByAddress() to resolve all users in the given group and PBXScript.OutputTrace() to write trace information into the SwyxServer trace file. This function was converted from VBScript into Lua from the initially posted version in this forum topic.
  10. Lua → VBScript This function returns true if at least one member of the given group is busy. Please see the Introduction chapter for some usage instructions. ------------------------------------------------------------------ -- IsAtLeastOneMemberOfGroupBusy -- -- Returns true if at least one member of the given group is busy. -- -- Parameter: -- sGroup group number or name -- -- Return: -- boolean true - at least one member of group busy -- false . no member of the group is busy ------------------------------------------------------------------ function IsAtLeastOneMemberOfGroupBusy ( sGroup ) PBXScript.OutputTrace ("---------> IsAtLeastOneMemberOfGroupBusy ( " .. sGroup .. " )") local bReturn = false local oUsers = nil oUsers = PBXScript.GetUserByAddress(sGroup) if (oUsers ~= nil) then for i = 1, #oUsers do PBXScript.OutputTrace ("Found user '" .. oUsers[i]:Name() .. "' with current state '" .. oUsers[i]:State() .. "'") -- state 3 = speaking external -- state 5 = speaking internal if ((oUsers[i]:State() == 3) or (oUsers[i]:State() == 5)) then bReturn = true end end end PBXScript.OutputTrace ("bReturn = " .. tostring(bReturn)) PBXScript.OutputTrace ("<--------- IsAtLeastOneMemberOfGroupBusy") return bReturn end This function makes use of the Server Script API functions PBXConfig.GetUserByAddress() to resolve all users in the given group and PBXScript.OutputTrace() to write trace information into the SwyxServer trace file. This function was converted from VBScript into Lua from the initially posted version in this forum topic.
  11. Lua → VBScript The following function returns the user name from a given extension. Please see the Introduction chapter for some usage instructions. ------------------------------------------------------------------ -- GetUserNameFromExtension -- -- Returns the user name for the given extension. -- -- Parameter: -- sExtension extension -- -- Return: -- string user name ------------------------------------------------------------------ function GetUserNameFromExtension( sExtension ) PBXScript.OutputTrace ("------> GetUserNameFromExtension ( " .. sExtension .. " )") local sReturn = "" local oUsers = nil oUsers = PBXScript.GetUserByAddress(sExtension) if (oUsers ~= nil) then for i = 1, #oUsers do PBXScript.OutputTrace ("Found user '" .. oUsers[i]:Name() .. "'") sReturn = oUsers[i]:Name() end end PBXScript.OutputTrace ("sReturn = " .. sReturn) PBXScript.OutputTrace ("<------ GetUserNameFromExtension") return sReturn end This function makes use of the Server Script API functions PBXConfig.GetUserByAddress() to get the user name from the given number and PBXScript.OutputTrace() to write trace information into the SwyxServer trace file. Examples for the usage of this function can be found in the functions IsRedirectedFromByNumber() and IsRedirectionLoopConfigured(). This function was converted from VBScript into Lua from the initially posted version in this forum topic.
  12. Lua → VBScript The following function returns true if the current script user has any redirection configured (unconditional, busy or delayed). Please see the Introduction chapter for some usage instructions. ------------------------------------------------------------------ -- AnyRedirectionConfigured -- -- Returns true if current user has configured any redirection (unconditional, busy or delayed) -- -- Parameter: -- none -- -- Return: -- boolean ------------------------------------------------------------------ function AnyRedirectionConfigured() PBXScript.OutputTrace ("------> AnyRedirectionConfigured ()") local bReturn bReturn = (PBXUser.UnconditionalRedirect() or PBXUser.BusyRedirect() or PBXUser.DelayedRedirect()) PBXScript.OutputTrace ("bReturn = " .. tostring(bReturn)) PBXScript.OutputTrace ("<------ AnyRedirectionConfigured") return bReturn end This function makes use of the Server Script API functions PBXUser.UnconditionalRedirec(), PBXUser.BusyRedirect() and PBXUser.DelayedRedirect() to figure if any of the script users' redirection is currently enabled and PBXScript.OutputTrace() to write trace information into the SwyxServer trace file. This function was converted from VBScript into Lua from the initially posted version in this forum topic.
  13. VBScript → Lua This function returns the current status of the given user. Please see the Introduction chapter for some usage instructions. '---------------------------------------------------------------- ' UserStatus ' ' Returns the current status of the given user. ' ' Parameter ' sNumber user name or extension ' ' Return ' integer 0 - State Unavailable (no status signalling configured!) ' 1 - Logged Off ' 2 - Logged On (no speaking) ' 3 - Speaking External ' 4 - Alerting ' 5 - Speaking Internal ' 6 - Away (since SwyxWare 2011) ' 7 - Do not Disturb (since SwyxWare 2011) ' 8 - Busy Indication from external presence source (e.g. MS Teams) (since SwyxWare 13) '---------------------------------------------------------------- Function UserStatus(ByVal sNumber) PBXScript.OutputTrace("-------------> UserStatus ( sNumber = " & sNumber & " )") Dim nReturn nReturn = 0 Dim Users Set Users = g_PBXConfig.GetUserByAddress(sNumber) Dim User For Each User In Users PBXScript.OutputTrace("Found user " & User.Name & " with current state " & User.State) nReturn = User.State Next UserStatus = nReturn PBXScript.OutputTrace("nReturn = " & nReturn) PBXScript.OutputTrace("<------------- UserStatus") End Function Please note that the status signalling between all involved users (incl. the one the current call routing runs for) must be configured (just as in SwyxIt!). This function makes use of the Server Script API functions PBXConfig.GetUserByAddress to resolve the user state and PBXScript.OutputTrace to write trace information into the SwyxServer trace file. You can use the Insert Script Code block to route all return values on different exits of this block in order to evaluate the user status graphically. This function was initially posted into this forum topic.
  14. VBScript → Lua The following function sets the "new voicemail indication" for a certain user or all users within a user group. Please see the Introduction chapter for some usage instructions. '------------------------------------------------------------------- ' SetNewVoicemailFlag ' ' This function sets the "new voicemail indication" for a single user ' or all users of a SwyxWare user group. ' ' Parameter: ' sUserOrGroup name of user or group ' ' Return: ' none '-------------------------------------------------------------------- Function SetNewVoicemailFlag ( sUserOrGroup ) PBXScript.OutputTrace "-------------> SetNewVoicemailFlag ( sUserOrGroup = " & sUserOrGroup & " )" Dim oUsers Set oUsers = g_PBXConfig.GetUserByAddress(sUserOrGroup) Dim oUser For Each oUser In oUsers PBXScript.OutputTrace "Found user " & User.Name oUser.NumberOfNewVoicemails = oUser.NumberofNewVoicemails + 1 Next PBXScript.OutputTrace "<------------- SetNewVoicemailFlag" End Function This function makes use of the Server Script API functions PBXConfig.GetUserByAddress to resolve all users in the given group and PBXScript.OutputTrace to write trace information into the SwyxServer trace file. This function was initially posted into this forum topic.
  15. VBScript → Lua This function calls (launches) a given URL (http request) and returns True if the request returns without error. Please see the Introduction chapter for some usage instructions. '------------------------------------------------------------------- ' LaunchHTTPRequest ' ' Launches given URL. ' ' Parameter: ' sURL complete url ' ' return value: ' boolean True - request file processed ' False - request file *not* processed '-------------------------------------------------------------------- Function LaunchHTTPRequest(ByVal sURL) PBXScript.OutputTrace "------> LaunchHTTPRequest ( sURL = '" & sURL & "' )" On Error Resume Next Dim bReturn bReturn = True Dim HTTP_REQ Set HTTP_REQ = CreateObject("Msxml2.ServerXMLHTTP.3.0") Dim lResolve, lConnect, lSend, lReceive lResolve = 1 * 60 * 1000 ' 1 minute (default: infinte) lConnect = 1 * 60 * 1000 ' 1 minute (default) lSend = 60 * 60 * 1000 ' 1 hour (default: 30 seconds) lReceive = 60 * 60 * 1000 ' 1 hour (default: 30 seconds) HTTP_REQ.setTimeouts lResolve, lConnect, lSend, lReceive Dim vBefore, vAfter, nDuration vBefore = Now HTTP_REQ.open "GET", sURL, False HTTP_REQ.send If Err <> 0 Then PBXScript.OutputTrace "Error sending http request (" & Hex(Err) & ")" PBXScript.OutputTrace Err.Description Err.Clear Else vAfter = Now nDuration = DateDiff("s", vBefore, vAfter) PBXScript.OutputTrace "HTTP Request returned after " & nDuration & " seconds" bReturn = True End If Set HTTP_REQ = Nothing LaunchHTTPRequest = bReturn PBXScript.OutputTrace "bReturn = " & bReturn PBXScript.OutputTrace "<------ LaunchHTTPRequest" End Function This function makes use of the Server Script API function PBXScript.OutputTrace to write trace information into the SwyxServer trace file. Another version of this function which makes use of the PBXScript.WebRequest object (which was introduced with SwyxWare 12.40) to perform the web request can be found in the LaunchHTTPRequestEx function. This function was initially posted into this forum topic.
  16. VBScript → Lua This function calls (launches) a given command, i.e. launches any given application. Please see the Introduction chapter for some usage instructions. '---------------------------------------------------------------- ' LaunchCmd ' ' Calls/launches the given command ' ' Parameter: ' sCommand command to be called ' ' Return: ' none '---------------------------------------------------------------- Function LaunchCmd( sCommand ) PBXScript.OutputTrace "------> LaunchCmd ( " & sCommand & " )" On Error Resume Next Dim objShell Set objShell = CreateObject("WScript.Shell") objShell.Run sCommand If Err <> 0 Then PBXScript.OutputTrace "Error executing the given command! (" & Hex(Err) & ")" PBXScript.OutputTrace Err.Description Else PBXScript.OutputTrace "Given Command successfuly executed" End If Set objShell = Nothing PBXScript.OutputTrace "<----- LaunchCmd" End Function Please note that this command will be launched on the SwyxServer machine. No windows will be opened, and no user input can be made. So only start command line applications which do not require any user input. As the call routing is executed by the Swyx Server service, the command will also be executed by the Swyx Server service. That means, it is executed by the Windows user, the Swyx Server service is running under (usually this is the local SwyxServiceAccount user). This function makes use of the Server Script API function PBXScript.OutputTrace to write trace information into the SwyxServer trace file. This function was initially posted into this forum topic.
  17. VBScript → Lua This function returns True of the given user is logged off from the server. Please see the Introduction chapter for some usage instructions. '---------------------------------------------------------------- ' IsUserLoggedOff ' ' Checks if given user is logged off ' ' Parameter: ' sNumber user name or extension ' ' Return: ' boolean '---------------------------------------------------------------- Function IsUserLoggedOff( sNumber ) PBXScript.OutputTrace "-------------> IsUserLoggedOff ( sNumber = " & sNumber & " )" Dim bReturn bReturn = False Dim Users Set Users = g_PBXConfig.GetUserByAddress(sNumber) Dim User For Each User In Users PBXScript.OutputTrace "Found user " & User.Name & " with current state " & User.State bReturn = (User.State = 1) Next IsUserLoggedOff = bReturn PBXScript.OutputTrace "bReturn = " &bReturn PBXScript.OutputTrace "<------------- IsUserLoggedOff" End Function Please note that the status signalling between all involved users (incl. the one the current call routing runs for) must be configured (just as in SwyxIt!). This function makes use of the Server Script API functions PBXConfig.GetUserByAddress to get the current status of the given user and PBXScript.OutputTrace to write trace information into the SwyxServer trace file. This function was initially posted into this forum topic.
  18. VBScript → Lua This function returns True of the given user is logged on. Please see the Introduction chapter for some usage instructions. '---------------------------------------------------------------- ' IsUserLoggedOn ' ' Checks if given user is logged on ' ' Parameter: ' sNumber user name or extension ' ' Return: ' boolean '---------------------------------------------------------------- Function IsUserLoggedOn( sNumber ) PBXScript.OutputTrace "-------------> IsUserLoggedOn ( sNumber = " & sNumber & " )" Dim bReturn bReturn = False Dim Users Set Users = g_PBXConfig.GetUserByAddress(sNumber) Dim User For Each User In Users PBXScript.OutputTrace "Found user " & User.Name & " with current state " & User.State bReturn = (User.State >= 2) Next IsUserLoggedOn = bReturn PBXScript.OutputTrace "bReturn = " &bReturn PBXScript.OutputTrace "<------------- IsUserLoggedOn" End Function Please note that the status signalling between all involved users (incl. the one the current call routing runs for) must be configured (just as in SwyxIt!). This function makes use of the Server Script API functions PBXConfig.GetUserByAddress to get the current status of the given user and PBXScript.OutputTrace to write trace information into the SwyxServer trace file. This function was initially posted into this forum topic.
  19. VBScript → Lua This function checks if the current script user is member of the given group. Please see the Introduction chapter for some usage instructions. '---------------------------------------------------------------- ' IsUserInGroup ' ' Checks if the current script user is in the given group ' ' Parameter: ' sGroup group number or name ' ' Return: ' boolean '---------------------------------------------------------------- Function IsUserInGroup ( sGroup ) PBXScript.OutputTrace "----------> IsUserInGroup" PBXScript.OutputTrace "sGroup = " & sGroup Dim bReturn bReturn = False Dim Users Set Users = g_PBXConfig.GetUserByAddress(sGroup) Dim User For Each User In Users PBXScript.OutputTrace "Found group member " & User.Name if PBXUser.Name = User.Name then PBXScript.OutputTrace "Current script user '" & PBXUser.Name & "' is member of the group '" & sGroup & "'!" bReturn = True end if Next IsUserInGroup = bReturn PBXScript.OutputTrace "bReturn = " & bReturn PBXScript.OutputTrace "<---------- IsUserInGroup" End Function This function makes use of the Server Script API functions PBXConfig.GetUserByAddress to resolve all users in the given group and PBXUser.Name to get the name of the current script user. It also uses PBXScript.OutputTrace to write trace information into the SwyxServer trace file. This function was initally posted into this forum topic.
  20. VBScript → Lua This function returns true if the given user is logged in and free. Please see the Introduction chapter for some usage instructions. '---------------------------------------------------------------- ' IsUserFree ' ' Checks if given user is free or not. ' ' Parameter: ' sNumber extension ' ' Return: ' boolean '---------------------------------------------------------------- Function IsUserFree( sNumber ) PBXScript.OutputTrace "-------------> IsUserFree ( sNumber = " & sNumber & " )" Dim bReturn bReturn = False Dim Users Set Users = g_PBXConfig.GetUserByAddress(sNumber) Dim User For Each User In Users PBXScript.OutputTrace "Found user " & User.Name & " with current state " & User.State bReturn = (User.State = 2) Next IsUserFree = bReturn PBXScript.OutputTrace "bReturn = " & bReturn PBXScript.OutputTrace "<------------- IsUserFree" End Function Please note that the status signalling between all involved users (incl. the one the current call routing runs for) must be configured (just as in SwyxIt!). This function makes use of the Server Script API functions PBXConfig.GetUserByAddress to resolve all users in the given group and PBXScript.OutputTrace to write trace information into the SwyxServer trace file. This function was initially posted into this forum topic.
  21. VBScript → Lua This function returns True if the current script user has an unconditional redirection to a user configured, where the current call already has been (in his call routing). Please see the Introduction chapter for some usage instructions. '---------------------------------------------------------------- ' IsRedirectionLoopConfigured ' ' Checks if the undonditional redirection target of the script user is ' already in the PreviousScripts list, i.e. the call was previously already in that user's call routing. ' ' Parameter: ' ' Return: ' boolean '---------------------------------------------------------------- Function IsRedirectionLoopConfigured PBXScript.OutputTrace "-------------> IsRedirectionLoopConfigured" Dim bReturn bReturn = False If PBXUser.UnconditionalRedirect Then Dim sRedirectToUser sRedirectToUser = GetUserNameFromExtension(PBXUser.UnconditionalRedirectNumber) Dim Script For Each Script In PBXScript.PreviousScripts PBXScript.OutputTrace "Found user " & User.Name If sRedirectToUser = Script.UserName Then PBXScript.OutputTrace "Found redirection target in the PreviousScripts list. So this is most likely a loop!" bReturn = True End If Next End If IsRedirectionLoopConfigured = bReturn PBXScript.OutputTrace "bReturn = " & bReturn PBXScript.OutputTrace "<------------- IsRedirectionLoopConfigured" End Function This function makes use of the function GetUserNameFromExtension to get the username of the destination the current script user has an unconditional redirection configured to. Afterwards it uses the Server Script API function PBXScript.PreviousScripts to search the username in the list of previous call routing scripts. Once this function returns true the idea is to disabled the unconditional redirection to prevent a loop. If IsRedirectionLoopConfigured Then PBXUser.UnconditionalRedirect = False End If There is another function IsLoopConfigured available, following another approach to identify an existing call loop. Please take a look into the How to avoid loops topic for more details. This function was initially posted into this forum topic.
  22. VBScript → Lua This function returns True if the call was redirected/transferred by a certain user (extension) or list of extensions, separated by ; (semikolon). Please see the Introduction chapter for some usage instructions. '---------------------------------------------------------------- ' IsRedirectedFromByNumber ' ' Returns true if the current call is redirected by any of the numbers ' given in the semicolon separated list. It also returns the number that ' redirected the call. ' ' Parameter: ' sNumbers [in] semicolon separated list of all numbers ' sNumber [out] empty if call wasn't redirected by anyone from the list, ' otherwise the extension that redirected the call. ' ' Return: ' boolean '---------------------------------------------------------------- Function IsRedirectedFromByNumber( ByVal sNumbers, ByRef sNumber ) PBXScript.OutputTrace "------> IsRedirectedFromByNumber ( '" & sNumbers & "' )" Dim bReturn bReturn = False sNumber = "" Dim i, aNumbers, sName aNumbers = Split(sNumbers, ";") For i = LBound(aNumbers) To UBound(aNumbers) PBXScript.OutputTrace "Checking extension: " & aNumbers(i) sName = GetUserNameFromExtension(aNumbers(i)) PBXScript.OutputTrace "Found username: " & sName If sName <> "" Then If IsRedirectedFromByName(sName) Then PBXScript.OutputTrace "Call is redirected from this user" bReturn = True sNumber = aNumbers(i) Else PBXScript.OutputTrace "Call is not redirected from this user" End If End If Next IsRedirectedFromByNumber = bReturn PBXScript.OutputTrace "bReturn = " & bReturn PBXScript.OutputTrace "<------ IsRedirectedFromByNumber ( Return '" & bReturn & "' )" End Function This function makes use of the function GetUserNameFromExtension to get the username for a given extension, and also the function IsRedirectedFromByName to then check if the call is redirected/transferred from that user. It makes also use of the Server Script API function PBXScript.OutputTrace to write trace information into the SwyxServer trace file. Please note: from SwyxWare v13.27 on it is possible to have call routing also for groups and not just users. This function can not be extended to identify the new groups as well, so it can identify users only. This function was initially posted into this forum topic.
  23. VBScript → Lua SwyxWare 13.26 This function checks if the current call was redirected by a given user. Please see the Introduction chapter for some usage instructions. '---------------------------------------------------------------- ' IsRedirectedFromByName ' ' Checks if current call is redirected by a given user. ' ' Parameter: ' sUserName name of user to check if call is redirected from ' ' Return: ' boolean true - call was redirected by given user ' false - call was not redirected by the given user '---------------------------------------------------------------- Function IsRedirectedFromByName(ByVal sUserName) PBXScript.OutputTrace "----------> IsRedirectedFromByName ( sUserName = " & sUserName & " )" Dim bReturn bReturn = False Dim PrevScripts Set PrevScripts = PBXScript.PreviousScripts Dim PrevScript For Each PrevScript In PrevScripts PBXScript.OutputTrace "PrevScript.UserName = " & PrevScript.UserName If PrevScript.UserName = sUserName Then PBXScript.OutputTrace "this is a redirected call from " & sUserName bReturn = True End If Next IsRedirectedFromByName = bReturn PBXScript.OutputTrace "bReturn = " & bReturn PBXScript.OutputTrace "<--------- IsRedirectedFromByName" End Function This function makes use of the Server script API function PBXScript.PreviousScripts to check if the call has been transferred by the given user (defined by his name) and PBXScript.OutputTrace to write trace information into the SwyxServer trace file. Please note: this function makes use of obsolete functionality in the PBXScript.PreviousScripts collection which was replaced in SwyxWare v13.27 to identify users and groups, instead of users only. There is an updated version of this function available, IsRedirectedFromByNameEx, which makes use of the new functionality. A usage example of this function could be the following: Boss redirects all his calls to his secretary. The secretary redirects all her calls to the operator because she has to leave the office. So, when calling the boss directly one would end up at the operator. For the operator it would be useful to know if this is such a "boss" call. So, all you have to do is to call this function with the name of the boss user and afterwards e.g. manipulate the text being shown in the SwyxIt! display. If IsRedirectedFromByName("Mr. Boss") Then PBXCall.CallingPartyName = "BOSS - " & PBXCall.CallingPartyName End If Another usage of this function can be found in the function IsRedirectedFromByNumber. This function was initially posted into this forum topic.
  24. VBScript → Lua This function checks a given date for a public holiday in Germany. It takes the different federal states into consideration. Please see the Introduction chapter for some usage instructions. ' Federal States of Germany const vb_FS_BW = 1 ' Baden-Wuerttemberg const vb_FS_BYMH = 131072 ' Bayern (mit Mariea Himmelfahrt) const vb_FS_BY = 2 ' Bayern (ohne Mariea Himmelfahrt) const vb_FS_BE = 4 ' Berlin const vb_FS_BB = 8 ' Brandenburg const vb_FS_HB = 16 ' Bremen const vb_FS_HH = 32 ' Hamburg const vb_FS_HE = 64 ' Hessen const vb_FS_MV = 128 ' Mecklenburg-Vorpommern const vb_FS_NI = 256 ' Niedersachsen const vb_FS_NW = 512 ' Nordrhein-Westfalen const vb_FS_RP = 1024 ' Rheinland-Pfalz const vb_FS_SL = 2048 ' Saarland const vb_FS_SN = 4096 ' Sachsen const vb_FS_ST = 8192 ' Sachen-Anhalt const vb_FS_SH = 16384 ' Schleswig-Holstein const vb_FS_TH = 32768 ' Thueringen const vb_FS_KD = 65536 ' Koeln/Duesseldorf (Rosenmontag) const vb_FS_AU = 262144 ' Augsburg (Friedensfest) '------------------------------------------------------------------- ' Name: IsPublicHolidayDE ' ================= ' ' Returns true if the given date is a public holiday in the given German ' federal state. Multiple federal states can be combined with "OR" ' ' Parameter: ' nFederalState single or combination of federal states ' vCheckDate vbscript date to check (e.g. as returned by now) or ' "" (for current date) ' ' Returns: ' Boolean True = is public holiday ' '-------------------------------------------------------------------- Function IsPublicHolidayDE ( nFederalState, vCheckDate ) On Error Resume Next PBXScript.OutputTrace "-------> IsPublicHolidayDE" PBXScript.OutputTrace "nFederalState = " & nFederalState PBXScript.OutputTrace "vCheckDate = " & vCheckDate Dim bReturn bReturn = False Dim a, b, c, d, e, f Dim nTempYear, vTempDate Dim Neujahr, Erscheinungsfest, Karfreitag, Ostersonntag, Ostermontag Dim Weltfrauentag, Maifeiertag, Rosenmontag, ChrHimmelfahrt, Pfingstmontag, Fronleichnam Dim MarieaHimmelfahrt, Friedensfest, Weltkindertag, Tagdereinheit, Reformationstag, Allerheiligen Dim BussUndBettag, Weihnachten1, Weihnachten2 if not IsDate(vCheckDate) then vCheckDate = Now vTempDate = DateSerial(Year(vCheckDate), Month(vCheckDate), Day(vCheckDate)) nTempYear = Year(vTempDate) PBXScript.OutputTrace "Using nTempYear = " & nTempYear PBXScript.OutputTrace "Using vTempDate = " & vTempDate ' Gauss Formular a = nTempYear Mod 19 b = nTempYear \ 100 c = (8 * b + 13) \ 25 - 2 d = b - (nTempYear \ 400) - 2 e = (19 * (nTempYear Mod 19) + ((15 - c + d) Mod 30)) Mod 30 if e = 28 then if a > 10 then e = 27 end if elseif e = 29 then e = 28 end if f = (d + 6 * e + 2 * (nTempYear Mod 4) + 4 * (nTempYear Mod 7) + 6) Mod 7 ' Calculate public holidays Neujahr = DateSerial(nTempYear, 1, 1) Erscheinungsfest = DateSerial(nTempYear, 1, 6) Weltfrauentag = DateSerial(nTempYear, 3, 8) Ostersonntag = DateSerial(nTempYear, 3, e + f + 22) Rosenmontag = DateSerial(nTempYear, 3, e + f + 22 - 48) Karfreitag = DateSerial(nTempYear, 3, e + f + 22 - 2) Ostermontag = DateSerial(nTempYear, 3, e + f + 22 + 1) Maifeiertag = DateSerial(nTempYear, 5, 1) ChrHimmelfahrt = DateSerial(nTempYear, 3, e + f + 22 + 39) Pfingstmontag = DateSerial(nTempYear, 3, e + f + 22 + 50) Fronleichnam = DateSerial(nTempYear, 3, e + f + 22 + 60) Friedensfest = DateSerial(nTempYear, 8, 8) MarieaHimmelfahrt = DateSerial(nTempYear, 8, 15) Weltkindertag = DateSerial(nTempYear, 9, 20) Tagdereinheit = DateSerial(nTempYear, 10, 3) Reformationstag = DateSerial(nTempYear, 10, 31) Allerheiligen = DateSerial(nTempYear, 11, 1) BussUndBettag = DateSerial(nTempYear, 12, 25) - Weekday(DateSerial(nTempYear, 12, 25), vbMonday) - 4 * 7 - vbWednesday Weihnachten1 = DateSerial(nTempYear, 12, 25) Weihnachten2 = DateSerial(nTempYear, 12, 26) ' Is public holiday? select case vTempDate case Neujahr bReturn = True case Erscheinungsfest if (nFederalState and (vb_FS_BW or vb_FS_BY or vb_FS_BYMH or vb_FS_ST)) then bReturn = True case Weltfrauentag if (nFederalState and (vb_FS_BE)) then bReturn = True case Ostersonntag bReturn = True case Rosenmontag If(nFederalState and (vb_FS_KD)) then bReturn = True case Karfreitag bReturn = True case Ostermontag bReturn = True case Maifeiertag bReturn = True case ChrHimmelfahrt bReturn = True case Pfingstmontag bReturn = True case Fronleichnam if (nFederalState and (vb_FS_BW or vb_FS_BY or vb_FS_BYMH or vb_FS_HE or vb_FS_NW or vb_FS_RP or vb_FS_SL)) then bReturn = True case Friedensfest If(nFederalState and (vb_FS_AU)) then bReturn = True case MarieaHimmelfahrt if (nFederalState and (vb_FS_BYMH or vb_FS_SL)) then bReturn = True case Weltkindertag if (nFederalState and (vb_FS_TH)) then bReturn = True case Tagdereinheit bReturn = True case Reformationstag if (nFederalState and (vb_FS_BB or vb_FS_HB or vb_FS_HH or vb_FS_MV or vb_FS_NI or vb_FS_SN or vb_FS_ST or vb_FS_SH or vb_FS_TH)) then bReturn = True case Allerheiligen if (nFederalState and (vb_FS_BW or vb_FS_BY or vb_FS_BYMH or vb_FS_NW or vb_FS_RP or vb_FS_SL)) then bReturn = True case BussUndBettag if (nFederalState and (vb_FS_SN)) then bReturn = True case Weihnachten1 bReturn = True case Weihnachten2 bReturn = True end select IsPublicHolidayDE = bReturn PBXScript.OutputTrace "bReturn = " & bReturn PBXScript.OutputTrace "<------- IsPublicHolidayDE" End Function The first parameter of the function is either one or a list federal states (linked by OR). See the above code for the possible values for each federal state. The second parameter is the date to check. This can either be a VBScript variant type (like e.g. Now returns or have been loaded from a database field of type datetime) or a string representing the date to be checked. Please note that in this case the string must be a valid date according the the regional settings configuration of your server machine (in regard to is format). Examples Check in Nordrhein-Westfalen for current date: IsPublicHolidayDE(vb_FS_NW, "") IsPublicHolidayDE(vb_FS_NW, Now) Check in Bayern and Saarland for a given fixed date: IsPublicHolidayDE(vb_FS_BY or vb_FS_SL, "01.05.2015") This function was provided by the well known forum user JoergG. This function was initially posted into this forum topic.
  25. VBScript This function checks a given date for a public holiday in Austria. It takes the different federal states into consideration. Please see the Introduction chapter for some usage instructions. '------------------------------------------------------------------- ' Feiertagsüberprüfung Österreich ' ' Author: Dominik Kronsteiner (PCH IT Solution GmbH - www.pch.at) ' ' Version: v1.1 - 2019-09-05 '------------------------------------------------------------------- ' Österreich const vb_FS_NO = 1 ' Niederösterreich const vb_FS_OO = 2 ' Oberösterreich const vb_FS_WI = 4 ' Wien const vb_FS_SM = 8 ' Steiermark const vb_FS_KA = 16 ' Kärnten const vb_FS_BU = 32 ' Burgenland const vb_FS_SA = 64 ' Salzburg const vb_FS_TI = 128 ' Tirol const vb_FS_VO = 256 ' Vorarlberg '------------------------------------------------------------------- ' Name: IsPublicHolidayAT ' ================= ' ' Returns true if the given date is a public holiday in the given Austrian ' federal state. Multiple federal states can be combined with "OR" ' ' Parameter: ' nFederalState single or combination of federal states ' vCheckDate vbscript date to check (e.g. as returned by now) or ' "" (for current date) ' ' Returns: ' Boolean True = is public holiday ' '-------------------------------------------------------------------- Function IsPublicHolidayAT ( nFederalState, vCheckDate ) On Error Resume Next PBXScript.OutputTrace "Holiday - -------> IsPublicHolidayAT" PBXScript.OutputTrace "Holiday - nFederalState = " & nFederalState PBXScript.OutputTrace "Holiday - vCheckDate = " & vCheckDate Dim bReturn bReturn = False Dim sReturn sReturn = "No Holiday Found" Dim a, b, c, d, e, f Dim nTempYear, vTempDate Dim Neujahr, dreiKoenige, Josef, Karfreitag, Ostersonntag, Ostermontag Dim Staatsfeiertag, Florian, ChrHimmelfahrt, Pfingstmontag, Fronleichnam Dim MarieaeHimmelfahrt, Rupert, TagderVolksabstimmung, Nationalfeiertag Dim Allerheiligen, Martin, Leopold, MariaeEmpfaengnis, HeiligAbend, Christtag, Stefanitag, Silvester if not IsDate(vCheckDate) then vCheckDate = Now vTempDate = DateSerial(Year(vCheckDate), Month(vCheckDate), Day(vCheckDate)) nTempYear = Year(vTempDate) PBXScript.OutputTrace "Holiday - Using nTempYear = " & nTempYear PBXScript.OutputTrace "Holiday - Using vTempDate = " & vTempDate ' Gauß Formel a = nTempYear Mod 19 b = nTempYear \ 100 c = (8 * b + 13) \ 25 - 2 d = b - (nTempYear \ 400) - 2 e = (19 * (nTempYear Mod 19) + ((15 - c + d) Mod 30)) Mod 30 if e = 28 then if a > 10 then e = 27 end if elseif e = 29 then e = 28 end if f = (d + 6 * e + 2 * (nTempYear Mod 4) + 4 * (nTempYear Mod 7) + 6) Mod 7 ' Feiertage konfigurieren Neujahr = DateSerial(nTempYear, 1, 1) dreiKoenige = DateSerial(nTempYear, 1, 6) Josef = DateSerial(nTempYear, 3, 19) Karfreitag = DateSerial(nTempYear, 3, e + f + 22 - 2) Ostersonntag = DateSerial(nTempYear, 3, e + f + 22) Ostermontag = DateSerial(nTempYear, 3, e + f + 22 + 1) Staatsfeiertag = DateSerial(nTempYear, 5, 1) Florian = DateSerial(nTempYear, 5, 4) ChrHimmelfahrt = DateSerial(nTempYear, 3, e + f + 22 + 39) Pfingstmontag = DateSerial(nTempYear, 3, e + f + 22 + 50) Fronleichnam = DateSerial(nTempYear, 3, e + f + 22 + 60) MarieaeHimmelfahrt = DateSerial(nTempYear, 8, 15) Rupert = DateSerial(nTempYear, 9, 24) TagderVolksabstimmung = DateSerial(nTempYear, 10, 10) Nationalfeiertag = DateSerial(nTempYear, 10, 26) Allerheiligen = DateSerial(nTempYear, 11, 1) Martin = DateSerial(nTempYear, 11, 11) Leopold = DateSerial(nTempYear, 11, 15) MariaeEmpfaengnis = DateSerial(nTempYear, 12, 8) HeiligAbend = DateSerial(nTempYear, 12, 24) Christtag = DateSerial(nTempYear, 12, 25) Stefanitag = DateSerial(nTempYear, 12, 26) Silvester = DateSerial(nTempYear, 12, 31) ' Feiertag? select case vTempDate case Neujahr bReturn = True sReturn = "Neujahr" case dreiKoenige bReturn = True sReturn = "dreiKoenige" case Karfreitag bReturn = True sReturn = "Karfreitag" case Ostermontag bReturn = True sReturn = "Ostermontag" case Staatsfeiertag bReturn = True sReturn = "Staatsfeiertag" case ChrHimmelfahrt bReturn = True sReturn = "ChrHimmelfahrt" case Pfingstmontag bReturn = True sReturn = "Pfingstmontag" case Fronleichnam bReturn = True sReturn = "Fronleichnam" case MarieaeHimmelfahrt bReturn = True sReturn = "MarieaeHimmelfahrt" case Nationalfeiertag bReturn = True sReturn = "Nationalfeiertag" case Allerheiligen bReturn = True sReturn = "Allerheiligen" case MariaeEmpfaengnis bReturn = True sReturn = "MariaeEmpfaengnis" case HeiligAbend bReturn = True sReturn = "HeiligAbend" case Christtag bReturn = True sReturn = "Christtag" case Stefanitag bReturn = True sReturn = "Stefanitag" case Silvester bReturn = True sReturn = "Silvester" case Josef if (nFederalState and (vb_FS_KA or vb_FS_SM or vb_FS_TI or vb_FS_VO or vb_FS_WI)) then bReturn = True sReturn = "Josef" case Florian if (nFederalState and (vb_FS_OO)) then bReturn = True sReturn = "Florian" case Rupert if (nFederalState and (vb_FS_SA)) then bReturn = True sReturn = "Rupert" case TagderVolksabstimmung if (nFederalState and (vb_FS_KA)) then bReturn = True sReturn = "TagderVolksabstimmung" case Martin if (nFederalState and (vb_FS_BU)) then bReturn = True sReturn = "Martin" case Leopold if (nFederalState and (vb_FS_NO or vb_FS_WI)) then bReturn = True sReturn = "Leopold" end select IsPublicHolidayAT = bReturn PBXScript.OutputTrace "Holiday - bReturn = " & bReturn PBXScript.OutputTrace "Holiday - " & sReturn PBXScript.OutputTrace "Holiday - <------- IsPublicHolidayAT" End Function The first parameter of the function is either one or a list federal states (linked by OR). See the above code for the possible values for each federal state. The second parameter is the date to check. This can either be a VBScript variant type (like e.g. Now returns or have been loaded from a database field of type datetime) or a string representing the date to be checked. Please note that in this case the string must be a valid date according the the regional settings configuration of your server machine (in regard to is format). Examples Check in Wien for current date: IsPublicHolidayAT(vb_FS_WI, "") IsPublicHolidayAT(vb_FS_WI, Now) Check in Kärnten and Tirol for a fixed given date: IsPublicHolidayAT(vb_FS_KA or vb_FS_TI, "01.05.2015") This function is based on the initial version IsPublicHolidayDE written by JoergG. kroni99 has created a new version to check for public holidays in Austria. This function was initially posted into this forum topic.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and have taken note of our Privacy Policy.
We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.