Jump to content

Graphic Switch Rule Issues


dleahy

Recommended Posts

Hello guys,

 

I am having a little bit of an issue here...

 

My goal is to return a letter of literal text if a specific graphic is chosen in a given field. Seems simple enough right.

 

Right now the switch rule I have isn't working and always returning the default case.

 

Do note that I am using Fusion Pro in connection with Marcom Central.

There is a field for every possible shoe (40 total)...

 

switch  (Field("SelectShoe1") || (Field("SelectShoe2") || (Field("SelectShoe3")  || (Field("SelectShoe4") || (Field("SelectShoe5") ||  (Field("SelectShoe6") || (Field("SelectShoe7") || (Field("SelectShoe8")  || (Field("SelectShoe9") || (Field("SelectShoe10") ||  (Field("SelectShoe11") || (Field("SelectShoe12") ||  (Field("SelectShoe13") || (Field("SelectShoe14") ||  (Field("SelectShoe15") || (Field("SelectShoe16") ||  (Field("SelectShoe17") || (Field("SelectShoe18") ||  (Field("SelectShoe19") || (Field("SelectShoe20") ||  (Field("SelectShoe1A") || (Field("SelectShoe2A") ||  (Field("SelectShoe3A") || (Field("SelectShoe4A") ||  (Field("SelectShoe5A") || (Field("SelectShoe6A") ||  (Field("SelectShoe7A") || (Field("SelectShoe8A") ||  (Field("SelectShoe9A") || (Field("SelectShoe10A") ||  (Field("SelectShoe11A") || (Field("SelectShoe12A") ||  (Field("SelectShoe13A") || (Field("SelectShoe14A") ||  (Field("SelectShoe15A") || (Field("SelectShoe16A") ||  (Field("SelectShoe17A") || (Field("SelectShoe18A") ||  (Field("SelectShoe19A") ||  (Field("SelectShoe20A")))))))))))))))))))))))))))))))))))))))))
{
case "Contour 54002":
return "A";
case "Contour 54038":
return "C";
case "Contour 54043":
return "B"
case "Contour 54051":
return "B";
case "Contour 54094":
return "A";
case "Contour 54102":
return "Z";
case "Contour 54111":
return "A";
case "Contour Casual 54238":
return "C";
case "Contour Casual 54251":
return "B";
case "Contour Casual 54275":
return "A";
case "Contour Casual 54356":
return "B";
case "Contour Casual 54363":
return "A";
case "Contour Casual 54371":
return "B";
case "Contour Casual 54389":
return "C";
case "Contour Casual 54397":
return "C";
case "DryJoys 99038":
return "A";
case "DryJoys 99045":
return "B";
case "DryJoys 99052":
return "A";
case "DryJoys Tour 53581":
return "A";
case "DryJoys Tour 53599":
return "C";
case "DryJoys Tour 53607":
return "B";
case "DryJoys Tour 53612":
return "A";
case "DryJoys Tour 53676":
return "A";
case "DryJoys Tour 53719":
return "B";
case "GreenJoy 45351":
return "C";
case "GreenJoy 45368":
return "C";
case "GreenJoy 45375":
return "C";
case "GreenJoy 45382":
return "C";
case "GreenJoy 45697":
return "S";
case "GreenJoys 48357":
return "B";
case "GreenJoys 48364":
return "B";
case "GreenJoys 48453":
return "S";
case "GreenJoys 48461":
return "S";
case "Icon 52005":
return "A";
case "Icon 52054":
return "A";
case "Icon 52108":
return "B";
case "Icon 52217":
return "C";
case "Icon 52245":
return "B";
case "Icon 52252":
return "Z";
case "Icon 52268":
return "Z";
case "Icon 52276":
return "B";
case "LoPro 97119":
return "A";
case "LoPro 97123":
return "B";
case "LoPro 97135":
return "C";
case "LoPro 97142":
return "B";
case "LoPro 97159":
return "B";
case "LoPro 97166":
return "C";
case "LoPro Casual 97065":
return "A";
case "LoPro Casual 97238":
return "C";
case "LoPro Casual 97261":
return "A";
case "LoPro Casual 97276":
return "A";
case "LoPro Casual 97292":
return "C";
case "M Project 95608":
return "A";
case "M Project 95615":
return "B";
case "M Project 95622":
return "B";
case "M Project 95634":
return "A";
case "M Project-Cleated 55108":
return "C";
case "M Project-Cleated 55116":
return "Z";
case "M Project-Cleated 55124":
return "A";
case "M Project-Cleated 55132":
return "B";
case "M Project-Cleated 55255":
return "A";
case "M Project-Spikeless 55206":
return "B";
case "M Project-Spikeless 55213":
return "C";
case "M Project-Spikeless 55221":
return "A";
case "M Project-Spikeless 55239":
return "Z";
case "M Project-Spikeless 55247":
return "B";
case "Sport 53203":
return "A";
case "Sport 53216":
return "Z";
case "Sport 53224":
return "B";
case "Sport 53247":
return "C";
case "Sport 53295":
return "B";
case "Sport Spikeless 53111":
return "A";
case "Sport Spikeless 53147":
return "C";
case "Sport Spikeless 53166":
return "C";
case "SuperLite 56732":
return "B";
case "SuperLite 58004":
return "A";
case "SuperLite 58012":
return "C";
case "SuperLites 98803":
return "A";
case "SuperLites 98811":
return "B";
case "SuperLites 98829":
return "C";
case "SuperLites 98837":
return "B";
case "SuperLites 98951":
return "A";
case "SuperLites CT 58118":
return "C";
case "SuperLites CT 58123":
return "C";
case "SuperLites CT 58135":
return "B";
default: return "B";
}

 

Any idea why this isn't working? All the images are named on Marcom Central just like the case value in the aforementioned rule.

Link to comment
Share on other sites

Normally, you would need to BREAK out of a switch loop to avoid executing the code following your specific case. However, in your code, the RETURN should theoretically do that for you. My guess is that there is a problem with using multiple fields (separated by an OR) in a single switch loop.

 

Is the idea that only one of the 40 fields can be populated with a value per record? If that is the case, I would first loop through all the sizes to find the one that is populated and then assign that to a variable. Then I would run the switch on the value of that variable:

 

for (var n=1; n<=40; n++) {
  var shoe = "SelectShoe";
  if (n<=20) shoe += n;
  else shoe += (n-20) + 'A';
  if (Field(shoe) != '') {
     var shoeStyle = Field(shoe);
     n = 40;
  }
}

switch  (shoeStyle) {
  case "Contour 54002":
  case "Contour 54094":
  case "Contour 54111":
  case "Contour Casual 54275":
  case "Contour Casual 54363":
  case "DryJoys 99038":
  case "DryJoys 99052":
  case "DryJoys Tour 53581":
  case "DryJoys Tour 53612":
  case "DryJoys Tour 53676":
  case "Icon 52005":
  case "Icon 52054":
  case "LoPro 97119":
  case "LoPro Casual 97065":
  case "LoPro Casual 97261":
  case "LoPro Casual 97276":
  case "SuperLites 98951":
  case "SuperLites 98803":
  case "SuperLite 58004":
  case "Sport Spikeless 53111":
  case "Sport 53203":
  case "M Project-Spikeless 55221":
  case "M Project-Cleated 55255":
  case "M Project-Cleated 55124":
  case "M Project 95634":
  case "M Project 95608":
     var result = "A";
     break;

  case "Contour 54038":
  case "Contour Casual 54238":
  case "Contour Casual 54389":
  case "Contour Casual 54397":
  case "GreenJoy 45351":
  case "GreenJoy 45368":
  case "GreenJoy 45375":
  case "GreenJoy 45382":
  case "DryJoys Tour 53599":
  case "Icon 52217":
  case "LoPro 97135":
  case "LoPro 97166":
  case "LoPro Casual 97238":
  case "SuperLites CT 58118":
  case "SuperLites CT 58123":
  case "SuperLites 98829":
  case "SuperLite 58012":
  case "Sport Spikeless 53147":
  case "Sport Spikeless 53166":
  case "Sport 53247":
  case "LoPro Casual 97292":
  case "M Project-Cleated 55108":
  case "M Project-Spikeless 55213":
     var result = "C";
     break;

  case "GreenJoy 45697":
  case "GreenJoys 48453":
  case "GreenJoys 48461":
     var result = "S";
     break;

  case "Contour 54102":
  case "Icon 52252":
  case "Icon 52268":
  case "Sport 53216":
  case "M Project-Cleated 55116":
  case "M Project-Spikeless 55239":
     var result = "Z";
     break;

  case "Contour 54043":
  case "Contour 54051":
  case "Contour Casual 54251":
  case "Contour Casual 54356":
  case "Contour Casual 54371":
  case "DryJoys 99045":
  case "DryJoys Tour 53719":
  case "DryJoys Tour 53607":
  case "GreenJoys 48357":
  case "GreenJoys 48364":
  case "Icon 52108":
  case "Icon 52245":
  case "Icon 52276":
  case "LoPro 97123":
  case "LoPro 97142":
  case "LoPro 97159":
  case "SuperLites CT 58135":
  case "SuperLites 98837":
  case "SuperLites 98811":
  case "Sport 53295":
  case "Sport 53224":
  case "M Project-Spikeless 55247":
  case "M Project-Spikeless 55206":
  case "M Project-Cleated 55132":
  case "M Project 95615":
  case "M Project 95622":
  case "SuperLite 56732":
  default:
     var result "B";
}

return result;

Edited by esmith
fixed FOR loop errors caught by another user
Link to comment
Share on other sites

You need break tags ( break; ) after each case.

No, you don't, not if you use a "return" statement. That exits the rule function, making a "break" statement unnecessary.

 

However, I like esmith's solution to iterate the fields, rather than that gigantic first line with all the "or" (||) operators.

 

But neither of those things address the problem, which is that, in MarcomCentral, the values of graphic fields contain fully-qualified paths (to UNC shares in the LAN where the job is composing), not just the file names as you get in Creator (Desktop) in Acrobat.

 

The fix is to call the GetFileName function. Specifically, in esmith's version, you can call it on the "switch" line, like so:

switch (GetFileName(shoeStyle)) {

Link to comment
Share on other sites

Dan,

 

This still doesn't seem to be working. It is baffling me because it appears quite logical. The rule just always returns the default value when previewed in Marcom Central.

 

Here's a full explanation for one last hurrah to try to get this to work. A complementary box of Fudgesicles is yours if you can solve this quandary. I will try to be comprehensive in my description...

-----------

The template is for a golf shoe client so that they can create marketing boards full of shoes for event exhibitions and tradeshows.

 

They can version boards on the webstore from 2 shoes all the way up to 20.

 

They have a bunch of different styles and shoes. I am using a 30,000 row deep iForms list document to filter the dropdowns so that only the shoes assigned to the style they choose are displayed.

 

They are restricted to only two styles per board.

 

I set up different pages in the PDF FP template like so:

2Shoes1Style

2Shoes2Styles

3Shoes1Style

3Shoes2Styles

...all the way to 20Shoes2Styles

 

An OnRecordStart rule assigns which page to used based on how SelectShoe fields are populated with a value. Here is what it looks like to the user:

 

http://www.dsgraphics.com/test/userview.png

 

Now each shoe has a size value (i.e. A, B, C, Z, etc.) assigned to it and I am trying to use the switch rule to pull that into a variable text frame positioned on the top right hand size of the shoe graphic frame. Circled in red is the text frame with the rule to pull in the letter:

 

http://www.dsgraphics.com/test/templateexample.png

 

So I am not sure I can use the switch rule below because it has to identify the specfic shoe value in the SelectShoe (x) field then return the correct shoe size letter.

For the screenshot above, you have SelectShoe1 and SelectShoe2 which each could have a different shoe size letter value depending on what the user picks for a shoe.

 

Here is how it looks in the Marcom Central manager:

 

http://www.dsgraphics.com/test/managerview.png

 

The A duplicate graphic field is used to pull a PDF template page setup if they choose a two style template instead a one style. I had to do it this way because I use a conditional visibility UI rules and they can only be assigned one parent field...but that really isn't the relevant to the problem. The problem is why the switch rule isn't working. I had to use the image library IDs to filter the dropdowns in iForms. Do you think I need to use that as a field value in the switch rule instead of the file name?

 

Here is the current switch rule:

for (var n=1; n<=40; n++) {
  var shoe = "SelectShoe";
  if (n<=20) shoe += n;
  else shoe += (n-20) + 'A';
  if (Field(shoe) != '') {
     var shoeStyle = Field(shoe);
     n = 40;
  }
}

switch (GetFileName(ShoeStyle)) {
  case "Contour 54002":
  case "Contour 54094":
  case "Contour 54111":
  case "Contour Casual 54275":
  case "Contour Casual 54363":
  case "DryJoys 99038":
  case "DryJoys 99052":
  case "DryJoys Tour 53581":
  case "DryJoys Tour 53612":
  case "DryJoys Tour 53676":
  case "Icon 52005":
  case "Icon 52054":
  case "LoPro 97119":
  case "LoPro Casual 97065":
  case "LoPro Casual 97261":
  case "LoPro Casual 97276":
  case "SuperLites 98951":
  case "SuperLites 98803":
  case "SuperLite 58004":
  case "Sport Spikeless 53111":
  case "Sport 53203":
  case "M Project-Spikeless 55221":
  case "M Project-Cleated 55255":
  case "M Project-Cleated 55124":
  case "M Project 95634":
  case "M Project 95608":
     var result = "A";
     break;

  case "Contour 54038":
  case "Contour Casual 54238":
  case "Contour Casual 54389":
  case "Contour Casual 54397":
  case "GreenJoy 45351":
  case "GreenJoy 45368":
  case "GreenJoy 45375":
  case "GreenJoy 45382":
  case "DryJoys Tour 53599":
  case "Icon 52217":
  case "LoPro 97135":
  case "LoPro 97166":
  case "LoPro Casual 97238":
  case "SuperLites CT 58118":
  case "SuperLites CT 58123":
  case "SuperLites 98829":
  case "SuperLite 58012":
  case "Sport Spikeless 53147":
  case "Sport Spikeless 53166":
  case "Sport 53247":
  case "LoPro Casual 97292":
  case "M Project-Cleated 55108":
  case "M Project-Spikeless 55213":
     var result = "C";
     break;

  case "GreenJoy 45697":
  case "GreenJoys 48453":
  case "GreenJoys 48461":
     var result = "S";
     break;

  case "Contour 54102":
  case "Icon 52252":
  case "Icon 52268":
  case "Sport 53216":
  case "M Project-Cleated 55116":
  case "M Project-Spikeless 55239":
     var result = "Z";
     break;

  case "Contour 54043":
  case "Contour 54051":
  case "Contour Casual 54251":
  case "Contour Casual 54356":
  case "Contour Casual 54371":
  case "DryJoys 99045":
  case "DryJoys Tour 53719":
  case "DryJoys Tour 53607":
  case "GreenJoys 48357":
  case "GreenJoys 48364":
  case "Icon 52108":
  case "Icon 52245":
  case "Icon 52276":
  case "LoPro 97123":
  case "LoPro 97142":
  case "LoPro 97159":
  case "SuperLites CT 58135":
  case "SuperLites 98837":
  case "SuperLites 98811":
  case "Sport 53295":
  case "Sport 53224":
  case "M Project-Spikeless 55247":
  case "M Project-Spikeless 55206":
  case "M Project-Cleated 55132":
  case "M Project 95615":
  case "M Project 95622":
  case "SuperLite 56732":
  default:
     var result "B";
}

return result;

Thanks for all your (and the rest of you fellas) help thus far. I appreciate it immensely!

 

Best,

-Dano

 

P.S. Here is a zip file of the template files in case they would be of any help.

Edited by dleahy
Link to comment
Share on other sites

Here's a full explanation for one last hurrah to try to get this to work.

...

...

...

P.S. Here is a zip file of the template files in case they would be of any help.

That's a lot to digest, and frankly, I don't know enough about the workings on MarcomCentral to be able to analyze that part of the workflow.

 

Here's how I would approach this: output one or more of the Graphic fields directly in a text frame. Then re-upload the template, compose, and see what it shows. Once we see exactly what's in the data, it should be clear what we need to do in the rule.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...