# FKV on custom Data View

**URL:** <https://www.epiusers.help/t/fkv-on-custom-data-view/72243>\
**Category:** Epicor ERP 10\
**Tags:** customization, epicor\
**Created:** [October 27, 2020, 6:15pm UTC](https://www.epiusers.help/t/fkv-on-custom-data-view/72243 "2020-10-27T18:15:16Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Doug.C](https://www.epiusers.help/user_avatar/www.epiusers.help/doug.c/32/26714_2.png) [@Doug.C](https://www.epiusers.help/u/Doug.C)\
**Post date:** [October 27, 2020, 6:15pm UTC](https://www.epiusers.help/t/fkv-on-custom-data-view/72243/1 "2020-10-27T18:15:16Z")

</div>

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](https://www.epiusers.help/uploads/default/original/3X/9/2/92e04e9e2731bc5e63f9b0a3f006f26325e46e45.png)

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?

---

<div class="post-metadata">

**Author:** ![Jason\_Woods](https://www.epiusers.help/user_avatar/www.epiusers.help/jason_woods/32/80101_2.png) [@Jason\_Woods](https://www.epiusers.help/u/Jason_Woods)\
**Post date:** [October 27, 2020, 6:47pm UTC](https://www.epiusers.help/t/fkv-on-custom-data-view/72243/2 "2020-10-27T18:47:03Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Doug.C](https://www.epiusers.help/user_avatar/www.epiusers.help/doug.c/32/26714_2.png) [@Doug.C](https://www.epiusers.help/u/Doug.C)\
**Post date:** [October 27, 2020, 7:03pm UTC](https://www.epiusers.help/t/fkv-on-custom-data-view/72243/3 "2020-10-27T19:03:38Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Jason\_Woods](https://www.epiusers.help/user_avatar/www.epiusers.help/jason_woods/32/80101_2.png) [@Jason\_Woods](https://www.epiusers.help/u/Jason_Woods)\
**Post date:** [October 27, 2020, 7:05pm UTC](https://www.epiusers.help/t/fkv-on-custom-data-view/72243/4 "2020-10-27T19:05:08Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Doug.C](https://www.epiusers.help/user_avatar/www.epiusers.help/doug.c/32/26714_2.png) [@Doug.C](https://www.epiusers.help/u/Doug.C)\
**Post date:** [October 27, 2020, 7:08pm UTC](https://www.epiusers.help/t/fkv-on-custom-data-view/72243/5 "2020-10-27T19:08:12Z")

</div>

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”.

---

<div class="post-metadata">

**Author:** ![josecgomez](https://www.epiusers.help/user_avatar/www.epiusers.help/josecgomez/32/55731_2.png) [@josecgomez](https://www.epiusers.help/u/josecgomez)\
**Post date:** [October 27, 2020, 8:33pm UTC](https://www.epiusers.help/t/fkv-on-custom-data-view/72243/6 "2020-10-27T20:33:10Z")

</div>

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

```auto
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

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

```

---

<div class="post-metadata">

**Author:** ![Doug.C](https://www.epiusers.help/user_avatar/www.epiusers.help/doug.c/32/26714_2.png) [@Doug.C](https://www.epiusers.help/u/Doug.C)\
**Post date:** [October 27, 2020, 8:55pm UTC](https://www.epiusers.help/t/fkv-on-custom-data-view/72243/7 "2020-10-27T20:55:15Z")

</div>

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!
