Cat Posted August 4, 2023 Share Posted August 4, 2023 My client wants the option to have a QR code generated by code (easy) or the option to upload an image for the QR code (easy) BUT if an image is uploaded the text frame for the generated code should cease to exist (hard) So the pseudo-code: if upload: frame = uploadImageFrame else: frame = qrCodeFrame Or is there a built in control that does not require a custom Rule? Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted August 4, 2023 Share Posted August 4, 2023 You could just have a single graphic frame, and have it call out a graphic rule that returns either the generated or uploaded QR code. That graphic rule could call another graphic rule as necessary. Something like: if (Field("Upload") != "") return CreateResource(Field("Upload")); //else return Rule("QR Barcode: Barcode Data"); This could be probably accomplished with a Drag-and-Drop Wizard rule as well, without any code. Posting the template would allow me to make a more specific recommendation. Quote Link to comment Share on other sites More sharing options...
Cat Posted August 7, 2023 Author Share Posted August 7, 2023 Hey Dan, The drag & drop rule wants to have a text value in both the text and graphic versions, so the drag & drop will not work. However, the code you provided helped me to figure out the code I needed to create, thank you! Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted August 7, 2023 Share Posted August 7, 2023 7 hours ago, Cat said: The drag & drop rule wants to have a text value in both the text and graphic versions, so the drag & drop will not work. I don't think that's true. If you create a Graphic Drag-and-Drop rule, it will tell you to put either a Graphic Resource or a Graphic Rule into the "Return" box. I was able to create two other graphic rules: One based on the "Insert Picture Rule" Form, for the "if the image is uploaded" case, and another based on the Graphic "QR Barcode" Form, for the "generated by code" case, then use both of them in a Graphic Drag-and-Drop rule. But if you have it working in JavaScript, that's great. Quote Link to comment Share on other sites More sharing options...
Cat Posted August 8, 2023 Author Share Posted August 8, 2023 Dan, I'm so frustrated not understanding this tool instantly! (primal scream... yeah I know it's an unrealistic expectation Thank you for the example! I will work on testing this to help learn more. I have used Python to do a lot of functionality in another web-to-print solution and I tend to try a code based solution first because of it. Thank you again for your patience and help. Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted August 8, 2023 Share Posted August 8, 2023 35 minutes ago, Cat said: I'm so frustrated not understanding this tool instantly! (primal scream... yeah I know it's an unrealistic expectation Thank you for the example! You're doing fine. It's a complicated program with a lot of features. I don't know if there's anyone who understands everything about it. I'm still learning new tricks, and I've been working on FusionPro since its inception, 25 years ago. 35 minutes ago, Cat said: I will work on testing this to help learn more. I have used Python to do a lot of functionality in another web-to-print solution and I tend to try a code based solution first because of it. I don't mean to discourage you from writing code. Far from it: I'm a big fan of coding. (It's what I do!) I just wanted to clarify that this, like many tasks, can be accomplished without any coding, which many people prefer. Interesting that you mention Python. We actually had a bit of a debate years ago when we added the rules scripting system about what language to use. The finalists were JavaScript and Python. I think we ultimately made the right choice with JavaScript. (It's a bit more forgiving in some ways that Python, given Python's mandatory whitespace for one thing, though I know there are differences of opinion.) But Python has its charms as well. Quote Link to comment Share on other sites More sharing options...
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.