Kinetic Functions Response Params and

Ignore those. 99.9999% of the time they’re red herrings and show up whether your stuff works or not. @bconner what’s the deal with those? Make them go away. :frowning:

Do you have a view called actionView??
Unless you assign the results of your function response to a view, then the default is actionResult, so yours would read {actionResult.oBuffer}

oh my, as I was proofing my post I saw actionView vs actionResult and just change that, and changed the file type to application/eml in the JS…wow, it’s kind of working now (file is downloaded)

that was a big post to create, it’s kind of like when you can’t find an issue and talk someone thru your code and pow, there it hits you in the face

That’s what my friends are for. :grin:

Ok, so in as much I got a file downloaded, two issues, can I make it have a .eml extension ?

And strangely it’s only 3 bytes vs the correct number is about 1,600 bytes

I’m guessing it has to do with the handing off of the oBuffer parameter still

(I’ve check my oBuffer contents in the response using the Epicor rest api helper)

Oh, and the red error from the JS is gone

Probably? This is a bit outside of my knowledge for JS.
Maybe try changing type: 'application/pdf' to type: 'application/octet-stream' or type: 'message/rfc822' Just throwing some stuff out that I saw on StackOverflow. You’ll have to play with it or someone with more JS knowledge can jump in here.

Not sure on this one, either. :sweat_smile:

You need to go hang here for a bit:

2 Likes

nice, that one worked to make it be an .eml file

I added a console.log('{actionResult.oBuffer}'); at the start of the script, it’s showing null in the console…makes me wonder about the function response parms again

well go fill them in with bs so they aren’t null and find out

Show me the function widget’s response properties in App Studio.

@hmwillett Show me the function widget’s response properties in App Studio.

they are all like this (empty)

image

I have made some guesses on what syntax to put but to no avail

Searching for some documentation on this now

I thought the key was that the condition widget expression’s Javascript was referencing the '{actionResult.oBuffer}' properly, it’s not throwing an error but…it’s not getting the data either

You can find that info from the network tab when your function executes.

ok, sorry…it looks like this:
{"oSuccess":1,"oToAddress":null,"oFromAddress":"scott.janisch@olympusgrp.com","oHtmlBody":null,"oCcAddress":null,"oSubject":null,"oBuffer":null}

so, it is null, not sure why, because if I execute the same in rest helper I get this:

  "oSuccess": 113,
  "oToAddress": "scott.janisch@olympusgrp.com",
  "oFromAddress": "scott.janisch@olympusgrp.com",
  "oHtmlBody": "<html><head><style>p { margin-top: 0 ; margin-bottom: 0 ; }</style></head><body><h1>MKE CHANGE FORM</h1><hr><br><p>Customer Name: TEST, INCC.</p><p>Job: 879940-1-1</p><p>Required Date: 4/14/2023 (release 1)</p><p>Traveler Location: 10: ARTSET</p><br><hr><br><p>Is someone from Olympus aware of or working on this change? &nbsp&nbsp&nbsp Yes / No, If so, who?</p><p>&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp Was change already made or are they waiting for a new traveler? &nbsp&nbsp&nbsp Made / Waiting</p><br><p>Further Approval Needed? Yes / No</p><br><p>Requested Ship Date (if changing): </p><br><p>Change(s):</p><br><p>Additional Information:</p><br><hr><br><p>Email this form to the distro with above information filled out.  </p><br><p>- If the job is in production, SALES must pull traveler and bring to engineering</p><p>&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp- Not needed if the only change is moving the date OUT  </p><p>&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp- Contact scheduling to discuss first if moving the date UP</p><br><p>- If the job is OFA, do NOT mark the approval operation complete. </p><p>&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp- Engineering will do so AFTER the change is made. </p></p></body></html>",
  "oCcAddress": "scott.janisch@olympusgrp.com",
  "oSubject": "MKE Change Form",
  "oBuffer": "X-Unsent: 1\r\nX-Sender: scott.janisch@olympusgrp.com\r\nX-Receiver: scott.janisch@olympusgrp.com\r\nX-Receiver: scott.janisch@olympusgrp.com\r\nMIME-Version: 1.0scott.janisch@olympusgrp.com\r\nFrom: scott.janisch@olympusgrp.com\r\nTo: scott.janisch@olympusgrp.com\r\nCc: scott.janisch@olympusgrp.com\r\nDate: 3/31/2023 9:55:09 AM\r\nSubject: MKE Change Form\r\nContent-Type: text/html; charset=us-asciiscott.janisch@olympusgrp.com\r\nContent-Transfer-Encoding: quoted-printable\r\n\r\n<html><head><style>p { margin-top: 0 ; margin-bottom: 0 ; }</style></head><body><h1>MKE CHANGE FORM</h1><hr><br><p>Customer Name: TEST, INCC.</p><p>Job: 879940-1-1</p><p>Required Date: 4/14/2023 (release 1)</p><p>Traveler Location: 10: ARTSET</p><br><hr><br><p>Is someone from Olympus aware of or working on this change? &nbsp&nbsp&nbsp Yes / No, If so, who?</p><p>&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp Was change already made or are they waiting for a new traveler? &nbsp&nbsp&nbsp Made / Waiting</p><br><p>Further Approval Needed? Yes / No</p><br><p>Requested Ship Date (if changing): </p><br><p>Change(s):</p><br><p>Additional Information:</p><br><hr><br><p>Email this form to the distro with above information filled out.  </p><br><p>- If the job is in production, SALES must pull traveler and bring to engineering</p><p>&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp- Not needed if the only change is moving the date OUT  </p><p>&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp- Contact scheduling to discuss first if moving the date UP</p><br><p>- If the job is OFA, do NOT mark the approval operation complete. </p><p>&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp- Engineering will do so AFTER the change is made. </p></p></body></html>"
}```

although, now I see that my payload on the network tab is { } so apparently my function isn’t receiving it’s input data properly

can I write to the debug console directly from a function ?

double checking my input/request bindings to the function…

No, but within your function you can write to Ice.Diagnostics.Log.WriteEntry("Tacos!"); which will show in the event viewer on the server.

How are you setting up the method parameters for your function widget in app studio?

Somehow, the method parameters were gone, argh, so now my response looks correct !
I wonder if it was because I was moving steps around, adding/removing steps (not that one tho)

I did not know about the network tab things, thanks

I am now getting an error on the JavaScript hack:
Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.

I can try some things to work through that…so close

Ah, ok, but I can use console.log in the JavaScript “hack”…that’s probably what I need now

@josecgomez
using the JavaScript “hack” to download a file, successfully passing my “blob” via
window.atob('{actionResult.oBuffer}') but oBuffer is an output from a function, typed as a String, see any issues there ?

What does oBuffer look like?can you console. log it?

yes…

X-Unsent: 1X-Sender: scott.janisch@olympusgrp.comX-Receiver: scott.janisch@olympusgrp.comX-Receiver: scott.janisch@olympusgrp.comMIME-Version: 1.0scott.janisch@olympusgrp.comFrom: scott.janisch@olympusgrp.comTo: scott.janisch@olympusgrp.comCc: scott.janisch@olympusgrp.comDate: 3/31/2023 2:38:28 PMSubject: MKE Change FormContent-Type: text/html; charset=us-asciiscott.janisch@olympusgrp.comContent-Transfer-Encoding: quoted-printable<html><head><style>p { margin-top: 0 ; margin-bottom: 0 ; }</style></head><body><h1>MKE CHANGE FORM</h1><hr><br><p>Customer Name: TEST, INCC.</p><p>Job: 879940-1-1</p><p>Required Date: 4/14/2023 (release 1)</p><p>Traveler Location: 10: ARTSET</p><br><hr><br><p>Is someone from Olympus aware of or working on this change? (continues)

but a rest response shows there should be \r\n to break the lines up

in a test program, if I take my oBuffer and convert it to a Byte[] the \r\n become 0x0d 0x0a as one would expect and then if I write that Byte[] to a file and name it as .eml, it opens as an email draft

this is the first part of oBuffer in my rest response:

"X-Unsent: 1\r\nX-Sender: scott.janisch@olympusgrp.com\r\nX-Receiver: scott.janisch@olympusgrp.com\r\nX-Receiver: scott.janisch@olympusgrp.com\r\nMIME-Version: 1.0scott.janisch@olympusgrp.com\r\nFrom: scott.janisch@olympusgrp.com\r\nTo: scott.janisch@olympusgrp.com\r\nCc: scott.janisch@olympusgrp.com\r\nDate: 3/31/2023 2:37:39 PM\r\nSubject: MKE Change Form\r\nContent-Type: text/html; charset=us-asciiscott.janisch@olympusgrp.com\r\nContent-Transfer-Encoding: quoted-printable\r\n\r\n<html><head><style>p { margin-top: 0 ; margin-bottom: 0 ; }</style></head><body><h1>MKE CHANGE FORM</h1><hr><br><p>Customer Name: TEST, INCC.</p><p>Job: 879940-1-1</p><p>Required Date: 4/14/2023 (release 1)</p><p>Traveler Location: 10: ARTSET</p><br><hr><br>

i’ve tried a few different things with the JavaScript, it always wants to strip those out when I convert from my string to the int8Array

I feel like if I could return a byte array from the function, this would work

That’s not base 64 encoded. atob needs a base 64 encoded string. Looks like yours is already decoded. Do return a Byte Array from your function take the File and turn it into a byte array.

byte[] fileBytes = File.ReadAllBytes(strFile);
string base64EncodedString = Convert.ToBase64String(fileBytes);

Return taht.

1 Like

Yeah, I eventually realized the thing about not being 64 encoded, so my attempt was to fix it in the javascript, I had removed the atob and replaced with various outher attempts, to no avail.

Fixing it on the other side (your suggestion) hadn’t occurred to me…eureka…it worked !!!

thanks much