# Generate List of historical BatchID's

**URL:** <https://forum.inductiveautomation.com/t/generate-list-of-historical-batchids/80019>\
**Category:** 3rd Party Modules\
**Tags:** sepasoft\
**Created:** [October 4, 2023, 2:19pm UTC](https://forum.inductiveautomation.com/t/generate-list-of-historical-batchids/80019 "2023-10-04T14:19:54Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![liam1](https://avatars.discourse-cdn.com/v4/letter/l/e68b1a/32.png) [@liam1](https://forum.inductiveautomation.com/u/liam1)\
**Post date:** [October 4, 2023, 2:19pm UTC](https://forum.inductiveautomation.com/t/generate-list-of-historical-batchids/80019/1 "2023-10-04T14:19:54Z")

</div>

I want to be able to selected from a list of previously run batches and view a selected batch in the EBR Viewer.

Only issue is, I need to provide the exact BatchID used.

We currently use ISA88 tag name combined with Unix timestamp to create a unique batch ID.

Is there a way of generating a list on batchID's where I can filter by date and a string name pattern  
ie `STU_01_02_02*` ?

---

<div class="post-metadata">

**Author:** ![jesse.records](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jesse.records/32/10960_2.png) [@jesse.records](https://forum.inductiveautomation.com/u/jesse.records)\
**Post date:** [October 4, 2023, 3:15pm UTC](https://forum.inductiveautomation.com/t/generate-list-of-historical-batchids/80019/2 "2023-10-04T15:15:56Z")

</div>

Yes, the easiest way is to create an [analysis setting](https://help.sepasoft.com/docs/display/SEPA/Analysis+Data+Points+and+Settings) like so:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/f/8f6917232ad34cbb4cfb5866a055b1c8aebcd037.png)

You could use the [analysis controller](https://help.sepasoft.com/docs/display/SEPA/MES+Analysis+Controller+-+Perspective) or the [analysis script library](https://help.sepasoft.com/docs/display/SEPA/system.mes.analysis.executeAnalysis) to populate the desired list.

---

<div class="post-metadata">

**Author:** ![liam1](https://avatars.discourse-cdn.com/v4/letter/l/e68b1a/32.png) [@liam1](https://forum.inductiveautomation.com/u/liam1)\
**Post date:** [October 6, 2023, 11:54am UTC](https://forum.inductiveautomation.com/t/generate-list-of-historical-batchids/80019/4 "2023-10-06T11:54:37Z")

</div>

Okay I figured out how to create the same analysis settings used in the analysis selector component through scripting.

Here is the current settings , which returns data.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/6/b6f12ed31f899e8487e32c8af2d9884ff3af0a4c.png)

Here is the same analysis settings implemented in scripting.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/4/d413f9ebf6448b3ad3d9bc123bc87002b2a11f9b.png)

I'm getting this error message.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/5/c50b72db75db261e3565af8a2f41992e4f1ae104.png)

What is equivalent datapoint name for "Procedure/Batch\_ID" ?

---

<div class="post-metadata">

**Author:** ![jesse.records](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jesse.records/32/10960_2.png) [@jesse.records](https://forum.inductiveautomation.com/u/jesse.records)\
**Post date:** [October 6, 2023, 4:14pm UTC](https://forum.inductiveautomation.com/t/generate-list-of-historical-batchids/80019/5 "2023-10-06T16:14:07Z")

</div>

For a quick conversion of your analysis settings to script, the [MES Monitor component](https://help.sepasoft.com/docs/display/SEPA/MES+Monitor) has a built-in feature:

Find your Named Analysis you executed and right click in the Metric Details section:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/5/d563d5a8583c793a1a00c127d37366ab15c2586e.png)

Pasting the copied script in the chat will give you an idea of how to formulate your script:

```auto
end = system.date.now()
begin = system.date.addDays(end, -8)

analysis = system.mes.analysis.createMESAnalysisSettings('analysis')
analysis.setDataPoints("Procedure/Batch_ID,Procedure/Recipe_Name")
analysis.setFilterExpression("Equipment Path LIKE 'Enterprise\Site\Area\Process Cell*'")
analysis.setGroupBy("Procedure/Batch_ID,Procedure/Recipe_Name")
# system.mes.analysis.executeAnalysis() returns an MES Analysis Results object
# For documentation, see: https://help.sepasoft.com/docs/display/MHD/MES+Analysis+Results
results = system.mes.analysis.executeAnalysis(begin, end, analysis)

if results.hasMessage():
	count = results.getMessageCount()
	message_list = [str(results.getMessage(index)) for index in range(count)]

# getDataset() returns an Ignition Dataset
# For documentation, see: https://docs.inductiveautomation.com/display/DOC79/Datasets
dataset = results.getDataset()

sep = ",\t"
print sep.join(dataset.getColumnNames())
for row in range(dataset.getRowCount()):
	print sep.join(map(str, dataset.getRow(row)))

```

---

<div class="post-metadata">

**Author:** ![liam1](https://avatars.discourse-cdn.com/v4/letter/l/e68b1a/32.png) [@liam1](https://forum.inductiveautomation.com/u/liam1)\
**Post date:** [October 9, 2023, 6:02am UTC](https://forum.inductiveautomation.com/t/generate-list-of-historical-batchids/80019/6 "2023-10-09T06:02:10Z")

</div>

Thank you ,based on your example I changed the values from a list of strings to a Parameter string.

It now works but I'm confused why my originals code didn't work when the documentation specifically specifies a List of strings as the parameter type.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/5/f55ecae4977bacdd07ce3931a925a5f81cd85383.png)

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/d/ed48a092dd5e9e7358f2cb336dc678f8d5602923.png)

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/c/fc81ef4ad329ada6422a62b9d20e4b597cc7ff07.png)

---

<div class="post-metadata">

**Author:** ![liam1](https://avatars.discourse-cdn.com/v4/letter/l/e68b1a/32.png) [@liam1](https://forum.inductiveautomation.com/u/liam1)\
**Post date:** [October 9, 2023, 6:21am UTC](https://forum.inductiveautomation.com/t/generate-list-of-historical-batchids/80019/7 "2023-10-09T06:21:43Z")

</div>

This is a java list string not which is not the same as a python list string.
