cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Announcements
629
Views
5
Helpful
7
Replies
Highlighted

First and Last Name - Script

How can i extract first and last name of calling user once call lands on UCCX system. Our requirement is to get First name and last name of calling user and pass it to other application. I tried to use Get User field but it says- User ID is blank.

 

7 REPLIES 7
Highlighted
Beginner

Re: First and Last Name - Script

Take it that these are from internal calls where you have an End user in call manager?

 

If so you might need to do a lookup of sorts

 

dir_url String "http://xxx:8080/ccmcip/xmldirectorylist.jsp?n="  

Where xxx is your PUB 

calling_number String ""  

 

xml Document null  

 

calling_number = Get Call Contact Info (--Triggering Contact--, Calling Number)

XML = Create XML Document (URL[dir_url + calling_number])

calling_name = Get XML Document Data (xml, "//DirectoryEntry/Name")

Set Enterprise Call Info (--Trigger Contact--) Variables Used:calling_name,calling_number)

 

Hope this helps

Highlighted

Re: First and Last Name - Script

Thanks Tom. It seems that as output, we are receiving full name but we need first name and last name in separate variable. Is there option in xml directory to use first name as variable ?

Highlighted
Beginner

Re: First and Last Name - Script

Hmm

 

Not that I can think of off the top of my head, I did some digging and I am a bit stuck to come up a solution for that requirement as well. 

 

Maybe someone else here could advise, have to admit I am curious if that is possible as well now.

Highlighted
Participant

Re: First and Last Name - Script

You have a few issues in your logic.  First you will receive a "best match" of 32 directory entries from the CUCM directory if there is no explicit match on your directory number query.  If none of them match, your next Get XML step will fail, because it is returning a "null" response. 

Once you do have a matching response, you can parse the XML data from the array string using a Java .split().

I will try to attach the working code (not sure if the website will allow .aef attachments... but I will try.)

This is a working script, you just need to provide the inputs of your CUCM IP address and the ANI (calling number) you wish to query in the directory.

Sincerely,

Sean

2018-0820-uccxCallerName-solved.png

Highlighted
VIP Collaborator

Re: First and Last Name - Script

This is all I do - it pulls the calling name from the phone.

 

Set callingParty = {
java.lang.reflect.Field ciscoCallField = contact.getClass().getDeclaredField("ciscoCall");
ciscoCallField.setAccessible(true);
com.cisco.jtapi.extensions.CiscoCall ciscoCall = (com.cisco.jtapi.extensions.CiscoCall)ciscoCallField.get(contact);
return ciscoCall.getCurrentCallingPartyDisplayName();
}

 

Then under Select Resource, set enterprise call info and assign callingParty to a callvariable.

 

Internal calls are 100% reliable, but external of course rely on the carrier information that was sent.

Highlighted
Participant

Re: First and Last Name - Script

...the requirement was to be able to separate the First and Last name from the directory displayed name, in separate variables. Did you see that part?

:-)
Highlighted
Participant

Re: First and Last Name - Script

...I had some fun working with this, and created a script with some error handling for missing first name (last name is required for a directory entry, but first name is not--which produces a "null" error when trying to extract XML data from an empty set), multiple entries found (you will need to add your own logic for what to do when there is more than one user with the same dialed number), etc.

Use the interactive debugger to see what works for your requirements.

2018-0905-RetrieveFirstAndLastNm2.PNG

 

Enjoy!

Everyone's tags (2)