Have your say in Community Polls: What was/is your greatest motivation to start your own business?

Send Invoice to Different Email Shopify Flow

Solved

Send Invoice to Different Email Shopify Flow

Leo_M
Tourist
9 0 2

Hey everyone,

We've started collecting a second email from our customers at sign-up (think accounting saas emails) and storing it in their profile notes. We did this because some of our customers use two emails and request invoices to be sent directly to their other email, not their primary one.

I've managed to pull this second email from the note, but I'm stuck on how to actually send the invoice there. Trying to use this email in the workflow keeps prompting for "get data." We tried it, but it didn't work.

Thanks

 

Screenshot 2024-02-10 at 01.19.36.png

 

Screenshot 2024-02-10 at 01.18.01.png

 

Screenshot 2024-02-10 at 01.18.09.png

 

Screenshot 2024-02-10 at 01.21.29.png

Accepted Solution (1)
paul_n
Shopify Staff
1429 156 330

This is an accepted solution.

Ok, the runtime error you are seeing is confusing. I think that is from an older version of the workflow.

 

For that error in Log Output, the problem is that you switched to a lower-case "output" field. It should look like:

type Output {
  somevar: String!
}

 

 

Paul_N | Flow Product Manager @ Shopify
- Finding Flow useful? Leave us a review
- Need Flow help? Check out our help docs.
- Building for Flow? Check out Flow's dev docs.

View solution in original post

Replies 10 (10)

Leo_M
Tourist
9 0 2

So, I simplified it, and it half worked. I used the flow below, and it worked if the Note contains only an email. However, the note will always be like this:

Mobile Number: 11123456789
Personal Email: aaa@example.com

 

I tried using 'Run Code' to parse the note and use its output, but I keep getting this error ""output" is invalid. Replace this variable"

would appreciate any help... thnx

Screenshot 2024-02-10 at 05.58.30.png

Screenshot 2024-02-10 at 05.51.06.png

paul_n
Shopify Staff
1429 156 330

The core problem is that the action requires an order and not a draft order. It will not work with Draft Orders. I think you figured that out in the last post?

 

The run code problem - the variable outputted is not called "output". It starts with the step name because you could have 2 steps that output the same variable. Always use "Add a variable" when adding variables via liquid if you want to see the correct syntax. In this case, it's something like "RunCode.email"

 

 

Paul_N | Flow Product Manager @ Shopify
- Finding Flow useful? Leave us a review
- Need Flow help? Check out our help docs.
- Building for Flow? Check out Flow's dev docs.
Leo_M
Tourist
9 0 2

Thanks Paul, yes the draft order wouldn't work, however I tried using "RunCode.email" with " Order Created" trigger and I ran into this error:
"Run code  Value {"email"=>"xxxx@gmail.com"} is of type Hash but should be of type NilClass"

side q: is Run Code the only way to make this workflow function? or is there a more direct method? I mean I tend to overcomplicate things sometimes

Flow1.pngError1.pngRun Code.png

paul_n
Shopify Staff
1429 156 330

That is a problem with your Run code step. I suspect that part where you assign it to matches[1] is actually undefined. Try matches[0].

Paul_N | Flow Product Manager @ Shopify
- Finding Flow useful? Leave us a review
- Need Flow help? Check out our help docs.
- Building for Flow? Check out Flow's dev docs.
Leo_M
Tourist
9 0 2

Thank you Paul, for your time I really appreciate it. I understand if you decide to leave this post, you've already been a great help. I just want to provide an update. I tried matches[0] and got the same error.

Here are two examples I tested all of them got same error as my previous post "Value {....} is of type Hash but should be of type NilClass""

I use the Run Code to log out the customer tag, and I got the exact same error as shown in the image.
I use the Run code with a Note that has only an email in it, still same exact error in my previous post.


Screenshot 2024-02-14 at 02.20.56.pngScreenshot 2024-02-14 at 02.20.35.png
Screenshot 2024-02-14 at 02.32.22.png

paul_n
Shopify Staff
1429 156 330
I think that tag field is actually a string of comma separated tags. So you
need to parse it first.
Paul_N | Flow Product Manager @ Shopify
- Finding Flow useful? Leave us a review
- Need Flow help? Check out our help docs.
- Building for Flow? Check out Flow's dev docs.
paul_n
Shopify Staff
1429 156 330

What variable are you using in Log Output? According to that code it should be {{ runCode.tag }} exactly. 

 

Paul_N | Flow Product Manager @ Shopify
- Finding Flow useful? Leave us a review
- Need Flow help? Check out our help docs.
- Building for Flow? Check out Flow's dev docs.
Leo_M
Tourist
9 0 2

I spent all my GPT-4 tokens on many possible scripts, and I ended up with the same exact error:
Value {"orderId"=>"5749155390000"} is of type Hash but should be of type NilClass

the below images for an example of trying to output the orderID. I thought it should be the most direct task

As for the Log Output step, I believe we are not there yet. We're still at the Run Code step, although I tried your suggested variable {{ runCode.tag }} and got this error: {"runCode" is invalid. Replace this variable} .. I also tried {{ RunCode.tag }} with the same error.

May I know if Run Code is the only way to make this workflow function using Shopify Flow?

thanks

error23.png

script23.png

runCode.png

paul_n
Shopify Staff
1429 156 330

This is an accepted solution.

Ok, the runtime error you are seeing is confusing. I think that is from an older version of the workflow.

 

For that error in Log Output, the problem is that you switched to a lower-case "output" field. It should look like:

type Output {
  somevar: String!
}

 

 

Paul_N | Flow Product Manager @ Shopify
- Finding Flow useful? Leave us a review
- Need Flow help? Check out our help docs.
- Building for Flow? Check out Flow's dev docs.
Leo_M
Tourist
9 0 2

Thanks a TON, Paul, for your patience. I really appreciate your support.

You were right, the problem was using "output" instead of "Output". The minute I corrected it, everything worked as it should be, even the Run Code process went through without any error

For anyone looking to use the customer profile Note data with their process using Run Code, here is what worked for me:

Screenshot 2024-02-15 at 06.41.31.png

Screenshot 2024-02-15 at 06.41.40.png

Screenshot 2024-02-15 at 06.41.51.png