Jump to content
  • IsRedirectedFromByNumber()

    IsRedirectedFromByNumber()

    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.
     

     


    Tom Wellige
     Share


     Share




    User Feedback

    Recommended Comments

    There are no comments to display.



    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now
×
×
  • 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.