Olivier Posted September 14, 2015 Posted September 14, 2015 Hi friends, I have written a OnRecordStart rule to compose a specific page based on the choice of an image field (Field("Type-flux")). I have a second condition base on the use of a logo or not. The rule is working fine on Acrobat with FP 9.3.6 on my Mac, but it is not working a expected when files are upload to the MarcomCentral. Here is my code : if (Field("LogoColl2") == "") { if (GetFileName(Field("Type-flux")) == "Bi-flux" || GetFileName(Field("Type-flux")) == "Bi-flux projet métal") { { FusionPro.Composition.SetBodyPageUsage("One", true); } { FusionPro.Composition.SetBodyPageUsage("Two", false); } { FusionPro.Composition.SetBodyPageUsage("Three", false); } { FusionPro.Composition.SetBodyPageUsage("Four", false); } } else { { FusionPro.Composition.SetBodyPageUsage("One", false); } { FusionPro.Composition.SetBodyPageUsage("Two", false); } { FusionPro.Composition.SetBodyPageUsage("Three", true); } { FusionPro.Composition.SetBodyPageUsage("Four", false); } } } else { if (Field("LogoColl2") != "") { if (GetFileName(Field("Type-flux")) == "Bi-flux" || GetFileName(Field("Type-flux")) == "Bi-flux projet métal" { { FusionPro.Composition.SetBodyPageUsage("One", false); } { FusionPro.Composition.SetBodyPageUsage("Two", true); } { FusionPro.Composition.SetBodyPageUsage("Three", false); } { FusionPro.Composition.SetBodyPageUsage("Four", false); } } else { { FusionPro.Composition.SetBodyPageUsage("One", false); } { FusionPro.Composition.SetBodyPageUsage("Two", false); } { FusionPro.Composition.SetBodyPageUsage("Three", false); } { FusionPro.Composition.SetBodyPageUsage("Four", true); } } } } } Where may be the issue ? I have used a GetFileName function to collect the name of the selected image, is there something wrong or something else to do ? Thank you all for the assistance. BR, Olivier. Quote
jwhittaker Posted September 14, 2015 Posted September 14, 2015 It looks like there are too many {}s. Try this. if (Field("LogoColl2") == "") { if (GetFileName(Field("Type-flux")) == "Bi-flux" || GetFileName(Field("Type-flux")) == "Bi-flux projet métal") { FusionPro.Composition.SetBodyPageUsage("One", true); FusionPro.Composition.SetBodyPageUsage("Two", false); FusionPro.Composition.SetBodyPageUsage("Three", false); FusionPro.Composition.SetBodyPageUsage("Four", false); } else { FusionPro.Composition.SetBodyPageUsage("One", false); FusionPro.Composition.SetBodyPageUsage("Two", false); FusionPro.Composition.SetBodyPageUsage("Three", true); FusionPro.Composition.SetBodyPageUsage("Four", false); } } else { if (GetFileName(Field("Type-flux")) == "Bi-flux" || GetFileName(Field("Type-flux")) == "Bi-flux projet métal" { FusionPro.Composition.SetBodyPageUsage("One", false); FusionPro.Composition.SetBodyPageUsage("Two", true); FusionPro.Composition.SetBodyPageUsage("Three", false); FusionPro.Composition.SetBodyPageUsage("Four", false); } else { FusionPro.Composition.SetBodyPageUsage("One", false); FusionPro.Composition.SetBodyPageUsage("Two", false); FusionPro.Composition.SetBodyPageUsage("Three", false); FusionPro.Composition.SetBodyPageUsage("Four", true); } } Quote
Olivier Posted September 14, 2015 Author Posted September 14, 2015 Hi jwhittaker, tank you it is much more clear like this. Unfortunately the result is still the same, the system online only composes page Three or Four, but never One or Two whatever the Type-flux is. It looks like the system does not recognize the name of the image selected as Type-flux. Hope someone will help me. Anyway, thank you ! Quote
jwhittaker Posted September 14, 2015 Posted September 14, 2015 Oliver Can you upload the data you are using for the template? Quote
Olivier Posted September 14, 2015 Author Posted September 14, 2015 Here they are ! Please note all the ressources are not attached, as there are many images in different collections. But the most important are there. Also note the OnRecordStart rule is working fine on my local Acrobat with FP 9.3.6 Images are available here : https://dl.dropboxusercontent.com/u/109498456/images.zip Best regards, OliviercollecteOG.zip Quote
jwhittaker Posted September 14, 2015 Posted September 14, 2015 Olivier Try using this code for the OnRecordStart I just created new variable and am searching for the 2 names you are looking for. var typeflux = Str(Field("Type-flux")); if (Field("LogoColl2") == "") { if ((typeflux.search("Bi-flux") != -1) || (typeflux.search("Bi-flux projet métal") != -1)) { FusionPro.Composition.SetBodyPageUsage("One", true); FusionPro.Composition.SetBodyPageUsage("Two", false); FusionPro.Composition.SetBodyPageUsage("Three", false); FusionPro.Composition.SetBodyPageUsage("Four", false); } else { FusionPro.Composition.SetBodyPageUsage("One", false); FusionPro.Composition.SetBodyPageUsage("Two", false); FusionPro.Composition.SetBodyPageUsage("Three", true); FusionPro.Composition.SetBodyPageUsage("Four", false); } } else { if ((typeflux.search("Bi-flux") != -1) || (typeflux.search("Bi-flux projet métal") != -1)) { FusionPro.Composition.SetBodyPageUsage("One", false); FusionPro.Composition.SetBodyPageUsage("Two", true); FusionPro.Composition.SetBodyPageUsage("Three", false); FusionPro.Composition.SetBodyPageUsage("Four", false); } else { FusionPro.Composition.SetBodyPageUsage("One", false); FusionPro.Composition.SetBodyPageUsage("Two", false); FusionPro.Composition.SetBodyPageUsage("Three", false); FusionPro.Composition.SetBodyPageUsage("Four", true); } } Quote
step Posted September 14, 2015 Posted September 14, 2015 I'll bet that the issue has less to do with the GetFileName function and more to do with the special character (é) in the field name. It seems like that character might work fine locally on a Mac but could be translated incorrectly on a server (especially if it's a Windows server). You should probably use a function like "TaggedTextFromRaw" to better handle the special characters. It will convert the é to its HTML entity: é Then you would be able to change your if statement to: if (TaggedTextFromRaw(Field("Type-flux")) == "Bi-flux" || TaggedTextFromRaw(Field("Type-flux")) == "Bi-flux projet métal") Or using a Regular Expression: if (!TaggedTextFromRaw(Field("Type-flux")).search(/Bi-flux( projet métal)?/g)) And if you really want reduce your code to eliminate the excessive if/else statements, you could change your OnRecordStart rule to look like this: var flux = TaggedTextFromRaw(Field("Type-flux")).search(/Bi-flux( projet métal)?/g); pg = [['One','Three'],['Two','Four']][+!!Field("LogoColl2")][+!!(flux)]; FusionPro.Composition.SetBodyPageUsage(pg, true); Quote
Olivier Posted September 14, 2015 Author Posted September 14, 2015 Hey, karen from the Grafix support has sent me the solution... I was using the GetFileName but thinking it was able to return the user Friendly label… In fact, in my rule I have to test on the exact file image name, and now it works fine ! I will try your code also, and let you know. Best regards, and thank you all for your assistance. Olivier Quote
Recommended Posts
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.