Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Announcements

Welcome to Cisco Support Community. We would love to have your feedback.

For an introduction to the new site, click here. And see here for current known issues.

New Member

Number matching with XML for setting priority

Dear Anthony,

I am trying write a simple script which I need to accomplish the following.

If the calling number ( Customer Number) XXXXXXXX, I should check this number in an XML file and if it is there I need to set priority for that number 10 other wise the number will get default priority in the que. I have UCCX enhanced. I am having morethan 100 numbers.

Will you please put a light on this.

2 ACCEPTED SOLUTIONS

Accepted Solutions

Re: Number matching with XML for setting priority

I have a couple of options here for you.  Let me know if you have any trouble making them work.

Option A - Check a local variable of type HashMap, for the calling number's priority

Variables

String calling_number = ""

java.util.HashMap vip_numbers_map =

{

     java.util.HashMap vip_numbers_map = new java.util.HashMap();

     vip_numbers_map.put("6125551000", 10);

     vip_numbers_map.put("6125552000", 5);

     return vip_numbers_map;

}

Script

Start

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

If (vip_numbers_map.containsKey(calling_number))

     True

          Set Priority (--Triggering Contact--, Assign: (int) vip_numbers_map.get(calling_number))

     False

          /* Leave at default priority of 1 */

End

Option B - Check a flat file in the document repository for the calling number's priority

Document

Filename:

 vip_numbers.csv

Contents:

6125551000,10

6125552000,5

Variables

String calling_number = ""

String[] vip_numbers_array = null

Document vip_numbers_doc = DOC[vip_numbers.csv]

java.util.HashMap vip_numbers_map = new java.util.HashMap()

String vip_numbers_string = ""

Script

Start

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

Set vip_numbers_string = vip_numbers_doc

Set vip_numbers_array = vip_numbers_string.split("\r\n")

Do {

     int i;

     int j = vip_numbers_array.length;

     String[] vip_number_entry;

     for (i = 0; i < j; i++) {

          vip_number_entry = vip_numbers_array[i].split(",");

          vip_numbers_map.put(vip_number_entry[0], vip_number_entry[1]);

     }

}

If (vip_numbers_map.containsKey(calling_number))

     True

          Set Priority (--Triggering Contact--, Assign: (int) vip_numbers_map.get(calling_number))

     False

          /* Leave at default priority of 1 */

End

Option C - Check a flat file on an external web server for the calling number's priority

Document

Filename:

vip_numbers.csv

Contents:

6125551000,10

6125552000,5

Variables

String calling_number = ""

String[] vip_numbers_array = null

Document vip_numbers_doc = URL[http://1.1.1.1/uccx/vip_numbers.csv]

java.util.HashMap vip_numbers_map = new java.util.HashMap()

String vip_numbers_string = ""

Script

Start

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

Set vip_numbers_string = vip_numbers_doc

Set vip_numbers_array = vip_numbers_string.split("\r\n")

Do {

     int i;

     int j = vip_numbers_array.length;

     String[] vip_number_entry;

     for (i = 0; i < j; i++) {

          vip_number_entry = vip_numbers_array[i].split(",");

          vip_numbers_map.put(vip_number_entry[0], vip_number_entry[1]);

     }

}

If (vip_numbers_map.containsKey(calling_number))

     True

          Set Priority (--Triggering Contact--, Assign: (int) vip_numbers_map.get(calling_number))

     False

          /* Leave at default priority of 1 */

End

Option D - Check an XML document in the document repository for the calling number's priority

Document

Filename:

vip_numbers.xml

Contents:

    

          6125551000

          10

    

    

          6125552000

          5

    

Variables

String calling_number = ""

Document vip_numbers_doc = DOC[vip_numbers.xml]

String xpath_priority = ""

String xpath_result = ""

int vip_priority = 0

Script

Start

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

Set xpath_priority = "//calling_number[number='" + calling_number + "']/priority"

vip_numbers_doc = Create XML Document (vip_numbers_doc)

xpath_result = Get XML Document Data (vip_numbers_doc, xpath_priority)

If (xpath_result != null && xpath_result.trim() != "")

     True

          Set vip_priority = Integer.parseInt(xpath_result)

          Set Priority (--Triggering Contact--, Assign: vip_priority)

     False

     /* Leave at default priority of 1 */

End

Option E - Check an XML document on an external web server for the calling number's priority

Document

Filename:

vip_numbers.xml

Contents:

    

          6125551000

          10

    

    

          6125552000

          5

    

Variables

String calling_number = ""

Document vip_numbers_doc = URL[http://1.1.1.1/uccx/vip_numbers.xml]

String xpath_priority = ""

String xpath_result = ""

int vip_priority = 0

Script

Start

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

Set xpath_priority = "//calling_number[number='" + calling_number + "']/priority"

vip_numbers_doc = Create XML Document (vip_numbers_doc)

xpath_result = Get XML Document Data (vip_numbers_doc, xpath_priority)

If (xpath_result != null && xpath_result.trim() != "")

     True

          Set vip_priority = Integer.parseInt(xpath_result)

          Set Priority (--Triggering Contact--, Assign: vip_priority)

     False

          /* Leave at default priority of 1 */

End

Anthony Holloway

Please use the star ratings to help drive great content to the top of searches.

Re: Number matching with XML for setting priority

No problem.  Let's see if we can work through them.

  1. Create a new variable.  In the drop down list for Type, just enter the text java.util.HashMap with your keyboard.  Next, set the name to vip_numbers.  Lastly, in the value field, enter the text new java.util.HashMap().
  2. When you drag in an if step, you:
    1. Rright click it and select properties on it to set the condition you wish to test. E.g., 3 > 2
    2. Drag other steps into the True and False branch
Anthony Holloway

Please use the star ratings to help drive great content to the top of searches.
14 REPLIES

Number matching with XML for setting priority

Hello,

Thanks for posting your question to the forums.

Before we get into a solution (which I promise we'll get to), let's dsicover a few more things about your project.

  1. What do you want the script to do, if the calling number is unavailable?
  2. Is there a specific requirement to use an XML document, or is your project flexible enough to use another method?  Say a HashMap variable?
  3. Is the priority always going to be a 10, for every number in the list? Or could some numbers have a priorty 5, while another has priority 3?
  4. Who will be updating the list of numbers, or how do you plan to keep the numbers list up to date?

Looking forward to your reply,

Anthony

Anthony Holloway

Please use the star ratings to help drive great content to the top of searches.
New Member

Number matching with XML for setting priority

1. Send to default priority 1

2. It is not mandatory to use XML file, but I was thinking if the contact center supervisor wants to update the list it is    easy    for him to edit the xml file.

3. No we want to put different priorty lets say Group A 10 Group B 5 Group C 3 No matching ?(Default) 1

4. Contact center supervisor.

Number matching with XML for setting priority

Thanks for the quick reply.

  1. This sounds like a good plan.
  2. Will you store the XML file on UCCX (document repo), or on an external web server?  Also, do you trust that they will keep the XML document's integrity?  One small typo could render the whole solution invalid.  Another option would be to simply maintain a list of numbers, one per line, such that a typo would only render that one line invalid, and not the whole file.  What do you think about that?
  3. Sounds good
  4. Depending on your reply to #2, I may have another question for you on this point.
Anthony Holloway

Please use the star ratings to help drive great content to the top of searches.
New Member

Number matching with XML for setting priority

I think maintain a list of numbers is fine with me. We are having only one CSQ.

I am also intrested how the XML scenario works ( can discuss later)

Re: Number matching with XML for setting priority

I have a couple of options here for you.  Let me know if you have any trouble making them work.

Option A - Check a local variable of type HashMap, for the calling number's priority

Variables

String calling_number = ""

java.util.HashMap vip_numbers_map =

{

     java.util.HashMap vip_numbers_map = new java.util.HashMap();

     vip_numbers_map.put("6125551000", 10);

     vip_numbers_map.put("6125552000", 5);

     return vip_numbers_map;

}

Script

Start

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

If (vip_numbers_map.containsKey(calling_number))

     True

          Set Priority (--Triggering Contact--, Assign: (int) vip_numbers_map.get(calling_number))

     False

          /* Leave at default priority of 1 */

End

Option B - Check a flat file in the document repository for the calling number's priority

Document

Filename:

 vip_numbers.csv

Contents:

6125551000,10

6125552000,5

Variables

String calling_number = ""

String[] vip_numbers_array = null

Document vip_numbers_doc = DOC[vip_numbers.csv]

java.util.HashMap vip_numbers_map = new java.util.HashMap()

String vip_numbers_string = ""

Script

Start

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

Set vip_numbers_string = vip_numbers_doc

Set vip_numbers_array = vip_numbers_string.split("\r\n")

Do {

     int i;

     int j = vip_numbers_array.length;

     String[] vip_number_entry;

     for (i = 0; i < j; i++) {

          vip_number_entry = vip_numbers_array[i].split(",");

          vip_numbers_map.put(vip_number_entry[0], vip_number_entry[1]);

     }

}

If (vip_numbers_map.containsKey(calling_number))

     True

          Set Priority (--Triggering Contact--, Assign: (int) vip_numbers_map.get(calling_number))

     False

          /* Leave at default priority of 1 */

End

Option C - Check a flat file on an external web server for the calling number's priority

Document

Filename:

vip_numbers.csv

Contents:

6125551000,10

6125552000,5

Variables

String calling_number = ""

String[] vip_numbers_array = null

Document vip_numbers_doc = URL[http://1.1.1.1/uccx/vip_numbers.csv]

java.util.HashMap vip_numbers_map = new java.util.HashMap()

String vip_numbers_string = ""

Script

Start

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

Set vip_numbers_string = vip_numbers_doc

Set vip_numbers_array = vip_numbers_string.split("\r\n")

Do {

     int i;

     int j = vip_numbers_array.length;

     String[] vip_number_entry;

     for (i = 0; i < j; i++) {

          vip_number_entry = vip_numbers_array[i].split(",");

          vip_numbers_map.put(vip_number_entry[0], vip_number_entry[1]);

     }

}

If (vip_numbers_map.containsKey(calling_number))

     True

          Set Priority (--Triggering Contact--, Assign: (int) vip_numbers_map.get(calling_number))

     False

          /* Leave at default priority of 1 */

End

Option D - Check an XML document in the document repository for the calling number's priority

Document

Filename:

vip_numbers.xml

Contents:

    

          6125551000

          10

    

    

          6125552000

          5

    

Variables

String calling_number = ""

Document vip_numbers_doc = DOC[vip_numbers.xml]

String xpath_priority = ""

String xpath_result = ""

int vip_priority = 0

Script

Start

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

Set xpath_priority = "//calling_number[number='" + calling_number + "']/priority"

vip_numbers_doc = Create XML Document (vip_numbers_doc)

xpath_result = Get XML Document Data (vip_numbers_doc, xpath_priority)

If (xpath_result != null && xpath_result.trim() != "")

     True

          Set vip_priority = Integer.parseInt(xpath_result)

          Set Priority (--Triggering Contact--, Assign: vip_priority)

     False

     /* Leave at default priority of 1 */

End

Option E - Check an XML document on an external web server for the calling number's priority

Document

Filename:

vip_numbers.xml

Contents:

    

          6125551000

          10

    

    

          6125552000

          5

    

Variables

String calling_number = ""

Document vip_numbers_doc = URL[http://1.1.1.1/uccx/vip_numbers.xml]

String xpath_priority = ""

String xpath_result = ""

int vip_priority = 0

Script

Start

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

Set xpath_priority = "//calling_number[number='" + calling_number + "']/priority"

vip_numbers_doc = Create XML Document (vip_numbers_doc)

xpath_result = Get XML Document Data (vip_numbers_doc, xpath_priority)

If (xpath_result != null && xpath_result.trim() != "")

     True

          Set vip_priority = Integer.parseInt(xpath_result)

          Set Priority (--Triggering Contact--, Assign: vip_priority)

     False

          /* Leave at default priority of 1 */

End

Anthony Holloway

Please use the star ratings to help drive great content to the top of searches.
New Member

Number matching with XML for setting priority

Thanku very much I will try and get back to you.

Number matching with XML for setting priority

What a great posts Anthony

I was trying to write just 3 or 4-lines in java to deal with java custom methods

only do you recommend me a training course to be good in this part. I mean to be good in calling java methods or to write xml

Regards

Haitham

Number matching with XML for setting priority

@hythamhadad: I don't have a good answer for you.  There's the programming guides for UCCX on cisco.com, and the get into some pretty tricky Java stuff.  Maybe just there.  The volume 3 gets intense!  Thanks for the positive review.  Don't forget to rate the posts you find helpful, with the star ratings.  Thanks again, and good luck.

Anthony Holloway

Please use the star ratings to help drive great content to the top of searches.
New Member

Number matching with XML for setting priority

Dear Anthony,

I have some script writing issue.

1. On Option B how can I add " java.util.HashMap vip_numbers_map = new java.util.HashMap() " variables.

2. In the XML option How the IF statment to added. When I put IF it ends with Then and I cannot add anything under True/

I am really sorry to ask you this, I am not at all a programmer, just learning only.

Re: Number matching with XML for setting priority

No problem.  Let's see if we can work through them.

  1. Create a new variable.  In the drop down list for Type, just enter the text java.util.HashMap with your keyboard.  Next, set the name to vip_numbers.  Lastly, in the value field, enter the text new java.util.HashMap().
  2. When you drag in an if step, you:
    1. Rright click it and select properties on it to set the condition you wish to test. E.g., 3 > 2
    2. Drag other steps into the True and False branch
Anthony Holloway

Please use the star ratings to help drive great content to the top of searches.
New Member

Number matching with XML for setting priority

Thank you very much, I manged to finisht script with your help, I will try this on saturday as we have week end now

New Member

Number matching with XML for setting priority

Thank you very much Its help me a lot. It was a great support.

Regards

Toms

Re: Number matching with XML for setting priority

I'm glad to know you were able to get it working.

I'm also curious to know which option you feel meets your needs the best?

Sent from Cisco Technical Support iPhone App

Anthony Holloway

Please use the star ratings to help drive great content to the top of searches.
New Member

Number matching with XML for setting priority

I use the option B with csv in repository, because it is quite easy for updating the numbers as we have more than 100+ priority users. My ultimate goal will be placing the file in the webserver or a shared folder in the network. That is our option C.

I am learning, Thank you for the support

706
Views
15
Helpful
14
Replies
CreatePlease login to create content