Jump to content

My client wants the option to generate a QR code from text input OR upload an image for the QR code.


Cat

Recommended Posts

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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.

D&D.png

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

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...