# Call Business Object Within BPM Using C# - Help Needed

**URL:** <https://www.epiusers.help/t/call-business-object-within-bpm-using-c-help-needed/106318>\
**Category:** Kinetic ERP\
**Tags:** baq, customization, bpm\
**Created:** [August 22, 2023, 4:48pm UTC](https://www.epiusers.help/t/call-business-object-within-bpm-using-c-help-needed/106318 "2023-08-22T16:48:46Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![dgreenEA](https://www.epiusers.help/user_avatar/www.epiusers.help/dgreenea/32/22635_2.png) [@dgreenEA](https://www.epiusers.help/u/dgreenEA)\
**Post date:** [August 22, 2023, 4:48pm UTC](https://www.epiusers.help/t/call-business-object-within-bpm-using-c-help-needed/106318/1 "2023-08-22T16:48:47Z")

</div>

I’m trying to rewrite a BPM we use as an update method on a BAQ.

Currently, the BPM goes through a ton of BO method widgets and works perfectly for a single return BAQ.

We are updating the BAQ to return multiple “dirty” rows and we need the BPM to be able to handle that. My thought was to rewrite the entire BPM into a C# custom code block and put a foreach statement around it.

The problem I have currently is that I can’t seem to get the syntax right. Having gone through some of the code snippets within the below post I tried using the following line:

> var bo=Erp.BO.EngWorkBenchSvc.GetService(Db);

Referenced Post:

> [@Adding Business Object Calls into Custom C# Method Directive code](https://www.epiusers.help/t/adding-business-object-calls-into-custom-c-method-directive-code/79396):
>
> Ladies & Gentlemen, Epicor E70.2.700 Public cloud here and I have a requirement in a Pre-Processing Method Directive to add a record into the UD Codes filewith a specific CodetypeID and CodeID if it doesn’t exist already. getting data from the ttable isn’t a problem using code similar to the following: foreach(var MyUDCodes in (from ThisUDCodes in Db.UDCodes.With(LockHint.UpdLock) where ThisUDCodes.Company == Session.CompanyID && ThisUDCodes.CodeTypeID == "NEXT" …

Doing this I get the following error:  
 ![image](https://www.epiusers.help/uploads/default/original/3X/9/e/9e66ddf4509096ebc6e10e56cfe87e1a675e689a.png)  
 ![image](https://www.epiusers.help/uploads/default/original/3X/7/0/705c684484b1715c442a4e53f37865d19cb18d2a.png)

I could really use a refresher on the syntax behind this stuff if anyone has a cheat sheet somewhere.

---

<div class="post-metadata">

**Author:** ![jtownsend](https://www.epiusers.help/letter_avatar_proxy/v4/letter/j/f14d63/32.png) [@jtownsend](https://www.epiusers.help/u/jtownsend)\
**Post date:** [August 22, 2023, 5:03pm UTC](https://www.epiusers.help/t/call-business-object-within-bpm-using-c-help-needed/106318/2 "2023-08-22T17:03:08Z")

</div>

Personally, I put all my custom code stuff in functions and call that from BPMs. Keeps all my poorly written garbage in one place for convenient bug-fixing. It also keeps the BPM’s super stripped down (usually just a condition block followed by a function call block). I find this way, way more manageable.

Once in there, I’m abusing this.CallService. You then put the service in the \<\> and a lamba expression (x =\> x.stuff) to access the methods within the service.

Simple example that could easily be implemented in a widget if it wasn’t for other requirements that I had.

```auto
this.CallService<Erp.Contracts.EngWorkBenchSvcContract>(ewb => ewb.Update(ref ewbTS));

```

Example using parameters. Lots of parameters.

```auto
 this.CallService<Erp.Contracts.EngWorkBenchSvcContract>(ewb =>
        ewb.GetDetailsFromMethods(
            EcoGroup,
            PartNum,
            Revision,
            method.AltMethod,
            DateTime.Today, //AsOfDate
            false, //CompleteTree Returns whole ECOGroup?
            method.basePartNum,
            method.baseRevisionNum,
            method.baseAltMethod,
            false, //return dataset
            false, //ipGetDatasetForTree True = callGetDatasetFor, False = call GetByID
            false, //UseMethodForParts
            false, false /*Configurator-related*/));

```

---

<div class="post-metadata">

**Author:** ![klincecum](https://www.epiusers.help/user_avatar/www.epiusers.help/klincecum/32/100137_2.png) [@klincecum](https://www.epiusers.help/u/klincecum)\
**Post date:** [August 22, 2023, 5:09pm UTC](https://www.epiusers.help/t/call-business-object-within-bpm-using-c-help-needed/106318/3 "2023-08-22T17:09:52Z")

</div>

> [@jtownsend](#):
>
> It also keeps the BPM’s super stripped down (usually just a condition block followed by a function call block).

This is the way. It’s very easy to manage.

And don’t forget descriptive groups in the BPMs !

---

<div class="post-metadata">

**Author:** ![jtownsend](https://www.epiusers.help/letter_avatar_proxy/v4/letter/j/f14d63/32.png) [@jtownsend](https://www.epiusers.help/u/jtownsend)\
**Post date:** [August 22, 2023, 5:16pm UTC](https://www.epiusers.help/t/call-business-object-within-bpm-using-c-help-needed/106318/4 "2023-08-22T17:16:51Z")

</div>

> [@klincecum](#):
>
> And don’t forget descriptive groups in the BPMs !

And the description field in Function Maint.  
Also the notes tab, where I usually document the inputs/outputs plus any other development notes.

---

<div class="post-metadata">

**Author:** ![gpayne](https://www.epiusers.help/user_avatar/www.epiusers.help/gpayne/32/55751_2.png) [@gpayne](https://www.epiusers.help/u/gpayne)\
**Post date:** [August 22, 2023, 6:55pm UTC](https://www.epiusers.help/t/call-business-object-within-bpm-using-c-help-needed/106318/5 "2023-08-22T18:55:59Z")

</div>

Change to this

```auto
var bo = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.EngWorkBenchSvcContract>(Db);

```

Add a reference

 ![image](https://www.epiusers.help/uploads/default/original/3X/a/a/aaefbb79814479d509a6e12dc322d25ada491898.png)  
 ![image](https://www.epiusers.help/uploads/default/original/3X/8/e/8e36c06223c1e37098e51193a5a0cbc67fb0c00a.png)

---

<div class="post-metadata">

**Author:** ![dgreenEA](https://www.epiusers.help/user_avatar/www.epiusers.help/dgreenea/32/22635_2.png) [@dgreenEA](https://www.epiusers.help/u/dgreenEA)\
**Post date:** [August 22, 2023, 8:12pm UTC](https://www.epiusers.help/t/call-business-object-within-bpm-using-c-help-needed/106318/6 "2023-08-22T20:12:46Z")

</div>

The code works for the original request. I’m now trying to use it with one of the other BO methods.

> this.CallService\<Erp.Contracts.EngWorkBenchSvcContract\>(ewb =\> ewb.GetDatasetForTree(myUser,myPart,myRev,“”,“”,BpmFunc.Now(),false,false, out tsWB));

The BO calls for 8 in variables and 1 out variable. However, when I have the out variable in there I get the following error:

![image](https://www.epiusers.help/uploads/default/original/3X/c/b/cbf0e55fc2c0673a9f2eaa19d4adafcdd9c5e4f5.png)

---

<div class="post-metadata">

**Author:** ![jtownsend](https://www.epiusers.help/letter_avatar_proxy/v4/letter/j/f14d63/32.png) [@jtownsend](https://www.epiusers.help/u/jtownsend)\
**Post date:** [August 22, 2023, 8:55pm UTC](https://www.epiusers.help/t/call-business-object-within-bpm-using-c-help-needed/106318/7 "2023-08-22T20:55:01Z")

</div>

The method itself returns the dataset. Try this:

```auto
tsWB = this.CallService<Erp.Contracts.EngWorkBenchSvcContract>(ewb => 			
	ewb.GetDatasetForTree(myUser, myPart, myRev,
                          “”, “”, BpmFunc.Now(), false, false));

```

Are you familiar with the API Swagger page? Biz Logic Teseter? Both are super useful when trying to test out unfamiliar BO’s.

Related note, be absolutely sure you want to use that method. It believe it will return **everything** in the eco group, which if (like most places) your engineers keep their groups open permanently, can mean returning hundreds of old parts long-since checked back in.

---

<div class="post-metadata">

**Author:** ![dgreenEA](https://www.epiusers.help/user_avatar/www.epiusers.help/dgreenea/32/22635_2.png) [@dgreenEA](https://www.epiusers.help/u/dgreenEA)\
**Post date:** [August 23, 2023, 2:23pm UTC](https://www.epiusers.help/t/call-business-object-within-bpm-using-c-help-needed/106318/8 "2023-08-23T14:23:10Z")

</div>

Im familiar with the API Swagger page. Never heard of the Biz Logic Teseter. Is it available to Gov Cloud users?

Thanks for explaining how the service handles the outbound return. Using the code you provided I get the following error:

![image](https://www.epiusers.help/uploads/default/original/3X/6/c/6c28afae1c47a0abebd59dacb3f0d416a4812291.png)

In this instance, tsWB is a table set (EngWorkBenchTableset). Is this error because I have not declared tsWB in the c# code? If so how would I go about declaring a table set in this instance?

---

<div class="post-metadata">

**Author:** ![jtownsend](https://www.epiusers.help/letter_avatar_proxy/v4/letter/j/f14d63/32.png) [@jtownsend](https://www.epiusers.help/u/jtownsend)\
**Post date:** [August 23, 2023, 2:35pm UTC](https://www.epiusers.help/t/call-business-object-within-bpm-using-c-help-needed/106318/9 "2023-08-23T14:35:19Z")

</div>

> [@dgreenEA](#):
>
> Never heard of the Biz Logic Teseter. Is it available to Gov Cloud users?

No, that one is just for locally hosted installs.

> [@dgreenEA](#):
>
> Is this error because I have not declared tsWB in the c# code?

Yes.

> [@dgreenEA](#):
>
> If so how would I go about declaring a table set in this instance?

```auto
//The verbose, technically recommended way to instantiate a new object.
EngWorkBenchTableset tsWB = new EngWorkBenchTableset();

//The way everyone actually does it.
var tsWB = new EngWorkBenchTableset();

```

You can also declare it at the function level if it’s going to be used outside of the one code block.

 ![image](https://www.epiusers.help/uploads/default/original/3X/9/a/9ab8057df5834c9b9551e4adc7e8fb2a249bb40e.png)

---

<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:** [August 23, 2023, 2:41pm UTC](https://www.epiusers.help/t/call-business-object-within-bpm-using-c-help-needed/106318/10 "2023-08-23T14:41:26Z")

</div>

> [@dgreenEA](#):
>
> Never heard of the Biz Logic Teseter. Is it available to Gov Cloud users?

I have used the Business Logic Tester successfully in the cloud. It uses the client DLLs to connect to the server and not REST. Think of it as Swagger for WCF. If you can connect via the Smart Client, then the Business Object Tester should work too. I had to ask Epicor support to send it to me. On-Prem users can install it from their servers.

---

<div class="post-metadata">

**Author:** ![dgreenEA](https://www.epiusers.help/user_avatar/www.epiusers.help/dgreenea/32/22635_2.png) [@dgreenEA](https://www.epiusers.help/u/dgreenEA)\
**Post date:** [August 23, 2023, 2:48pm UTC](https://www.epiusers.help/t/call-business-object-within-bpm-using-c-help-needed/106318/11 "2023-08-23T14:48:09Z")

</div>

After declaring tsWB both ways you described I still get the same error. Im wondering if this is saying that what is being returned by the service call is void.

Also really appreciate all the help with this!

---

<div class="post-metadata">

**Author:** ![jtownsend](https://www.epiusers.help/letter_avatar_proxy/v4/letter/j/f14d63/32.png) [@jtownsend](https://www.epiusers.help/u/jtownsend)\
**Post date:** [August 23, 2023, 3:38pm UTC](https://www.epiusers.help/t/call-business-object-within-bpm-using-c-help-needed/106318/12 "2023-08-23T15:38:45Z")

</div>

I actually had to test it out myself since I didn’t have an example offhand to compare. Turns out I had to enclose the method call in a bracket to get it to work. Why? No idea, but I’ve now got homework for later.

```auto
this.CallService<Erp.Contracts.EngWorkBenchSvcContract>(ewb =>
{
    var tsWB = ewb.GetDatasetForTree(ecoGrp, part, rev, "",
                                     BpmFunc.Now(), false, false);
});

```

EDIT: key terms here are “lambda expressions” vs “lambda statements”. This is a statement lambda. The expression lambda wasn’t working. My guess is that, despite this being a single line, this is actually doing a couple things in one go thus it requires a statement block with the braces (which can be omitted on simpler expressions).

Good news is that I don’t think I need to rewrite anything I’ve done up to now. I rarely use the built-in Get methods (and when I do, I use the widgets) because they pull far, far more data than I typically need. LINQ FTW.

---

<div class="post-metadata">

**Author:** ![gpayne](https://www.epiusers.help/user_avatar/www.epiusers.help/gpayne/32/55751_2.png) [@gpayne](https://www.epiusers.help/u/gpayne)\
**Post date:** [August 23, 2023, 4:13pm UTC](https://www.epiusers.help/t/call-business-object-within-bpm-using-c-help-needed/106318/13 "2023-08-23T16:13:39Z")

</div>

I love when helping turns into learning. 🙂

---

<div class="post-metadata">

**Author:** ![dgreenEA](https://www.epiusers.help/user_avatar/www.epiusers.help/dgreenea/32/22635_2.png) [@dgreenEA](https://www.epiusers.help/u/dgreenEA)\
**Post date:** [August 23, 2023, 5:15pm UTC](https://www.epiusers.help/t/call-business-object-within-bpm-using-c-help-needed/106318/14 "2023-08-23T17:15:29Z")

</div>

That worked perfectly! Thanks for the clarification on the cause.

My next related question is how do we state that we wish to ignore outbound or inbound variables when there are multiple?

> ```
> this.CallService<Erp.Contracts.EngWorkBenchSvcContract>(ewb =>
> {
> tsWB = ewb.CheckOut(myUser, myPart, myRev,"","", BpmFunc.Now(), false, myPass, false, true, false, out false, out false, out false);
> });
> 
> ```

![image](https://www.epiusers.help/uploads/default/original/3X/9/6/9646b8e0bde004d2a92fd7e6a9e7933a25c86a25.png)

In the above example, there are four total outputs for the service call. The first three need to be ignored and the fourth is the output to our table set from earlier.

I tried leaving them blank but it called for a bool. I changed them to bool false statements. Then it called for an “out” statement in front of the bool. I added that and ended up with this error.

What would be the proper syntax for this?

---

<div class="post-metadata">

**Author:** ![jtownsend](https://www.epiusers.help/letter_avatar_proxy/v4/letter/j/f14d63/32.png) [@jtownsend](https://www.epiusers.help/u/jtownsend)\
**Post date:** [August 23, 2023, 5:35pm UTC](https://www.epiusers.help/t/call-business-object-within-bpm-using-c-help-needed/106318/15 "2023-08-23T17:35:59Z")

</div>

Declare the variables beforehand. You don’t have to use them after the method call.

```auto
    string checkedOutRev, msg;
    bool flag;

    this.CallService<Erp.Contracts.EngWorkBenchSvcContract>(ewb =>
        ewb.CheckOut(EcoGroup,
        PartNum,
        Revision,
        altMethods.FirstOrDefault(),
        DateTime.Today,
        false, //ipCompleteTree returns complete tree for ipGetDatasetForTree
        true, //ipValidPassword
        false, //ipReturn returns refreshed dataset
        false, //ipGetDatasetForTree False = call GetByID
        true, //ipUseMethodForParts
        out checkedOutRev, out msg, out flag) );

```

---

<div class="post-metadata">

**Author:** ![dgreenEA](https://www.epiusers.help/user_avatar/www.epiusers.help/dgreenea/32/22635_2.png) [@dgreenEA](https://www.epiusers.help/u/dgreenEA)\
**Post date:** [August 30, 2023, 1:47pm UTC](https://www.epiusers.help/t/call-business-object-within-bpm-using-c-help-needed/106318/16 "2023-08-30T13:47:22Z")

</div>

I got all my code built out and the syntax comes out good. However, I am getting an error when running it.

The error seems to be happening on line 214 of the following code:

```auto
//Get user input on part rev from BAQ selection
//Get user op description text from 
//Get user change description from form
//Get op sequence code from user.
int counter = 0;
int counter2 = 0;
string checkedOutRev, msg;
bool flag;
myPart = callContextBpmData.Character01;
myRev = callContextBpmData.Character02;
//myComment = callContextBpmData.Character03; // defined after the dataset has been pulled. This helps combine the existing comment with the new comment.
myReason = callContextBpmData.Character04;
myUser = callContextBpmData.Character05;
myOp = Convert.ToInt32(callContextBpmData.Number01);
myResGrpID = callContextBpmData.Character06;
myQtyPerParent = Convert.ToDecimal(callContextBpmData.Number02);
mySetHours = Convert.ToDecimal(callContextBpmData.Number03);
myProdTime = Convert.ToDecimal(callContextBpmData.Number04);
SkipCheckIn = callContextBpmData.Checkbox01;
EngWorkBenchTableset tsWB = new EngWorkBenchTableset();

//check all inputs
this.PublishInfoMessage("myPart: " + myPart + "\n myRev: " + myRev + "\n myReason: " + myReason + "\n myUser: " + myUser + "\n myOp: " + myOp + "\n myResGrpID: " + myResGrpID , Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "", "");

//Module: PromptPW1
this.CallService<Erp.Contracts.EngWorkBenchSvcContract>(ewb => ewb.PromptForPassword(out myPass));

//Module: GetDSTree 6
this.CallService<Erp.Contracts.EngWorkBenchSvcContract>(ewb =>
{
    tsWB = ewb.GetDatasetForTree(myUser, myPart, myRev,"","", BpmFunc.Now(), false, false);
});

//Module: Op Seq Taken? 1
//PUT IN QUERY CHECK IF OP EXISTS
foreach (var PartOpr_iterator in (from r in Db.PartOpr where r.Company == Session.CompanyID && r.PartNum == myPart && r.RevisionNum == myRev && r.OprSeq == myOp select r))
{ 

//Module: No Valid Op! 1
  if (PartOpr_iterator == null)
  {
    this.PublishInfoMessage("This part and revision does not have Op " + myOp + ". Please review the operations for this part and select a valid Op sequence number.", Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "", "");
    break;
  }
}

//Module: ECOUser? 1
//PUT IN QUERY CHECK IF USER ECO EXISTS
foreach (var ECOGroup_iterator in (from r in Db.ECOGroup where r.Company == Session.CompanyID && r.GroupID == myUser select r))
{ 

//Module: No ECO Group! 1
  if (ECOGroup_iterator == null)
  {
    this.PublishInfoMessage("You do not have permission to make this change. Please contact ERPSupport to add your userID to the ECO group list.", Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "", "");
    break;
  }
}

//Module: GetDsTree 1
this.CallService<Erp.Contracts.EngWorkBenchSvcContract>(ewb =>
{
    tsWB = ewb.GetDatasetForTree(myUser, myPart, myRev,"","", BpmFunc.Now(), false, false);
});

counter = 0;

//Module: SkipCHeckin?2
if(SkipCheckIn == true)
{

//Module: CheckedOutAnyone? 1
    foreach (var ECORev_iterator in (from r in Db.ECORev where r.Company == Session.CompanyID && r.PartNum == myPart && r.RevisionNum == myRev && r.CheckedOut == true select r))
    { 
        counter++;
    }
    
    if(counter > 0)
    {
    
//Module: CheckedOutByYou? 2
        foreach (var ECORev_iterator in (from r in Db.ECORev where r.Company == Session.CompanyID && r.GroupID == myUser &&r.PartNum == myPart && r.RevisionNum == myRev && r.CheckedOut == true select r))
        { 
            counter2++;
        }
        
//Module: Already Checked Out! 2        
        if(counter2 == 0)
        {
             this.PublishInfoMessage("This part and revision has already been checked out to another user. Please check the revision back in before editing any operations.", Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "", "");
             //break;   
        }
    }
    else
    {
//Module: CheckOut 1
        this.CallService<Erp.Contracts.EngWorkBenchSvcContract>(ewb =>
        {
            tsWB = ewb.CheckOut(myUser, myPart, myRev,"","", BpmFunc.Now(), false, myPass, false, true, false, out checkedOutRev, out msg, out flag);
        });
    }
}
else
{
    counter = 0;
    counter2 = 0;

//Module: CheckedOutByYou? 1
    foreach (var ECORev_iterator in (from r in Db.ECORev where r.Company == Session.CompanyID && r.GroupID == myUser &&r.PartNum == myPart && r.RevisionNum == myRev && r.CheckedOut == true select r))
    { 
        counter++;
    }
    if(counter == 0)
    {
//Module: Already Checked Out! 1 
        foreach (var ECORev_iterator in (from r in Db.ECORev where r.Company == Session.CompanyID && r.PartNum == myPart && r.RevisionNum == myRev && r.CheckedOut == true select r))
        { 
            counter2++;
        }
        if(counter2 > 0)
        {
             this.PublishInfoMessage("This part and revision has already been checked out to another user.Please check the revision back in before editing any operations.", Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "", "");
             //break;   
        }
        else
        {
//Module: CheckOut 1
            this.CallService<Erp.Contracts.EngWorkBenchSvcContract>(ewb =>
            {
                tsWB = ewb.CheckOut(myUser, myPart, myRev,"","", BpmFunc.Now(), false, myPass, false, true, false, out checkedOutRev, out msg, out flag);
            });
        }
        
    }
}

//Module: GetECORevData 1
this.CallService<Erp.Contracts.EngWorkBenchSvcContract>(ewb =>
{
    tsWB = ewb.GetECORevData(myUser, true);
});

//Module: GetDsTree 5
this.CallService<Erp.Contracts.EngWorkBenchSvcContract>(ewb =>
{
    tsWB = ewb.GetDatasetForTree(myUser, myPart, myRev,"","", BpmFunc.Now(), false, false);
});

//Module: GetECORevData 1
this.CallService<Erp.Contracts.EngWorkBenchSvcContract>(ewb =>
{
    tsWB = ewb.GetECORevData(myUser, true);
});

//Module: GetDsTree 5
this.CallService<Erp.Contracts.EngWorkBenchSvcContract>(ewb =>
{
    tsWB = ewb.GetDatasetForTree(myUser, myPart, myRev,"","", BpmFunc.Now(), false, false);
});

//Module: set shortdesc1
myShortDesc = (from ECORev_Row in Db.ECORev
           where ECORev_Row.Company == Session.CompanyID && 
                 ECORev_Row.GroupID == myUser && 
                 ECORev_Row.PartNum == myPart && 
                 ECORev_Row.RevisionNum == myRev
           select ECORev_Row.RevShortDesc).FirstOrDefault();

//Module: Set myComment 1
myComment = (from ECORev_Row in Db.ECORev
           where ECORev_Row.Company == Session.CompanyID && 
                 ECORev_Row.GroupID == myUser && 
                 ECORev_Row.PartNum == myPart && 
                 ECORev_Row.RevisionNum == myRev
           select ECORev_Row.RevDescription).DefaultIfEmpty(".").FirstOrDefault();

//Check 
this.PublishInfoMessage("My Comment: " + myComment + " My Short Desc: " + myShortDesc, Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "", "");

//Module: is mycomment blank 1
if(myComment == "")
{

//Module: set mycomment=. 1
    myComment = ".";
}

//Module: shortdesc is blank? 1
if(myShortDesc == "")
{
    
//Module: set shortdesc = . 1
    myShortDesc = ".";
}

//Module: tsWB RowMod=u1
/* update ECOOpDtl*/

Erp.Tables.ECORev ECORev;

ECORev = (from ECORev_Row in Db.ECORev
           where ECORev_Row.Company == Session.CompanyID && 
                 ECORev_Row.GroupID == myUser&&
                 ECORev_Row.PartNum == myPart && 
                 ECORev_Row.RevisionNum == myRev
           select ECORev_Row).FirstOrDefault(); //Get the ECOOpDtl record to update... 
if (ECORev != null)
{
  ECORev.RevShortDesc = myShortDesc;
  ECORev.RevDescription = myComment;
}

//Module: CheckECORev tsApp1 1
this.CallService<Erp.Contracts.EngWorkBenchSvcContract>(ewb => ewb.CheckECORevApproved(false, myPass, ref tsWB));

```

Error:

 ![image](https://www.epiusers.help/uploads/default/original/3X/a/6/a6aa4dc126430619f17820e4d5dd85b188c02efc.png)

Even though this pops up it still checks out the part into your eco group. I also reapproved the revision and checked it back in but the error still comes up.

Is this something that just needs to be suppressed and if so how?

---

<div class="post-metadata">

**Author:** ![jtownsend](https://www.epiusers.help/letter_avatar_proxy/v4/letter/j/f14d63/32.png) [@jtownsend](https://www.epiusers.help/u/jtownsend)\
**Post date:** [August 30, 2023, 2:52pm UTC](https://www.epiusers.help/t/call-business-object-within-bpm-using-c-help-needed/106318/17 "2023-08-30T14:52:59Z")

</div>

My first thought is that GetDatasetForTree is grabbing more than you think.

My second thought is that you could probably reduce the number of LINQ calls to the DB. I’m also wary that you’re making direct Db calls instead of copying it to a list and working on that.

It also looks like you’re setting Db fields directly instead of using the tableset and update methods? Yikes.

---

<div class="post-metadata">

**Author:** ![klincecum](https://www.epiusers.help/user_avatar/www.epiusers.help/klincecum/32/100137_2.png) [@klincecum](https://www.epiusers.help/u/klincecum)\
**Post date:** [August 30, 2023, 3:02pm UTC](https://www.epiusers.help/t/call-business-object-within-bpm-using-c-help-needed/106318/18 "2023-08-30T15:02:37Z")

</div>

> [@jtownsend](#):
>
> Yikes.

Looks like just descriptions.  
 ![Reassuring Jimmy Fallon GIF by The Tonight Show Starring Jimmy Fallon](https://media2.giphy.com/media/e9hRgPKipZqgy8sYFP/giphy.webp?cid=e90edba3pkd1i43itm5wj8p7d7w7yye0wid1kbxbhaa2j8e3&ep=v1_gifs_search&rid=giphy.webp&ct=g)

---

<div class="post-metadata">

**Author:** ![dgreenEA](https://www.epiusers.help/user_avatar/www.epiusers.help/dgreenea/32/22635_2.png) [@dgreenEA](https://www.epiusers.help/u/dgreenEA)\
**Post date:** [August 30, 2023, 3:07pm UTC](https://www.epiusers.help/t/call-business-object-within-bpm-using-c-help-needed/106318/19 "2023-08-30T15:07:42Z")

</div>

Currently, the code only checks out a part and unapproves it. The ECORev.RevShortDesc and ECORev.RevDescription are there so that I can see that something is happening table-wise when I do the checkout.

Also, this is all being done in our pilot system not live so no worries about breaking stuff here.

Also I have a partial solution to why the error is happening:

> [@Using CheckECORevApproved and ChangeECORevApproved](https://www.epiusers.help/t/using-checkecorevapproved-and-changeecorevapproved/58574):
>
> Good morning, I am working on an updatable BAQ that will change Resource Group IDs for Parts. I already used a ton of help from this group to get this working for the open jobs. Now I am working in the Engineering Workbench, trying to update the master parts. See this related post for reference: Back to the task at hand. When I try to use the engineering workbench methods CheckECORevApproved, and ChangeECORevApproved, I get an error: “ECORev has not changed.” Below I have clipped some of the…

The code I’m creating here is based on the works of @NateS. In his post above he mentions that the row mod for tsWB needs to be marked as “U” before the unapproved method can be called.

However when I try to go into tsWB.ECORev.RowMod I get the following error:

 ![image](https://www.epiusers.help/uploads/default/original/3X/5/2/5249735422d7c6c87b496c307034b1d998305a75.png)

Any ideas on how I can swap the RowMod on this sentax-wise?

---

<div class="post-metadata">

**Author:** ![NateS](https://www.epiusers.help/user_avatar/www.epiusers.help/nates/32/18519_2.png) [@NateS](https://www.epiusers.help/u/NateS)\
**Post date:** [September 6, 2023, 6:49pm UTC](https://www.epiusers.help/t/call-business-object-within-bpm-using-c-help-needed/106318/20 "2023-09-06T18:49:47Z")

</div>

I have to add:

```auto
using Erp.Tablesets;

```

to my BPM Usings and References.
