01-05-2009 03:04 PM - edited 03-14-2019 03:28 AM
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
Solved! Go to Solution.
01-07-2009 01:26 PM
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.
01-07-2009 12:53 AM
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.
01-07-2009 06:35 AM
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?
01-07-2009 07:08 AM
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);
}
}
}
01-07-2009 01:08 PM
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);
01-07-2009 01:26 PM
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.
01-07-2009 02:24 PM
Very nice! That did it. Thanks to both of you for all your help...
05-28-2009 05:58 AM
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.
05-28-2009 06:58 AM
05-28-2009 07:12 AM
Thank you sir!
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide