# Read CSV, Update Material Queue and then Process the Record

**URL:** <https://www.epiusers.help/t/read-csv-update-material-queue-and-then-process-the-record/104070>\
**Category:** Kinetic ERP\
**Tags:** customization, e10, bpm, epicor\
**Created:** [June 15, 2023, 1:19pm UTC](https://www.epiusers.help/t/read-csv-update-material-queue-and-then-process-the-record/104070 "2023-06-15T13:19:30Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ricky90](https://www.epiusers.help/letter_avatar_proxy/v4/letter/r/ea5d25/32.png) [@Ricky90](https://www.epiusers.help/u/Ricky90)\
**Post date:** [June 15, 2023, 1:19pm UTC](https://www.epiusers.help/t/read-csv-update-material-queue-and-then-process-the-record/104070/1 "2023-06-15T13:19:31Z")

</div>

Hi, I have a CSV file from our WMS system (seperate to Epicor). The 3 columns it contains are MtlQueueSeq, To Bin and Quantity.

Id like to schedule a function to read the CSV files in a directory every 5 minutes, update the To Bin in the MtlQueue table and then process the record with the Quantity leaving any outstanding qty in situ without user interaction.

To give context im attempting to integrate Modula Lifters with EpicorERP ensuing ‘complete’ automation. (At least thats the task ive been given).

Hopefully someone can help out as i can export a CSV file from a BAQ in a Function but importing, i do not know where to start.

---

<div class="post-metadata">

**Author:** ![klincecum](https://www.epiusers.help/user_avatar/www.epiusers.help/klincecum/32/100137_2.png) [@klincecum](https://www.epiusers.help/u/klincecum)\
**Post date:** [June 15, 2023, 1:23pm UTC](https://www.epiusers.help/t/read-csv-update-material-queue-and-then-process-the-record/104070/2 "2023-06-15T13:23:42Z")

</div>

> [@Kinetic, Application Studio, Server Files (Saas)](https://www.epiusers.help/t/kinetic-application-studio-server-files-saas/103238/13):
>
> In a function: //ref: Ice.Contracts.Lib.ServerPath //using System.IO; CallService\<Ice.Contracts.ServerPathSvcContract\>(serverPathSvc =\> { List\<Ice.Lib.ServerPath.Types.PathInfo\> pathInfo = new List\<Ice.Lib.ServerPath.Types.PathInfo\>(); pathInfo = serverPathSvc.GetPaths(Epicor.ServiceModel.Utilities.SpecialFolder.CompanyData, "", false); if(pathInfo.Count \> 0) { string path = $"{pathInfo.First().FullName}\\testing.txt"; File.WriteAllText(path, "In t…

Should get you started.

Anything else you need help with?

---

<div class="post-metadata">

**Author:** ![Mark\_Wonsil](https://www.epiusers.help/user_avatar/www.epiusers.help/mark_wonsil/32/51594_2.png) [@Mark\_Wonsil](https://www.epiusers.help/u/Mark_Wonsil)\
**Post date:** [June 15, 2023, 1:50pm UTC](https://www.epiusers.help/t/read-csv-update-material-queue-and-then-process-the-record/104070/3 "2023-06-15T13:50:34Z")

</div>

![image](https://www.epiusers.help/uploads/default/original/3X/9/c/9c8660b94c8f0e05805dea76d52884141370af09.jpeg)

If you’re a cloud developer and afraid of file systems like me, you could also write an Epicor Function that updates the ToBin in the MtlQueue and processes the record. Now create a PowerShell that reads the CSV after the export and does a POST to your Efx using Invoke-RESTMethod. It removes the dependency on the File system and removes all of those messy details from your Kinetic server code.

---

<div class="post-metadata">

**Author:** ![klincecum](https://www.epiusers.help/user_avatar/www.epiusers.help/klincecum/32/100137_2.png) [@klincecum](https://www.epiusers.help/u/klincecum)\
**Post date:** [June 15, 2023, 2:08pm UTC](https://www.epiusers.help/t/read-csv-update-material-queue-and-then-process-the-record/104070/4 "2023-06-15T14:08:56Z")

</div>

I skip the filesystem when I can, and even when it’s hard, memorystream is your friend 🙂

---

<div class="post-metadata">

**Author:** ![Ricky90](https://www.epiusers.help/letter_avatar_proxy/v4/letter/r/ea5d25/32.png) [@Ricky90](https://www.epiusers.help/u/Ricky90)\
**Post date:** [June 15, 2023, 2:16pm UTC](https://www.epiusers.help/t/read-csv-update-material-queue-and-then-process-the-record/104070/5 "2023-06-15T14:16:25Z")

</div>

Well so far so good via Postman, updating the MtlQueue table.  
Im struggling with the process button. Trans Type is STK-SHP.

The help states to use Move Material program but im unsure where to find that except for within Epicor and that looks to relate to Jobs.

---

<div class="post-metadata">

**Author:** ![Mark\_Wonsil](https://www.epiusers.help/user_avatar/www.epiusers.help/mark_wonsil/32/51594_2.png) [@Mark\_Wonsil](https://www.epiusers.help/u/Mark_Wonsil)\
**Post date:** [June 15, 2023, 4:06pm UTC](https://www.epiusers.help/t/read-csv-update-material-queue-and-then-process-the-record/104070/6 "2023-06-15T16:06:42Z")

</div>

> [@Ricky90](#):
>
> Im struggling with the process button

Trace is the only way to know!

---

<div class="post-metadata">

**Author:** ![klincecum](https://www.epiusers.help/user_avatar/www.epiusers.help/klincecum/32/100137_2.png) [@klincecum](https://www.epiusers.help/u/klincecum)\
**Post date:** [June 15, 2023, 4:12pm UTC](https://www.epiusers.help/t/read-csv-update-material-queue-and-then-process-the-record/104070/7 "2023-06-15T16:12:17Z")

</div>

![total physical response alo7 english GIF by ALO7.com](https://media4.giphy.com/media/7NRsIP2Zj43XGmTGfe/giphy.webp?cid=e90edba35l0273nexhtx4cm9ko9exw0ecy7t8v993y41dzbv&ep=v1_gifs_search&rid=giphy.webp&ct=g)

Not related but came up in search for relevant gif, couldn’t not share:

![Dog Drawing GIF](https://media3.giphy.com/media/dhe9WPSdH6Cas/giphy.webp?cid=e90edba3ii07a8t348z9c5dqy80khoelixuutu83wmaepsl3&ep=v1_gifs_search&rid=giphy.webp&ct=g)

---

<div class="post-metadata">

**Author:** ![Ricky90](https://www.epiusers.help/letter_avatar_proxy/v4/letter/r/ea5d25/32.png) [@Ricky90](https://www.epiusers.help/u/Ricky90)\
**Post date:** [June 16, 2023, 8:32am UTC](https://www.epiusers.help/t/read-csv-update-material-queue-and-then-process-the-record/104070/8 "2023-06-16T08:32:21Z")

</div>

I think i found it under ERP.BO.IssueReturn.SVC and custom method PerformMaterialMovement.  
I need to load the mtlqueue data into the function so i can build the Issue Returns dataset in order to move the mtl queue record. Thank you for pointing me in the right direction!

---

<div class="post-metadata">

**Author:** ![Ricky90](https://www.epiusers.help/letter_avatar_proxy/v4/letter/r/ea5d25/32.png) [@Ricky90](https://www.epiusers.help/u/Ricky90)\
**Post date:** [June 16, 2023, 1:20pm UTC](https://www.epiusers.help/t/read-csv-update-material-queue-and-then-process-the-record/104070/9 "2023-06-16T13:20:18Z")

</div>

i decided to change it up a bit.

I will use Powershell to read the CSV and call the Epicor Function but i decided to have a go using the widgets for the updating.  
am i better using UpdateExt from a Function rather than Update method?  
Also, should i use row mod as A or use U if the row already exists and im changing a field.

---

<div class="post-metadata">

**Author:** ![klincecum](https://www.epiusers.help/user_avatar/www.epiusers.help/klincecum/32/100137_2.png) [@klincecum](https://www.epiusers.help/u/klincecum)\
**Post date:** [June 16, 2023, 1:24pm UTC](https://www.epiusers.help/t/read-csv-update-material-queue-and-then-process-the-record/104070/10 "2023-06-16T13:24:45Z")

</div>

> [@Ricky90](#):
>
> am i better using UpdateExt from a Function rather than Update method?

It doesn’t really matter as long as you have the proper data for the call.  
You’ll end up at the same place in the end.

---

<div class="post-metadata">

**Author:** ![klincecum](https://www.epiusers.help/user_avatar/www.epiusers.help/klincecum/32/100137_2.png) [@klincecum](https://www.epiusers.help/u/klincecum)\
**Post date:** [June 16, 2023, 1:25pm UTC](https://www.epiusers.help/t/read-csv-update-material-queue-and-then-process-the-record/104070/11 "2023-06-16T13:25:38Z")

</div>

> [@Ricky90](#):
>
> Also, should i use row mod as A or use U if the row already exists and im changing a field.

Editing → “U”  
Adding → “A”  
Deleting → “D”

---

<div class="post-metadata">

**Author:** ![Ricky90](https://www.epiusers.help/letter_avatar_proxy/v4/letter/r/ea5d25/32.png) [@Ricky90](https://www.epiusers.help/u/Ricky90)\
**Post date:** [June 16, 2023, 2:36pm UTC](https://www.epiusers.help/t/read-csv-update-material-queue-and-then-process-the-record/104070/12 "2023-06-16T14:36:29Z")

</div>

Not sure why this isnt working as i expected… I have another directive doing similar on another table and that works…

![image](https://www.epiusers.help/uploads/default/original/3X/a/f/af1ca2474e4eb34262bdf4d59553252ab26ae7a9.png)

The update is tableset is bound to the getbyid variable.  
 ![image](https://www.epiusers.help/uploads/default/original/3X/6/8/68017b8f2175ebe06aecda36842983eb95e7a5eb.png)

Then i use a fill table by query, pass all the data from the same tableset and change the to Bin and row Mod to U.

---

<div class="post-metadata">

**Author:** ![Ricky90](https://www.epiusers.help/letter_avatar_proxy/v4/letter/r/ea5d25/32.png) [@Ricky90](https://www.epiusers.help/u/Ricky90)\
**Post date:** [June 16, 2023, 3:03pm UTC](https://www.epiusers.help/t/read-csv-update-material-queue-and-then-process-the-record/104070/13 "2023-06-16T15:03:16Z")

</div>

a simple bit of code wont update the record…  
The correct data is passing into the function as i used an exception to show the 3 variables are available

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

No errors in event viewer…or in postman when testing the function.

---

<div class="post-metadata">

**Author:** ![klincecum](https://www.epiusers.help/user_avatar/www.epiusers.help/klincecum/32/100137_2.png) [@klincecum](https://www.epiusers.help/u/klincecum)\
**Post date:** [June 16, 2023, 3:46pm UTC](https://www.epiusers.help/t/read-csv-update-material-queue-and-then-process-the-record/104070/14 "2023-06-16T15:46:11Z")

</div>

You should probably use the business object instead of the Db context.

---

<div class="post-metadata">

**Author:** ![klincecum](https://www.epiusers.help/user_avatar/www.epiusers.help/klincecum/32/100137_2.png) [@klincecum](https://www.epiusers.help/u/klincecum)\
**Post date:** [June 16, 2023, 9:57pm UTC](https://www.epiusers.help/t/read-csv-update-material-queue-and-then-process-the-record/104070/15 "2023-06-16T21:57:37Z")

</div>

If you are dead set on using the Db context though, you need to call:

`Db.Validate()` in a BPM, or `Db.SaveChanges()` in a function before `txScopeComplete()`

In a function, you will also have to enable read/write for that table, and in the tables screen  
on the right side, allow edit/update/whatever it says lol.

---

<div class="post-metadata">

**Author:** ![Ricky90](https://www.epiusers.help/letter_avatar_proxy/v4/letter/r/ea5d25/32.png) [@Ricky90](https://www.epiusers.help/u/Ricky90)\
**Post date:** [June 19, 2023, 10:16am UTC](https://www.epiusers.help/t/read-csv-update-material-queue-and-then-process-the-record/104070/16 "2023-06-19T10:16:03Z")

</div>

so near yet so far.

This code works in postman to process a material queue record.  
In Epicor however the first line in the body shows an error in event viewer.

 ![image](https://www.epiusers.help/uploads/default/original/3X/8/e/8e80a1ee32de3e89583b92a1528c425ebb119c0f.png)

The error given is Ice.Api.Exceptions.ApiException: Parameter plNegQtyAction is not found in the input object.

below is the working code in postman, im struggling to find the issue.

 ![image](https://www.epiusers.help/uploads/default/original/3X/d/f/dfefb5c163e0d85b5df7b018513b2bf43b192cb8.png)

---

<div class="post-metadata">

**Author:** ![klincecum](https://www.epiusers.help/user_avatar/www.epiusers.help/klincecum/32/100137_2.png) [@klincecum](https://www.epiusers.help/u/klincecum)\
**Post date:** [June 19, 2023, 11:48am UTC](https://www.epiusers.help/t/read-csv-update-material-queue-and-then-process-the-record/104070/17 "2023-06-19T11:48:13Z")

</div>

No need to call rest from inside.

If you do continue, IssueReturn should be an array.

---

<div class="post-metadata">

**Author:** ![Ricky90](https://www.epiusers.help/letter_avatar_proxy/v4/letter/r/ea5d25/32.png) [@Ricky90](https://www.epiusers.help/u/Ricky90)\
**Post date:** [June 19, 2023, 11:51am UTC](https://www.epiusers.help/t/read-csv-update-material-queue-and-then-process-the-record/104070/18 "2023-06-19T11:51:54Z")

</div>

I know but im struggling with adding a record to the IssueReturns method so i thought id try the rest method as i got that working ouside of epicor.

---

<div class="post-metadata">

**Author:** ![klincecum](https://www.epiusers.help/user_avatar/www.epiusers.help/klincecum/32/100137_2.png) [@klincecum](https://www.epiusers.help/u/klincecum)\
**Post date:** [June 19, 2023, 11:52am UTC](https://www.epiusers.help/t/read-csv-update-material-queue-and-then-process-the-record/104070/19 "2023-06-19T11:52:31Z")

</div>

I understand how you feel. I’ll see if I can futz with it.

---

<div class="post-metadata">

**Author:** ![Ricky90](https://www.epiusers.help/letter_avatar_proxy/v4/letter/r/ea5d25/32.png) [@Ricky90](https://www.epiusers.help/u/Ricky90)\
**Post date:** [June 19, 2023, 11:52am UTC](https://www.epiusers.help/t/read-csv-update-material-queue-and-then-process-the-record/104070/20 "2023-06-19T11:52:43Z")

</div>

what are the long term issues of using rest inside epicor?

[Next page](https://www.epiusers.help/t/read-csv-update-material-queue-and-then-process-the-record/104070.md?page=2)
