Jump to content
Tom Wellige

Function: GetUserNameFromExtension

Recommended Posts

This post is taken from the Swyx Forum Archive (2007-2014) and was originally posted 10.08.2010 by me

 

The following function returns the user name from a given extension.

It makes use of the PBXConfig object which is fully described in the following Swyx knowledgebase article:

Please note that it is not necessary to instantiate the PBXConfig object yourself, as it is already available in the global variable g_PBXConfig.
To use the function within your call routing script just copy&paste it into the "Start" block.

 

'----------------------------------------------------------------
' GetUserNameFromExtension
'
' Returns the user name for the given extension.
'
' Parameter:
'	sExtension		extension
'
' Return:
'	string			user name
'----------------------------------------------------------------
Function GetUserNameFromExtension(ByVal sExtension)
	PBXScript.OutputTrace "------> GetUserNameFromExtension ( " & sExtension & " )"
	 
	On Error Resume Next

	Dim sReturn
	sReturn = ""

	Dim oUSers
	Set oUsers = g_PBXConfig.GetUserByAddress(sExtension)
	If Err <> 0 Then
		PBXScript.OutputTrace "ERROR getting user from IpPBxSrv.PBXConfig object!"
		PBXScript.OutputTrace "ERROR: " & CStr(Hex(Err)) & " - " & Err.Description
		Exit Function
	End If
	 
	Dim oUser
	For Each oUser In oUsers
		PBXScript.OutputTrace "Name: " & oUser.Name
		sReturn = oUser.Name
	Next
	 
	GetUserNameFromExtension = sReturn

	PBXScript.OutputTrace "sReturn = " & sReturn
	PBXScript.OutputTrace "<------ GetUserNameFromExtension"
End Function

 

Examples for the usage of this function can be found in the functions IsRedirectedFromByNumber and IsRedirectionLoopConfigured.

 

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • 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.