FKV on custom Data View

I’ve got a customization I’ve been tasked with. When I develop a new “blank” form, I want to be able to access data from other parts of the system and store them into “normal” DataViews. I can go in and create the FKV based on the data from my created DataView from within the customization.

The issue I’m having is, when I load up the form I get the following error:
image

The FKV does not show up in the designer, and I cannot remove it without going into the XML properties.

If I go in and reproduce the line that is causing the error after my custom DataView gets defined in the InitializeCustomCode() method, then everything works fine, even though I still get the error message the first time it tries to call the CallAddForeignKeyView method.

Is there a way that anybody knows that I can do a foreign key view on a blank UD form without tying it to the UD table?

I doubt this will accomplish what you need. A FKV is tied to a current DataView. If you don’t already have a DataView that will be your parent, then this is not the correct solution. I would offer a BAQView instead.

Yeah, the DataView is created “on the fly”, so the wizard seems to attach before my code runs which causes the error.

Ah. Then you will need to try to create the DataView before any other code runs. Not sure it’s possible, but are you creating the DataView at the very beginning of the InitializeCode?

Yes. The call happens before most of the other code in the “Read Only” section, so I think I’m out of luck. I’m going to try Plan “B”.

You can do this @Doug.C you just have to attach the FKV yourself (manually after your view is created)
This can be done just add it via the wizard, -> Save, go to View all Code and find the 1 or 2 lines that Epicor Adds for it something like this

Ice.Lib.Customization.PersonalizeCustomizeManager personalizeCustomizeManager = this.csm.PersonalizeCustomizeManager;
        personalizeCustomizeManager.CallAddForeignKeyView("AbcCode.ShipToCustNum", "CustomDV", "", "b6ad7728-0374-456a-82f4-572bcebe02ee", "SalesOrderAdapter", "IntegerGetByID", "AbcCode", true);

Then copy that code, delete the FKV from the Wizard and add it yourself (via that code) after your dataview is created.

Signature is

public bool CallAddForeignKeyView(string colName, string viewName, string tableName, string epiGuid, string adapterName, string getByType, string parViewName, bool defaultAdapter)

2 Likes

Those were the lines I was putting after my DV creation that allowed me to see it in the list. I had tried this, but there was another line after it relating to an EpiDataView which I didn’t look at closely enough. Defining that and adding this call worked.

Saved me a bunch of hours. Thanks!