Jump to content
  • IsRedirectionLoopConfigured

    IsRedirectionLoopConfigured

    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.

     

     


    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.