cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
698
Views
0
Helpful
9
Replies

java within script

Jeff Thompson
Level 1
Level 1

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

1 Accepted Solution

Accepted Solutions

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.

View solution in original post

9 Replies 9

m.jilderda
Level 1
Level 1

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.

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?

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);

}

}

}

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);

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.

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

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.

sure not a problem. Hope this helps...

~Jeff

Thank you sir!

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: