C# Help

The Set By Query is not triggering the RowMod in my BPM. After much trial and error, discussing with those more knowledgeable with Epicor, I am needing an Custom Code Widget where it causes the OrderRel.RowMod to be set to U. I am NOT a C# person and the Set Field doesn’t have RowMod in it. So, can someone help me with the C#?

So far I have gotten this: ttOrderRel_xRow[“RowMod”] = “U”;

Although I know I am missing info because I get the error: The name ‘ttOrderRel_xRow’ does not exist in the current context.

Its possibly the rest of the logic, which I do not know how to put into C#. Logic being Where ttOrderRel is the table and xRow is the current row you are working with.

In your bpm, can you tell me what the dataset variable is?

Just posted pics that have that info. But it set to ds.

Are all rows in your dataset going to need RowMod=“U?”

All changed rows. The logic is that if the OrderHed need by date is greater than OrderRel date, then change the OrderRel Need By date. Else Orderhed need by date. So, any changed rows.

Will I want to help right now, but I can’t at the moment.

I will take another look tomorrow. First thought for you is to search on this forum for how to update a data row.

Understandable! Thank you! Just for info, as I didn’t mention it, but this is a Method Directive.

So you are on an older version, so to be sure, right click in the code window, find parameters, and find what’s there. I Kinetic it’s ds but in older versions it’s ttsomething. So right click, find the parameters to make sure your object is in the method. Then you need to index into the table ( [0] is the first record, I don’t know if that is correct, you’ll have to experiment).

image

image

image

That being said, is there a reason that you can’t set these on pre-processing? Then you won’t have to call update again. Which, by the way if you do, the info that’s on the screen will not be the info that’s saved in the database, you’re going to have to hit refresh after you make the save in the UI without more code.

Thank you! I’ll do that! I tried preprocessing but everytime I would change a date, not even hit save yet, it would popup and say there wasn’t any data in ttOrderHed or something like that. I can get the exact error later in when I’m back at my desk. Is there something I’m missing that would cause that? I did have the condition set to if OrderHed.NeedByDate changes from any to other…

The dataset is only going to be included if something is actually changing. So if you are only changing something on the header, the BO won’t pull in the information for the Release, there is no need. So you have to change something on the release to tell the system that it needs the data.

I don’t quite get what you’re doing, but it might be better for you to latch onto another method, like on-change. Do a trace all the way through what ever you are doing, and see if there something before you go to save that can do what you want.

1 Like

In our company we have the date on the Order Release as a backorder. At times, they need to change the order need by date but they do not want it to affect all the releases unless the order need by date is greater than the order release. This way they can see which release is back ordered, which is based on the order release need by date.

@Banderson

So close! I needed the RowMod hit for every row, so I made some adjustments. However, still a little error. Didn’t know if you could point out my flaw. (Which could be huge and I may just be crazy! :crazy_face: :crazy_face:) Keep in mind, i had to google to get this far, as I really don’t know much in C#. So what may be obvious to others, is learning for me.

image

You are looping with the variable “row”

so it will be

row.RowMod  = "U";

in the loop.

So loops work like this. You have a variable, that is holding the think you are iterating on. You can call that whatever you want. Then when you are in the loop, that variable is that current thing (row in this case) and you can use the variable and it has properties just like the row does.

Foreach (var MyCurrentRow in ttOrderRel)
{
     MyCurrentRow.Field = "new thing";
}
1 Like

image

Thank you for the explanation as well! Side note: What’s a good place for me to learn enough C# for Epicor usage?

This is a good list of videos to get you started.

This is also an excellent class. It’s Python, but it’s still object oriented programming and covers explaining the above example. Both of these helped me immensely while learning to code.

Finally, this is an awesome website to go and practice. You can use any language you want, and there are all kinds of different levels of challenges. The IDE is within the web browser so you get to skip a lot of the setup that you would otherwise have to do (like Epicor does) and gets you right into coding. But you are figuring it out yourself. So start with the classes, then when those get boring find some puzzles to test your newly found skills.

1 Like

Thank you! It something I’ve been wanting todo for a while.

Lastly, the code worked, it did what it was supposed to do, but its still not updating the tables.

Forgetting everything else in this thread, if you were asked to create a bpm that compared the orderhed.needbydate to all orderrel.needbydate and if greater, change them, if not, leave them alone. How would you build it? I’mobviusly missing something and I think another perspective would be helpful as I may have tunnel vision.

I would put a post processing method directive on change need by date, and check your conditions, then change the fields if necessary. Then whey you go to save, the fields are already changed. (like I mentioned yesterday)

1 Like

AH! I was doing this form MasterUpdate because that is what the trace showed when changing the OrderRel. Maybe that is the difference I have been missing.

@Banderson , thanks for hopping in here.

Yeah, there are 2 things the trace tells. 1st, is where’s the method you want to trigger the thing you want to do. (like changing the date). And the second thing is how to do this thing you want to the in the BPM or custom code. If you can’t simply change the fields, you need to follow all the calls. But in this case, the dataset should have the release dates in it, and you should be able to change those fields, then they will get saved in the normal update.

2 Likes