# How to define a dataset in a BPM?

**URL:** <https://www.epiusers.help/t/how-to-define-a-dataset-in-a-bpm/44543>\
**Category:** Epicor ERP 10\
**Tags:** bpm\
**Created:** [May 9, 2018, 8:55pm UTC](https://www.epiusers.help/t/how-to-define-a-dataset-in-a-bpm/44543 "2018-05-09T20:55:39Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Banderson](https://www.epiusers.help/user_avatar/www.epiusers.help/banderson/32/50875_2.png) [@Banderson](https://www.epiusers.help/u/Banderson)\
**Post date:** [May 9, 2018, 8:55pm UTC](https://www.epiusers.help/t/how-to-define-a-dataset-in-a-bpm/44543/1 "2018-05-09T20:55:40Z")

</div>

So I want to be able to grab some information from various tables in E-10 to populate an E-mail template. I can fill a table by query, but I can’t figure out how to use anything other than the context data sets. How do I define the columns in the DataSet under variables so I can fill it by a query?

 ![image](https://epiusers.help/uploads/default/original/2X/b/bfb88911c8899d5fba7f66f09a987f49da825367.png)

---

<div class="post-metadata">

**Author:** ![Chris\_Conn](https://www.epiusers.help/user_avatar/www.epiusers.help/chris_conn/32/93797_2.png) [@Chris\_Conn](https://www.epiusers.help/u/Chris_Conn)\
**Post date:** [May 9, 2018, 9:29pm UTC](https://www.epiusers.help/t/how-to-define-a-dataset-in-a-bpm/44543/2 "2018-05-09T21:29:20Z")

</div>

I can tell you how to do it in code - but that doesnt answer the question proper.

---

<div class="post-metadata">

**Author:** ![Banderson](https://www.epiusers.help/user_avatar/www.epiusers.help/banderson/32/50875_2.png) [@Banderson](https://www.epiusers.help/u/Banderson)\
**Post date:** [May 9, 2018, 9:43pm UTC](https://www.epiusers.help/t/how-to-define-a-dataset-in-a-bpm/44543/3 "2018-05-09T21:43:32Z")

</div>

I’m wondering if that is the “proper” way… I imagine you have to run a custom code block to build the DataSet?

My other option is just hijack a duplicated DataSet and just use the fields for what I want. It’s pretty messy that way, but it would be easier.

edit, no that won’t work for what I want to do because I need a table formatted nicely enough to drop into an e-mail. Using an Epicor data set doesn’t give me any control over the order of fields when I do a field query in a message/email. ughhh

---

<div class="post-metadata">

**Author:** ![timshuwy](https://www.epiusers.help/user_avatar/www.epiusers.help/timshuwy/32/90122_2.png) [@timshuwy](https://www.epiusers.help/u/timshuwy)\
**Post date:** [May 10, 2018, 12:38am UTC](https://www.epiusers.help/t/how-to-define-a-dataset-in-a-bpm/44543/4 "2018-05-10T00:38:40Z")

</div>

I found that the EASIEST way to create the dataset is to first define where you will use it…  
For example, I made an updatable BAQ BPM that needed to check-out a part to the Engineering Workbench… it calls the method called “EngineeringWorkbench.Checkout”… when you load that business object, you will see it demands a bunch of parameters… one of which is the Engineering Workbench tableset. When you click on that Combo box, there is an option to “Create New Variable”… when you do, it seems to create the dataset you need. You can then use that dataset in other widgets like the Fill table widget (if I remember right… this was a long time ago).  
 ![image](https://epiusers.help/uploads/default/original/2X/f/f1cf73c3e657d1c8380116e6d0f518ba04695c10.png)

---

<div class="post-metadata">

**Author:** ![Banderson](https://www.epiusers.help/user_avatar/www.epiusers.help/banderson/32/50875_2.png) [@Banderson](https://www.epiusers.help/u/Banderson)\
**Post date:** [May 10, 2018, 1:44pm UTC](https://www.epiusers.help/t/how-to-define-a-dataset-in-a-bpm/44543/5 "2018-05-10T13:44:36Z")

</div>

It looks like that method is creating the new data set that goes with the BO/has the BO required columns. Which is essentially what this does in the variables.

 ![image](https://epiusers.help/uploads/default/original/2X/1/193bb299d8db29483609d935b7b76aed95e831df.png)

I’m trying to figure out how to the use generic DataSet option that shows up on the one that I created called “Email”

---

<div class="post-metadata">

**Author:** ![Banderson](https://www.epiusers.help/user_avatar/www.epiusers.help/banderson/32/50875_2.png) [@Banderson](https://www.epiusers.help/u/Banderson)\
**Post date:** [May 10, 2018, 6:36pm UTC](https://www.epiusers.help/t/how-to-define-a-dataset-in-a-bpm/44543/6 "2018-05-10T18:36:33Z")

</div>

So I figured out how to call a BAQ and write to an XML, not exactly what I need, but I used this post to help me figure out how to do this.

> **[Call a BAQ from within a BPM](https://www.epiusers.help/t/call-a-baq-from-within-a-bpm/33852/8)**
>
> There are at least three options when needing to pull in data from the database in a BPM. 1. You can use LINQ 2. you can execute SQL String myCommand = "some sql"; System.Data.SqlClient.SqlCommand sqlCom = new...

This is what I end up with,

 ![image](https://www.epiusers.help/uploads/default/original/2X/3/3c7164687bc88a8516b27d31c21d20eba350d782.png)

It writes an XML file based on the Pack number of the record you are modifying.

Now I would like to know if it’s possible to store that Data Set temporarily instead of an XML in order to display it in a message/e-mail??

Would I just have to build the string with a foreach loop on the data set?
