Error when trying to update PartLot through code

I am trying to setup a button on the Lot Number Entry form to print a basic lot tag. I have fired printing on other forms using the click event to set a custom checkbox to true and forcing an update to fire a data directive. When I use the same syntax I have in the past

		MyDv.dataView[MyDv.Row]["BMFPrintTag_c"] = false;
		MyDv.dataView[MyDv.Row]["BMFPrintTag_c"] = true;

I receive the error:
“Ice.Lib.Framework.EpiSingleViewTransaction.Update()’ is inaccessible due to its protection level”.

Looking at object explorer there is no update method in the transaction. Is there another way I could approach this for that form or am I missing something else?

Thanks in advance!

I believe you need the following before and after

//Your updates here
//can't remeber if its oTrans.Update() or oTrans.Refresh()
1 Like

Thanks Chance, that gets me closer to what I was looking to do. It sets the checkbox on the form, but they still have to press save after to trigger the directive. Was hoping to do both in one click like I have on other forms but this is a great start.

Try reflection and call the save button from code.

Here is a snippet. You’ll need to change out the typeof, the form, and the tool to be SaveTool. You’ll also need to import Edit* using System.Reflection

			MethodInfo mi1 = typeof(Erp.UI.App.POEntry.POEntryForm).GetMethod("handleToolClick", BindingFlags.Instance | BindingFlags.NonPublic);
			mi1.Invoke(POEntryForm, new object[]{"RefreshTool",new Infragistics.Win.UltraWinToolbars.ToolClickEventArgs(POEntryForm.MainToolManager.Tools["RefreshTool"],null)}); ```

This worked perfectly Logan, Thank You!!

Just to give some context.

Part Lot Entry has a protected override Update method, it is because any class that inherits EpiSingleViewTransaction requires to implement its own Update. For some reason Epicor made it protected.

Reflection is sort of a hack to say I dont care if you are protected or private, execute it anyway.

Now you could have invoked the Update in reflection, or you could invoke the SaveTool which will run the Update.

The Right (not easy way) is to Get your own Instance of the Adapter and run your own adapter.Update() but not worth it for a simple scenario.

Another example I have for a Dashboard without requiring Reflection. Might not be applicable for a UI Form

MainController.AppControlPanel.HandleToolClick("RefreshTool", new Infragistics.Win.UltraWinToolbars.ToolClickEventArgs(MainController.MainToolManager.Tools["RefreshTool"], null));

That’s a much better way to implement it, I didn’t know about the HandleToolClick method!

I like the adapter updates, but I’ve found some of them don’t run Update for all actions and need stuff like UpdateMaster, DataTree, etc. If I’m saving a field that’s already on the form, I just quick pop in that reflection statement from a cheat sheet.

1 Like

Thanks for the insight on this, always trying to learn more on this front. This isn’t working on the UI form as you mentioned it might not. Receive the error “The name ‘MainController’ does not exist in the current context”. Reflection is working so will stick with that for this case, but going to try yours on a couple dashboards where I would like to add save and refresh buttons to the tracker. Thanks Again!