# Moving code from Method Directive to Data Directive generates an error

**URL:** <https://www.epiusers.help/t/moving-code-from-method-directive-to-data-directive-generates-an-error/66056>\
**Category:** Epicor ERP 10\
**Tags:** e10, bpm\
**Created:** [April 3, 2020, 10:50am UTC](https://www.epiusers.help/t/moving-code-from-method-directive-to-data-directive-generates-an-error/66056 "2020-04-03T10:50:29Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Adrian\_Mepham](https://www.epiusers.help/user_avatar/www.epiusers.help/adrian_mepham/32/6960_2.png) [@Adrian\_Mepham](https://www.epiusers.help/u/Adrian_Mepham)\
**Post date:** [April 3, 2020, 10:50am UTC](https://www.epiusers.help/t/moving-code-from-method-directive-to-data-directive-generates-an-error/66056/1 "2020-04-03T10:50:29Z")

</div>

Hi everyone,  
I have a BPM which was compiling and working as a Method Directive, I then realised that I needed a Data Directive instead.  
In the References and Usings area I have ‘Erp.Contracts.BO.Task’.

When I move the code to an In Transition DD, I get this error. Can anyone tell me what I need to do to correct it?

The type or namespace name ‘TaskTableset’ could not be found (are you missing a using directive or an assembly reference?)

Thanks in advance  
Adrian

---

<div class="post-metadata">

**Author:** ![Mark\_Wonsil](https://www.epiusers.help/user_avatar/www.epiusers.help/mark_wonsil/32/51594_2.png) [@Mark\_Wonsil](https://www.epiusers.help/u/Mark_Wonsil)\
**Post date:** [April 3, 2020, 11:49am UTC](https://www.epiusers.help/t/moving-code-from-method-directive-to-data-directive-generates-an-error/66056/2 "2020-04-03T11:49:01Z")

</div>

Data Directives only work on the current table. There is no notion of DataSets like you have in Method Directives that work on a Business Object. Think database trigger.

---

<div class="post-metadata">

**Author:** ![Adrian\_Mepham](https://www.epiusers.help/user_avatar/www.epiusers.help/adrian_mepham/32/6960_2.png) [@Adrian\_Mepham](https://www.epiusers.help/u/Adrian_Mepham)\
**Post date:** [April 3, 2020, 12:14pm UTC](https://www.epiusers.help/t/moving-code-from-method-directive-to-data-directive-generates-an-error/66056/3 "2020-04-03T12:14:18Z")

</div>

Thanks @Mark_Wonsil, I thought about it, and googled database trigger but still not sure what I need to do. The directive is on the SysAgentSched. I am trying to get it to run on a schedule

---

<div class="post-metadata">

**Author:** ![ckrusen](https://www.epiusers.help/user_avatar/www.epiusers.help/ckrusen/32/50584_2.png) [@ckrusen](https://www.epiusers.help/u/ckrusen)\
**Post date:** [April 3, 2020, 1:32pm UTC](https://www.epiusers.help/t/moving-code-from-method-directive-to-data-directive-generates-an-error/66056/4 "2020-04-03T13:32:29Z")

</div>

I think you have to abandon the notion of BO’s in a DD (aside from the Execute BO widget).

You might need to make a MD (Method Directive) for any BO related functionality, and call that MD from the DD.

---

<div class="post-metadata">

**Author:** ![Adrian\_Mepham](https://www.epiusers.help/user_avatar/www.epiusers.help/adrian_mepham/32/6960_2.png) [@Adrian\_Mepham](https://www.epiusers.help/u/Adrian_Mepham)\
**Post date:** [April 3, 2020, 6:13pm UTC](https://www.epiusers.help/t/moving-code-from-method-directive-to-data-directive-generates-an-error/66056/5 "2020-04-03T18:13:01Z")

</div>

Thanks @ckrusen, I had a feeling that it was never going to work.

Is it an easy thing to do? I straight away looked in hope for a widget but there doesn’t appear to be one. Is it done in custom code?

---

<div class="post-metadata">

**Author:** ![ckrusen](https://www.epiusers.help/user_avatar/www.epiusers.help/ckrusen/32/50584_2.png) [@ckrusen](https://www.epiusers.help/u/ckrusen)\
**Post date:** [April 3, 2020, 6:24pm UTC](https://www.epiusers.help/t/moving-code-from-method-directive-to-data-directive-generates-an-error/66056/6 "2020-04-03T18:24:31Z")

</div>

Whoops … I was think of the conditions when a Pre- and Post- MD are required. Not about mixing DD’s and MD’s.

Why did you have to move the BPM from a MD to a DD? Because other BO’s may invoke the change your original MD was trying to account for, and don’t want to have near duplicate MD’s for all the different ways the field and table the DD monitors could be changed?

I think of MD’s as being used when a “function” happens. And DD’s when a “variable” (the DB table) is changed.

---

<div class="post-metadata">

**Author:** ![danbedwards](https://www.epiusers.help/letter_avatar_proxy/v4/letter/d/9f8e36/32.png) [@danbedwards](https://www.epiusers.help/u/danbedwards)\
**Post date:** [April 3, 2020, 6:49pm UTC](https://www.epiusers.help/t/moving-code-from-method-directive-to-data-directive-generates-an-error/66056/7 "2020-04-03T18:49:04Z")

</div>

Just a tip that helps if you are used to using a method directive with the BO widget and then need to convert it to code. Assuming you are on-premise, you can do this for a little cheat or help.  
**1.** Create method directive with BO widget and enable  
**2.** Look in the Folder where your app server is installed and in the \BPM\Sources\BO\ and then in the method you used (task.update in example) and then the most current folder. Open that folder.  
**3.** Open the Pre or Post update .cs file and you can see how the widget was converted to C# code  
**4.** You can pretty much copy the code, add some references, and be off and running.

 ![image](https://epiusers.help/uploads/default/original/3X/8/1/81c95415fa55c4468f57f54414d5aa4fffd5bc3b.png)

---

<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:** [April 3, 2020, 7:26pm UTC](https://www.epiusers.help/t/moving-code-from-method-directive-to-data-directive-generates-an-error/66056/8 "2020-04-03T19:26:04Z")

</div>

> [@ckrusen](#):
>
> I think you have to abandon the notion of BO’s in a DD (aside from the Execute BO widget).

This isn’t 100% true. I’m building a BPM as a Data Directive that uses all code and can make BO calls.

---

<div class="post-metadata">

**Author:** ![ckrusen](https://www.epiusers.help/user_avatar/www.epiusers.help/ckrusen/32/50584_2.png) [@ckrusen](https://www.epiusers.help/u/ckrusen)\
**Post date:** [April 3, 2020, 7:27pm UTC](https://www.epiusers.help/t/moving-code-from-method-directive-to-data-directive-generates-an-error/66056/9 "2020-04-03T19:27:33Z")

</div>

The fact that there is no Call BO widget in DD’s makes my statement 100% false

---

<div class="post-metadata">

**Author:** ![zwilli526](https://www.epiusers.help/user_avatar/www.epiusers.help/zwilli526/32/50966_2.png) [@zwilli526](https://www.epiusers.help/u/zwilli526)\
**Post date:** [April 3, 2020, 9:15pm UTC](https://www.epiusers.help/t/moving-code-from-method-directive-to-data-directive-generates-an-error/66056/10 "2020-04-03T21:15:35Z")

</div>

I’ve had issues copying code widgets between BPMs. Same thing happened where the references weren’t recognized. Usually I just rebuild the BPM from scratch or copy everything but the execute code blocks.

---

<div class="post-metadata">

**Author:** ![Chris\_Conn](https://www.epiusers.help/user_avatar/www.epiusers.help/chris_conn/32/93797_2.png) [@Chris\_Conn](https://www.epiusers.help/u/Chris_Conn)\
**Post date:** [April 4, 2020, 12:09am UTC](https://www.epiusers.help/t/moving-code-from-method-directive-to-data-directive-generates-an-error/66056/11 "2020-04-04T00:09:18Z")

</div>

perhaps try

using Ice.Tabletsets;  
using Erp.Tables;

---

<div class="post-metadata">

**Author:** ![timshuwy](https://www.epiusers.help/user_avatar/www.epiusers.help/timshuwy/32/90122_2.png) [@timshuwy](https://www.epiusers.help/u/timshuwy)\
**Post date:** [April 4, 2020, 12:37am UTC](https://www.epiusers.help/t/moving-code-from-method-directive-to-data-directive-generates-an-error/66056/12 "2020-04-04T00:37:28Z")

</div>

if you did an include in your widget code, and then copied the widget, for some reason, it doesnt recognize the include UNTIL you open up the include screen and save… THEN it works. You dont have to do anything other than open/close/save.
