Jump to content

- PBXScript

- # PBXScript.PreviousScripts()

  Followers 0

  Lua → VBScript SwxWare v13.10

  This function returns a list (indexed table) with information about all call routing scripts the call was in before reaching the current one.

      local tScripts = PBXScript.PreviousScripts()

  This function returns an indexed table with the following content per entry:

  - userid (obsolete from SwyxWare v13.27, contains valid value for user scripts only)
  - username (obsolete from SwyxWare v13.27, contains valid value for user scripts only)
  - entitytype (new from SwyxWare v13.27)
  - either PBXScriptTypeUser or PBXScriptTypeGroup
  - entityid (new from SwyxWare v13.27)
    number value containing the SwyxWare interal id of user or user group
  - entityname (new from SwyxWare v13.27)
    string value containing the name of user or user group
  - start
  - end

      [
          {
              .userid   : number
              .username : string
              .entitytype : number
              .entityid   : number
              .entityname : string
              .start      : {
                              .sec   : number
                              .min   : number
                              .hour  : number
                              .day   : number
                              .month : number
                              .year  : number
                              .wday  : number
                              .yday  : number
                              .isdst : boolean
                          }
              .finish     : {
                              .sec   : number
                              .min   : number
                              .hour  : number
                              .day   : number
                              .month : number
                              .year  : number
                              .wday  : number
                              .yday  : number
                              .isdst : boolean
                          }
          }
      ]

  Please note, that the date and time is given in Universal Time Coordinated (UTC), so it comes without any daylight savin time problems.

  The follwing example lists all available information into the Server trace file:

      local tScripts  = nil
      tScripts = PBXScript.PreviousScripts()
      if (tScripts ~= nil) then
          for i = 1, #tScripts do

              -- til SwyxWare v13.26
              PBXScript.OutputTrace("UserId: "       .. tScripts[i].userid)
              PBXScript.OutputTrace("UserName: "     .. tScripts[i].username)

              -- from SwyxWare v13.27
              PBXScript.OutputTrace("EntityType: "   .. tScripts[i].entitytype)
              PBXScript.OutputTrace("EntityId : "    .. tScripts[i].entityid)
              PBXScript.OutputTrace("EntityName : "  .. tScripts[i].entityname)

              PBXScript.OutputTrace("StartTime: "    .. AddLeadingZeros(tScripts[i].start.day,    2) .. "." ..
                                                        AddLeadingZeros(tScripts[i].start.month,  2) .. "." ..
                                                        AddLeadingZeros(tScripts[i].start.year,   4) .. " " ..
                                                        AddLeadingZeros(tScripts[i].start.hour,   2) .. ":" ..
                                                        AddLeadingZeros(tScripts[i].start.min,    2) .. ":" ..
                                                        AddLeadingZeros(tScripts[i].start.sec,    2))
              PBXScript.OutputTrace("EndTime: "      .. AddLeadingZeros(tScripts[i].finish.day,   2) .. "." ..
                                                        AddLeadingZeros(tScripts[i].finish.month, 2) .. "." ..
                                                        AddLeadingZeros(tScripts[i].finish.year,  4) .. " " ..
                                                        AddLeadingZeros(tScripts[i].finish.hour,  2) .. ":" ..
                                                        AddLeadingZeros(tScripts[i].finish.min,   2) .. ":" ..
                                                        AddLeadingZeros(tScripts[i].finish.sec,   2))
          end
      end

  This example makes use of the string helper function AddLeadingZeros() from the GSE build-in helper functions.

  Resulting trace lines if call was forwarded by one previous user:

      Til SwyxWare v13.26

      04 18:18:23.840 001e70 Info SrvScript  0942A7E8 00000084 SPBXScriptLua::OutputTrace  () UserId: 20
      04 18:18:23.840 001e70 Info SrvScript  0942A7E8 00000084 SPBXScriptLua::OutputTrace  () UserName: Erika Mustermann
      04 18:18:23.840 001e70 Info SrvScript  0942A7E8 00000084 SPBXScriptLua::OutputTrace  () StartTime: 04.06.2022 16:18:00
      04 18:18:23.840 001e70 Info SrvScript  0942A7E8 00000084 SPBXScriptLua::OutputTrace  () EndTime: 04.06.2022 16:18:20

      From SwyxWare v13.27
      04 18:18:23.840 001e70 Info SrvScript  0942A7E8 00000084 SPBXScriptLua::OutputTrace  () EntityType: 1
      04 18:18:23.840 001e70 Info SrvScript  0942A7E8 00000084 SPBXScriptLua::OutputTrace  () EntityId: 20
      04 18:18:23.840 001e70 Info SrvScript  0942A7E8 00000084 SPBXScriptLua::OutputTrace  () EntityName: Erika Mustermann
      04 18:18:23.840 001e70 Info SrvScript  0942A7E8 00000084 SPBXScriptLua::OutputTrace  () StartTime: 04.06.2022 16:18:00
      04 18:18:23.840 001e70 Info SrvScript  0942A7E8 00000084 SPBXScriptLua::OutputTrace  () EndTime: 04.06.2022 16:18:20

  Examples from the Function Collection

  - IsCallTransferred()
  - IsRedirectedFromByName() (til SwyxWare v13.26)
  - IsRedirectedFromByNameEx() (from SwyxWare v13.27)
  - IsRedirectionLoopConfigured()

  By Tom Wellige

  - May 22, 2022
  Share
  Share
  Followers 0

## 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.