Anyone know correct syntax to iterate through all columns in a temp table?. Straightforward syntax to iterate datacolumns in a customization but I can’t get it working in Method Directive.
Thank you in advance
Anyone know correct syntax to iterate through all columns in a temp table?. Straightforward syntax to iterate datacolumns in a customization but I can’t get it working in Method Directive.
Thank you in advance
foreach (var Row in Table)
Hello Marjorie thank you for reply but I need to loop columns in temp table not rows. Similar to this…
foreach (DataColumn col in ttOrderDtl.Columns)
but syntactically altered for temp tables in method directives.
What are you trying to accomplish?
Identify all column values that have changed without having to specify column name/s.
Not sure I fully understand your requirements but these use Entity framework objects I believe (someone will surely correct me if I’m wrong) and you can find some ways to do this, but similarly lots of questions about what you’re trying to accomplish arise. Perhaps knowing the requirements better would be more illuminating as to the correct tool/technique for the job
Objective to prevent saving record should a user change more than one item on a form. Eg take sales order header, user changes need by date and some other random header field, pre proc detects multiple alterations and prevents committing changes.
Should need by date change and no other alterations just need by date then proceed to commit changes.
It’s the syntax that’s causing me problems when attempting to loop through temp table columns. All ears if you have a better approach.
I think you’re going to have a horrible time if you try to implement something like that…
If we stick with the Sales Order Header example, what happens if a shipment occurs that closes that sales order? The method that changes the status of the shipment will invoke a change to the sales order fields and then calls for an update. If you have it so it kicks back if more than one fields is changed, you’re going to have chaos. Forget about it if you ever use DMT or an updatable BAQ.
Not to mention you’d be creating an absolutely terrible user experience if you did manage to get this working. Oh you want to change two fields on the sales order? Gotta make the change, save the entire thing, make your second change, etc. If you accidently make two changes, it will throw an error, then you have to refresh the form and try again, which will happen every time they select a need by date.
Getting back to the root of what I think you’re trying to do…which I’m still kind of unclear, but I think it’s wanting to ensure the data is committed? Epicor already does this for you and does it very well and handles large quantities of data and its state with ease.
Why? Everyone wants to be more productive multi-task and you are going backwards ![]()
I think the row has a .Columns property
What’s the backstory here I’m curious. Saving between every change sounds brutal, sincerely interested in the rational for this requirement.
Apologies, let me clarify…
Users with appropriate access privileges can edit sales orders.
Basic Example: User “ABC” is authorised to make changes to sales Order Date only. Need By, Ship By, Ship By Time etc etc cannot be altered by this user.
User makes a change to Order Date clicks save then save changes. If they make a change to Order Date and Need By, clicks save then throw exception.
I need a mechanism to identify exactly what the user has changed, if those alterations are permitted based on the users access privileges then proceed to save record otherwise throw exception. This is why I was going to cross-reference temp table data with Db data or where Row Mod = “” to identify exactly what columns have changed.
Any advice or guidance would be appreciated.
The way that we would normally do this is by creating a SECURITY GROUP for special people… for argument, lets call this:
*CanEditNeedBy"
*CanEditOrders"
So… now we can apply those security groups to the users…
Now you can then create a BPM that says "is the user a member of “CanEditNeedBy”. if the answer is NO, then check another condition: “Did the NeedBY Date change from ANY to Another”. if it did, then throw an error.
The above can be done without any C# code. You can do the entire check in one condition widget.
OH… you can also have a “CanAddOrders” vs “CanEditOrder” security groups… if they do not have the CanAddOrders group, then you can reject any Added orders… or added lines, but still accept changes.
Think about the security group as a filter of what people can/cannot do, and then further check to see what they did.
Hello Tim,
Yes I have used security groups for similar functionality in the past but I don’t think this will work in this instance unless I add all available fields to the condition.
User “ABC” can only edit Need By, how can I check if any other other field(s) has been changed without specifying each and every one of them in either code or condition? I want to prevent saving if user “ABC” has edited Need By and something else in order header.
It seems like there is a trust issue… I prefer to allow people to do their jobs, and give them rules. If you cannot trust the employees that are working to do their jobs without breaking policy, there is a problem. They either are allowed, or not allowed to edit records. My opinion…
You could turn on Tracking and then create queries that search for people that broke policy. But I don’t think you are going to get what you want without a bunch of code.
I know where you are coming from, but I still need to lock down access for certain users by identifying what they have attempted to change.
I’m getting stuck with the syntax required to iterate through temp table columns. Straightforward in a customisation but I don’t know correct syntax for BPM framework.
Perhaps you can think about updatable dashboard for those users.
I have used below code for storing value change in a different table. This should help you. Basically if there is any change in UD01, I am storing in UD08.
List datefields = new List(){“Date01”, “Date02”, “Date03”, “Date04”, “Date05” ,“Date06” , “Date07”};
foreach(string CDateFields in datefields)
{
if((DateTime?)ttUD01xRow[CDateFields] != (DateTime?)UD01[CDateFields] )
{
UD08[CDateFields] = (DateTime?)UD01[CDateFields] ;
}
}
Maybe just use Field Security
Hello Arul,
Appreciate feedback, the issue I see with this approach is each field would need to be added to the list.
Could use field security but I would like to use a BPM if possible. You kindly mentioned in an earlier post that row has a columns property would you know syntax for this in BPM framework?.