Kinetic Web browser Print Preview

Yes!!! :raised_hands:

I am trying this and I am getting the error below. I am trying to learn js but I am not at the point to troubleshoot this code. I am trying to go from sales order entry to Print sales order Acknowledgement. I have that working except passing the sales order number which i could use help with too. Once I type in the order and it retrieves it I click print and this is the error I get.
image

That black part is what we need to see lol :slight_smile:

Show us your version of this:

eval ("var byteString = window.atob('{SysRptList.SysRptLst_RptData}');let int8Array = new Uint8Array(new ArrayBuffer(byteString.length));for (let i = 0; i < byteString.length; i++) { int8Array[i] = byteString.charCodeAt(i);}let documentBlob = new Blob([int8Array], { type: 'application/pdf' });let fileURL = URL.createObjectURL(documentBlob);console.log(fileURL); window.open(fileURL,'_blank');")

You can change the names to protect the guilty if you need.

This is what’s blacked out.

https://server/project2/Apps/Erp/Home/main.a5d0dc98451493a9bd38.js:1:2635957)),

Here’s the code

eval ("var byteString = window.atob('{SysRptList.SysRptLst_RptData}');let int8Array = new Uint8Array(new ArrayBuffer(byteString.length));for (let i = 0; i < byteString.length; i++) { int8Array[i] = byteString.charCodeAt(i);}let documentBlob = new Blob([int8Array], { type: 'application/pdf' });let fileURL = URL.createObjectURL(documentBlob);console.log(fileURL); window.open(fileURL,'_blank');")

Ok, that’s exactly the same :slight_smile:

Something must be wrong with SysRptList.SysRptLst_RptData, or it’s blank.

window.atob decodes base64data

It returns the report row. I am using the baq downloaded from above. the field RptData only has System.Byte[] in it. That doesn’t seem right.

image

So, yeah, JavaScript eval(). As Microsoft has blocked more and more file types in email, JavaScript HTML Smuggling is getting popular again. Obfuscated JavaScript in emails is difficult for Anti-Malware software to catch. eval() is an old capability that was useful to developers but has become even more useful to threat actors.

eval() can be blocked with security headers, so I wouldn’t hang my hat on the technique. From:

Don’t mean to p*ss on the St. Pat’s Parade. :person_shrugging: :shamrock:

Failure To Launch Listening GIF by Laff

Yes, that’s right. Then thing is, is it empty, or malformed?

When I open the Client it pops up so I would assume it’s formed correctly

I have it working now. It opens automatically in Edge but only downloads in Chrome. Is there a way to get it to open in chrome too?

Btw @klincecum was right. I inverted the i and s in SysRptList so it was obviously blank. Time for a new set of glasses i guess.

What to Know

  • In the Chrome browser, select the three vertical dots in the upper-right corner.
  • Choose Settings > Advanced > Privacy and security. Select Site Settings > PDF documents.
  • Use the toggle switch next to Download PDF files instead of automatically opening them in Chrome to turn the feature on and off.

There is no Advanced Settings there, so they are wrong, but the rest is right.

2 Likes

That worked. Thank you

1 Like

Separately, for those who use Edge, Microsoft will be replacing Chrome’s built-in PDF viewer with Adobe’s by 31 March 2023.

Because Adobe has such a great track record of being super secure :poop:

It’s super speedy too!

Thanks for All the help. I have it working and have modified the code slightly so that It will open any output option other than EMF. I just added an event next between the ERP BAQ and ran three conditions. one for each PDF, Excel, and Word (XML opens natively in the browser) I set TransView.Format to what ever the application/ is and use the code below in the condition. This way we can roll Kinetic out through browser rather than Client. Kind of keep the 2 worlds separated as we bring groups of users onto kinetic. I know it’s a temporary fix but hope it helps someone else.

eval ("var byteString = window.atob('{SysRptList.SysRptLst_RptData}');let int8Array = new Uint8Array(new ArrayBuffer(byteString.length));for (let i = 0; i < byteString.length; i++) { int8Array[i] = byteString.charCodeAt(i);}let documentBlob = new Blob([int8Array], { type: '{TransView.Format}' });let fileURL = URL.createObjectURL(documentBlob);console.log('{TransView.Format}'); window.open(fileURL,'_blank');")
3 Likes

I used the above tutorial from @hmwillett but it pulled up the report before the one I just ran and then opening the client I am bombarded with reports popping up. Although this will likely not matter in live just in case we are prepared. I modified it that it will open any output format PDF all the excels, csv, and word with the appropriate program then added a loop to wait for the new report to finish. and update sysrptlst so that the previews won’t pop up when entering the classic app.

If anyone wants instructions I am throwing them together so I don’t miss anything when doing this repetitively across all reports. Yes I am making even reports triggered from the overflow menu work like Sales order acknowledgment and invoices and edit lists.

A little confused on the magic sauce…

So your BAQ is querying the SysRpt thingy, and then you take the results of the BAQ and using JavaScript write a file to the client side ?

Say I have a function that does “some stuff” and one of it’s outputs is a “stream of bytes”,
could I use the expression-JavaScript to write the “stream of bytes” to a file locally ?

Thanks

Kind of you can’t write to the file from the browser if you could @Mark_Wonsil would blow a gasket. (and we don’t want to lose him, them dad jokes are :fire:)

However you can take that stream of bytes and generate a “BLOB” and then you can tell the Browser to “Download” this blob at which point the browser would prompt you to download / save / open the file with Outlook (or whatever)

That’s what this line does

eval ("var byteString = window.atob('{SysRptList.SysRptLst_RptData}');let int8Array = new Uint8Array(new ArrayBuffer(byteString.length));for (let i = 0; i < byteString.length; i++) { int8Array[i] = byteString.charCodeAt(i);}let documentBlob = new Blob([int8Array], { type: '{TransView.Format}' });let fileURL = URL.createObjectURL(documentBlob);console.log('{TransView.Format}'); window.open(fileURL,'_blank');")
2 Likes