# java within script

Jan 5th, 2009

I need to be able to route a call to six different dealers on a weekly rotation. I came up with a script that performs that, but the order of the java within the script will not recognize the first 6 weeks of the year. I am posting a strip down version of the script so you can see where it is failing.

Please, any help on how to correct the script or better examples on how to accomplish this task would be greatly appreciated.

~Jeff

Attachment:
Correct Answer by CHRIS CHARLEBOIS about 7 years 9 months ago

I, like everyone else here, am no Java expert, but what you are trying to acomplish is a simple modulus operation. I think there is a mod function, but I don't know if it's available.

Assuming that you define the variables as integers..

X = weekOfYear/6;

Y = X * 6;

Z = weekOfYear - Y;

If Z==0 return dealer1;

if Z==1 return dealer2;

if Z==2 return dealer3;

This way, there needs to be no recursion.

Overall Rating: 5 (1 ratings)

## Replies

m.jilderda Wed, 01/07/2009 - 00:53

Hi Latigo,

was just looking at your script. I'm no Java expert, but if I'm correct you are doing the following:

while (CJ <= 52)

{

CJ = (CJ += 6);

if (CJ == weekOfYear) {

return C;

}

This means that you are always adding 6 to the variable CJ. The statement CJ += 6 means the same as CJ = CJ + 6. Assuming that there's a weeknumber in the var CJ, this will never work for the first 6 weeks?

If you'd switch around the sequence like this:

while (CJ <= 52)

{

if (CJ == weekOfYear) {

return C;

CJ = (CJ += 6);

}

it would work?

Just my 2 cents, maybe it helps a little.

Jeff Thompson Wed, 01/07/2009 - 06:35

jildera - Many thanks for your post. I am no java expert as well. I had come up with a very similar version of your example script, the thing is is I need to be able to continue the script on with 'else' statements, essentially checking all my dealer veriable 'CJ', 'HON' ect. but when I add the 'else' statement I keep getting the error "else with out if" Maybe I didn't have the curly braces { } in the right part of the code, but I have tried just about every combination I could think. Any other thoughts?

m.jilderda Wed, 01/07/2009 - 07:08

Ah right,

the syntax of the java statement was not correct. This seems to work in my CRS Editor:

Ofcourse add the rest of the dealers..

{

while (CJ <= 52)

{

if (CJ == weekOfYear) {

return C;

} else {

CJ = (CJ += 6);

}

if (TOY <=52) {

return T;

} else {

TOY = (TOY +=6);

}

}

}

Jeff Thompson Wed, 01/07/2009 - 13:08

Thanks, it is so close. When I apply this code and then run it on my lab IPCC server where I can change the date - It looks like it only runs through the script one time because when you debug and change the date to reflect say week 13 in the CJ variable it changes to 7 and that is only one iteration of

CJ = (CJ +=6);

CHRIS CHARLEBOIS Wed, 01/07/2009 - 13:26

I, like everyone else here, am no Java expert, but what you are trying to acomplish is a simple modulus operation. I think there is a mod function, but I don't know if it's available.

Assuming that you define the variables as integers..

X = weekOfYear/6;

Y = X * 6;

Z = weekOfYear - Y;

If Z==0 return dealer1;

if Z==1 return dealer2;

if Z==2 return dealer3;

This way, there needs to be no recursion.

Jeff Thompson Wed, 01/07/2009 - 14:24

Very nice! That did it. Thanks to both of you for all your help...

mwilson706 Thu, 05/28/2009 - 05:58

Hi Jeff,

I'm trying to accomplish the same thing with an oncall rotation. I was wondering if you'd upload another sample of your working .aef? I was trying to follow the thread but the modulus function post was way over my head. Any response would be greatly appreciated.

## Trending Topics: Contact Center

 uccx call recording uccx system prompts Cisco cusp Cisco uccx high cpu Cisco uninstall error 28007 Cisco vpn client error 1720 Cisco agent login failed configuration error Cisco jabber login failed