# Make a report with a byte array

**URL:** <https://forum.inductiveautomation.com/t/make-a-report-with-a-byte-array/62887>\
**Category:** Ignition\
**Created:** [August 10, 2022, 7:09pm UTC](https://forum.inductiveautomation.com/t/make-a-report-with-a-byte-array/62887 "2022-08-10T19:09:20Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Annette\_McDonough](https://avatars.discourse-cdn.com/v4/letter/a/bb73d2/32.png) [@Annette\_McDonough](https://forum.inductiveautomation.com/u/Annette_McDonough)\
**Post date:** [August 10, 2022, 7:09pm UTC](https://forum.inductiveautomation.com/t/make-a-report-with-a-byte-array/62887/1 "2022-08-10T19:09:20Z")

</div>

I am trying to create a report but I already have queried and formatted a string in python. I then took that string and converted it to a byte array. How do I create a report to email with the string that I converted to a byte array?  
Or is there a way to save my formatted string to the ignition server in a file and then retrieve that file like a local machine can do?  
Any help would be greatly appreciated.

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [August 10, 2022, 7:15pm UTC](https://forum.inductiveautomation.com/t/make-a-report-with-a-byte-array/62887/2 "2022-08-10T19:15:53Z")

</div>

If you are trying to email a report after using `system.report.execute()` then you need to use `system.report.executeAndDistribute()` instead.  
[system.report.executeAndDistribute - Ignition User Manual 8.1 - Ignition Documentation (inductiveautomation.com)](https://docs.inductiveautomation.com/display/DOC81/system.report.executeAndDistribute)

---

<div class="post-metadata">

**Author:** ![Annette\_McDonough](https://avatars.discourse-cdn.com/v4/letter/a/bb73d2/32.png) [@Annette\_McDonough](https://forum.inductiveautomation.com/u/Annette_McDonough)\
**Post date:** [August 10, 2022, 7:40pm UTC](https://forum.inductiveautomation.com/t/make-a-report-with-a-byte-array/62887/3 "2022-08-10T19:40:38Z")

</div>

I have not created a report yet. I am wondering if there is a way to create the report with a formatted string or a byte array?  
Thank you for your help

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [August 10, 2022, 7:42pm UTC](https://forum.inductiveautomation.com/t/make-a-report-with-a-byte-array/62887/4 "2022-08-10T19:42:22Z")

</div>

> [@Annette\_McDonough](#):
>
> I am wondering if there is a way to create the report with a formatted string or a byte array?

Not that I know of.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [August 10, 2022, 8:11pm UTC](https://forum.inductiveautomation.com/t/make-a-report-with-a-byte-array/62887/5 "2022-08-10T20:11:26Z")

</div>

Since 8.1.16 you can pass a byte array directly into a report as a parameter. You can provide a PDF (binary) and embed it inside a report via the image component.

I’m really not clear on what you’re actually doing/trying to do, though.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [August 10, 2022, 8:22pm UTC](https://forum.inductiveautomation.com/t/make-a-report-with-a-byte-array/62887/6 "2022-08-10T20:22:23Z")

</div>

My interpretation is that they’re just looking to send an email with some arbitrary attachment they’ve already managed to create…

---

<div class="post-metadata">

**Author:** ![Annette\_McDonough](https://avatars.discourse-cdn.com/v4/letter/a/bb73d2/32.png) [@Annette\_McDonough](https://forum.inductiveautomation.com/u/Annette_McDonough)\
**Post date:** [August 10, 2022, 8:22pm UTC](https://forum.inductiveautomation.com/t/make-a-report-with-a-byte-array/62887/7 "2022-08-10T20:22:24Z")

</div>

I am trying to email a query from 2 different databases and put them in one queried string with the scripting. I formatted and saved the string to a local file and then emailed it, but I wanted to email the file I created so it has to be saved on the local machine. Only problem is it cant be saved locally to a machine and needs to be saved to the server. I am trying to either save the file to the server to then email so its not on a local machine or somehow take my formatted string or the byte array and put it into a report.  
It seems the only way to save to the server that I have found is through reports which I am not familiar with yet.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [August 10, 2022, 8:26pm UTC](https://forum.inductiveautomation.com/t/make-a-report-with-a-byte-array/62887/8 "2022-08-10T20:26:26Z")

</div>

> [@Annette\_McDonough](#):
>
> It seems the only way to save to the server that I have found is through reports which I am not familiar with yet.

If your script is running in the gateway somewhere you can just use [system.file.writeFile](https://docs.inductiveautomation.com/display/DOC81/system.file.writeFile) to write it somewhere the gateway can access.

---

<div class="post-metadata">

**Author:** ![Annette\_McDonough](https://avatars.discourse-cdn.com/v4/letter/a/bb73d2/32.png) [@Annette\_McDonough](https://forum.inductiveautomation.com/u/Annette_McDonough)\
**Post date:** [August 10, 2022, 8:40pm UTC](https://forum.inductiveautomation.com/t/make-a-report-with-a-byte-array/62887/9 "2022-08-10T20:40:56Z")

</div>

I can save it to my local machine with system.file.writeFile(). What are the places I can write it to in the server where gateway has access? I am very new to ignition thank you.

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [August 10, 2022, 9:07pm UTC](https://forum.inductiveautomation.com/t/make-a-report-with-a-byte-array/62887/10 "2022-08-10T21:07:22Z")

</div>

The writeFile script would have to be called in the gateway scope where it would write on the gateway server. This could be done by using a gateway handler message, or a tag event.

If the script is called in a Vision client, then it would be called in a client scope (local).

[Gateway Event Scripts - Ignition User Manual 8.1 - Ignition Documentation (inductiveautomation.com)](https://docs.inductiveautomation.com/display/DOC81/Gateway+Event+Scripts)
