Update multiple rows in grid

Trying to see what the best way is to update multiple rows in a grid.

Currently, I have an App Studio Event off a button click. When the button is clicked, it does a GetByID of the JobPart BO to pull in the dataview data. After that, I have a row-update set to update the qtys. This works as intended, but it only updates one row at a time.

The overall goal would be to still have the button click, and when clicked, it would update the whole column, not just the row. I know there is a better way to do this, just struggling in putting it together. Any help or guidance would be greatly appreciated.

You’ll need a couple events to do it…

You’ll need to move your row update to its own event because you’re going to iterate through this event multiple times.

In your main event, instead of the Row Update, you want to use a DataView-Condition.

For the parameters of that dataview-condition:
DataView: The name of the dataview you want to evaluate
Results: matches
Expression: You can just leave this blank, because you want all rows to go through the iterative event.
Iterative Event: The name of the event that does your row update.

Here’s an example post… and you can find more posts if you search for “dataview condition” in the forum:

2 Likes

I followed the steps and saw some weirdness. When I triggered the dataview event, I could see the Iterative event retriggering properly 5 times, which is how many rows of data there were. The issue is that the event was not moving to the other rows, and it was only using the data from the first row. So essentially, the event was triggered 5 times all on the same row.

Could this be due to doing a GetID? It seemed to only look at one row of data, even though I could see multiple come back in the Debug.

I attempted to do a GetList and GetRows but both of those are giving me 500 Internal Errors and I am really struggling to see what I am doing wrong. We are in the Epicor Cloud - Live Sciences, so we do not access to any server logs like this. Kind of in a stuck state.

use a row-find/row-current-set in your iterating event to address the correct row (vs. the currently active row)
when you do the dataview condition, set Result = matches, you’ve already got your iterative event in the right place. This will pass the matching row data into a dataview called “matches” which is available to the iterating event and changes for each iteration.
Now start off your iterative event with a row-find, set dataview to the dataview to row-update, expression to “dataviewyouareupdating.keyfield = matches.keyfield” without quotes, epbinding to any field in any dataview (i use Filter.RowIndex) - it doesn’t matter what you choose here, as long as it’s not being used for anything else
next event widget is “row-current-set”, with “Row” set to {Filter.RowIndex} and dataview set to “dataviewyouareupdating”
This will move the selected row each time the iterative event fires.
Then, do your stuffs that you want to happen to each row.

See this post for more infos: App Studio, Events, Row-Find - Working example, - Kinetic ERP - Epicor User Help Forum

I think I know what my issue is, but I do not know how to fix it.
I did a row-find and row-current-set. What I saw happen was the iterating event triggering and updating multiple rows, but with incorrect values and even adding rows to the table. Since I can see the other rows updating, I know part of the set up was right, but it was still only using the single row to update. Was weird that it created its own rows though.

I think my issue lies with my JobPart dataview. When I call that using a GetById, it only pulls a single row because it is looking at JobNum and PartNum for the method params. All I want is for the Job number to be the same, not Part. Since it is applying both, in my JobPart Dataview, it only shows one row, and I think that is why it is reusing it. What I want it to show is just all records that have the same JobNum, that way the PartNum isn’t bound to any value. I tried to clear the PartNum field but get an error saying the value is missing. If I can get the JobPart view to show the data I want, then I think this may work. I attached some images to show what I am seeing.

Results of iterating event:

JobPart Dataview:

This error was thrown when the rows started to create themselves:

image

GetById Setup:

image

image

image

Iterating Event setup:

image

image

image

1 Like

Update:

Had a small epiphany while look at the Debug logs and trying a baseline customization.
I reverted some changes back to when it was just updating the focused row on click. In doing this, it finally hit me what the reason was for the iterating event using the same row. On click, the GetID is ran and pulls a single record matching Job and Part. My iterating event was then taking that single row and using it for each iteration. What needs to happen for the iterating event to work correctly, is I need to have the GetID run on the iterating event as well. This way that when the button is click, on each iteration, it will do a row GetId to get the Part of the row it is updating.
Now I just need figure out where to properly set the GetId in the iterations and see if my theory works. If there any suggestions, please let me know!

1 Like

Update 2:

My theory works but ran into another issue (just one after another ugh :persevere:) The iterating event loops through and updates the rows, but it skips rows. In the data I am working with, there are 5 rows. When the event runs, it updates rows 1, 3, and 5. Rows 2 and 4 are skipped. From how it looks, seems like it thinks there are no more rows, so when it goes the GetBy, it errors out because there is no PartNum match. If I re click the Button 2 more times, the other values will pull in.

Going to keep picking at this but starting to move to the direction of a Function. Have not messed with Functions too much but feel like it may be the best route. I will take any suggestions

Might I suggest sending the entire dataset to a function, do the work in the function, then send the dataset back to App Studio?

This is my end goal if I can achieve it :sweat_smile:

I know what capabilities Functions have but have yet to actually create and implement one. Just to make sure I am thinking right, create the Function that do all the dirty work (Get the data, update qtys) and then just have that Function set as an On Click event? I think I have a good understanding of what to do inside the Function, may struggle with knowing where to place it in App Studio

Yeah, I mean if that’s how you want it to work, sure. That’s definitely the easiest.
And the configuration in App Studio is super easy.

As long as you can handle the C# in the function, you’re good to go.

Just out of curiosity, to tackle what I am trying to do, would you go a different route?

Is this a native grid you’re adding a custom column to? If so, I would probably go this route first: Showing UD Field values from JobHead in Job Entry LandingPage View - Kinetic ERP - Epicor User Help Forum

If that didn’t work, I would send the dataset to the function, process there, then send it back.

I would save the dataview-condition for a last resort as it’s not the most efficient.

The overall idea of what I want to do is to take qtys from one table and update them to another. It is tied to Co-Parts in MES End Activity.

The required qtys for the Co-Parts sits in the JobPart table and service. I want to pull the data from JobPart to get the qtys and then update those qtys to the LaborPart qtys. I attempted to do this with a Method and Data directive but neither of them reflected the qty update. This is why I went the App Studio route, because it seemed like I needed to update the qtys client side and then have them update to server on a normal clock out.

I am hoping a Function can still do this. Currently working on that as I am learning Functions all together lol.

Mmm, I would be hesitant to do anything in App Studio for this. The general rule of thumb is to only use App Studio for visual updates to the client.
Any data modification that you’re actually committing (vs just displaying) should be done server-side (BPMs, Functions).

I’m not too familiar with co-parts, but method/data directive would have been my starting place for what you’re trying to do. I’d be curious to see how you wrote the BPM.

Functions are still an option as that’s server-side.

1 Like

Method and Data Directives were very basic and pretty much set up the same. I tried Pre and Post. The Method directives used Labor.Update. Data Directive I tried LaborDtl and LaborPart. Just seemed like nothing pulled through but could definitely be due to my set up.



image

Have an update with the BPMs:

I was able to get it to work!! Partly, but we are getting somewhere lol. I think part of my issue lied with me forgetting to set RowMod to U.

The only issue I have now is that the qtys are updating to the server before I want it to. What is happening is when the End Activity screen opens, it updates the rows with the qtys and shows them. When you try to complete the transaction, an error is thrown saying the Co-Part qtys dont balance. I think this is because the qtys are saving to the server before the completion. It then errors out because the system thinks the qtys showed client side need to be saved as well, even though they already have. I assume this is because I have it set to Update table by query, should I used another Set/Fill By?

Instead of Labor.Update, try a post-processing on Labor.EndActivity. Sounds like you just need to find the right timing is all.

This helped tremendously but has led to another problem. Technology just won’t let me win. The quantities pull in when I want, but they are not reflecting completed qtys on clock out.

Think this has something to do with the OnChangePartQty event. This event is what drives those fields to be updated client side. Tried to call it in the BPM but got an error saying there was more than one LaborPart record.

Chipping away at it. I am insanely grateful for the help given. I apologize for being “unknowledgeable” in situations. I think if I can get that OnChange event to run, either client or server side,

a cartoon of spongebob and a doctor with a stethoscope

No luck in getting this to work still. Has gotten to be very frustrating. My BPM is loading the data correctly. I can see the data in the Debug, I just cannot figure out how to commit it client side. With this being the MES End Activity screen, the system requires a “user input”, even if the data is already loaded from a BPM. I attempted the dataview condition again in combination with the BPM but got the same results as before with rows being skipped.

Think for what I want to do, I need custom code in either the BPM or Function that iterates the OnChangePartQty event for each row. Unfortunately, I am not well experienced with C# to do this. May be waving the white flag soon :pensive: