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

Set variables with data of varying lengths?

I am sending data collected from a CVP application back to ICM in the array variable user.microapp.FromExtVXML(0).  Now I want to parse the data and put it into ECC Variables.  I can do all this but one issue:  how do I handle data that can have varying lengths?   For example, the first piece of data is an account number which can either be 7 or 10 digits.  Each piece of data is separated by a comma, so if I could extract using that as a separator, it would be ideal.

Here's an example to show you what the data looks like from the ECC:

1234567,1,G,Smith,Mary

=Account # (can be 7-10 digits), Authentication Flag (always 1 digit), Tier (always 1 digit), Last Name (varied length), First Name (varied length)

Appreciate your help on this.

Walter

Everyone's tags (6)
10 REPLIES

Re: Set variables with data of varying lengths?

I can't think of any way of doing it with your current format.  You're going to have to switch your string to be a key value pair.  E.g. Account=1234567,Flag=1,Tier=G,Last=Smith,First=Mary.

Then use this formula which takes the value pair you're looking for as a parameter and retrieves the data.  E.g. if you enter account, the formula returns 1234567, if you enter First it returns Mary.

if((find(%1%,Call.user.microapp.FromExtVXML[0]))>0,before(",",after(concatenate(%1%,"="),Call.user.microapp.FromExtVXML[0])),"Not Found"))))

david

Set variables with data of varying lengths?

Some further clarification.  The key value pair comes from CVP, you will have to change your CVP application to send the data in the format you're looking for.

As for the formula, you pass a parameter to it, "account", it then concatenates a "=" making your paremeter "account=", then it looks for this string in the FromExtVXML[0], once it finds it it will grab everything after the "=" and before the ",".  If the parameter is not found it returns "Not Found".

david

Community Member

Set variables with data of varying lengths?

Hi David:

You responded to my post and provided me the formula below. I have set up my "value pairs" in CVP so I can now see that the data sent from Studio is in the correct format (i.e.: FF=1234,LAST=Dickey, etc.). Now I'm trying to used the formula below to extract the data and set a variable with it in ICM. Two things: 1) I'm assuming that the "1" in the formula below is a placeholder and I should substitute the name of my "field" (i.e.: FF). 2) When I put the formula in the "value" section of the SET node, I get an error on the % sign. It says it's and "unexpected token". Is there something else I can use?

Where do you find references to writing this formulas anyway? Thanks for your help on this - I'm so close!

Walter

if((find(%1%,Call.user.microapp.FromExtVXML[0]))>0,before(",",after(concatenate(%1%,"="),Call.user.microapp.FromExtVXML[0])),"Not Found"))))

Set variables with data of varying lengths?

You need to put that formula into a custom formula, then use your set node with the following (example) PV2 = customformulaname("FF").  This will set PV2 as "1234".

david

Community Member

Set variables with data of varying lengths?

I created a custom function with the function exactly as you had given to me (below) and named it user_CVP_data:

if((find(%1%,Call.user.microapp.FromExtVXML[0]))>0,before(",",after(concatenate(%1%,"="),Call.user.microapp.FromExtVXML[0])),"Not Found"))))

Then I went into my SET node (where I'm setting the value of an ECC) and in the "value" section choose my new formula which shows up as user_CVP_data() - I altered it to: user_CVP_data("FF").  I get an error trying to save it "Misplaced right paren".

So close...

Green

Re: Set variables with data of varying lengths?

The way I usually do these complicated parsing operations is to simply use Call Tracer to send a dummy call through a test script. Have a SET node that sets up a test string into PV1 - say "Account=1234567,Flag=1,Tier=G,Last=Smith,First=Mary" (stay under 40) then feed it into a SET node that sets another PV using a formula, then have an IF node that tests the value of the PV against the expected result. No need to make a real call. Then keep fiddling with the formula in the SET node until you get it to sing and dance.

Once you understand how the if(), find(), after() etc functions all work and your SET node is working, you can easily turn it into a custom function and then try the custom function again with Call Tracer.

This is way faster than actually making calls through CVP. Many script writers try to develop the whole enchilada rather than taking the easy way out with Call Tracer.

Regards,

Geoff

Community Member

Set variables with data of varying lengths?

Thanks Geoff - that's a great suggestion and I'll do it that way - a lot easier.  However, where can I go to find to find some references as far as the symantics of the formula I'm writing?

Green

Set variables with data of varying lengths?

There is on-line help in your Script Editor for the functions like find().

It's a bit cryptic, and some good examples would help. But I don't know of any. I only know that I had to work it out for myself and it took a few goes. You'll figure it out.

Regards,

Geoff

Set variables with data of varying lengths?

Just by the eye ball test it looks like my formula has an extra ) at the end.  Remove it and try again.  Like Geoff said, the help file is not too bad and it's a great starting point, aside from that there's nothing else but trial and error.

david

Community Member

Set variables with data of varying lengths?

I FINALLY GOT IT!  A great way to start the weekend here in Australia.

My string is:

FF=55555555,PIN=1111,AUTH=1,TIER=G,LAST=Smith,FIRST=John

I'm setting an ECC value in a SET node with the Value:

after(("FF=",before(("PIN"),(Call.user.microapp.FromExtVXML[0])))

after(("PIN=",before(("AUTH"),(Call.user.microapp.FromExtVXML[0])))

etc...works great!

Thanks David and Geoff for your suggestions and pointing me in the right direction.  Have a nice weekend.

Walter

832
Views
7
Helpful
10
Replies
CreatePlease to create content