E10 BPM External Code, use DB and bpmContext

Hey, how are u guys? im really stuck whit a problem, i need to execute from a BPM (RcvDtl-> OnChangeDtlReceived) an external code. After some tries i make that, but then… i need to use on my external code (C#) the DB context and bmpContext too, because on ds rows i only have the RcvDtl rows, and i need some information from Rcvhead row.

if i can access to db will be more easily, i will have all the things i need.

I need the GLAccount from the partClass and TaxCatID from the Part, these last things are not in receive.

about code i dont have much yet, cause im starting whit that. but basically the idea is convert the info to new entitie and then add row in another db on another server.

sry for the bad english and thanks for read :slight_smile:

quoting the reply that helped me atleast, because i marked mi last post as solution, using this quoted post i can arrive to real solution:

Porque estas usando External Code para esto? Si usas Custom Code Action tienes acceso directo a el objeto DB y a todos los demás. Porque necesitas hacer esto con una llamada externa?

Lo que yo necesito es llevar las recepciones hacia un sistema de contabilidad que tenemos. Para esto mismo me tengo que acomodar al a información necesaria por dicho sistema y hacer que elimine o agregue filas en una tabla de una DB externa a Epicor dependiendo de si marco como recibido o desmarco lo mismo en la recepción.

Esto mismo no es tan simple como tomar el registro e insertarlo sino que tengo otros datos que necesito obtener (GLAcount para el PartClass y el TaxCatID), pero mas allá de esto necesito también algunos datos del RcvHead.

El problema es que si lo hago con un Custom Code Action si bien tengo el acceso a dichos objetos y datos, no tengo el poder de acceder a la base externa y hacer lo pertinente, ni de hacer la conversión de todos los campos para lo que se necesita en la misma.

Saludos

Ok, Stop it…English only…deal with it….and don’t mess with me today…I stood in line for 3 hours to vote….so I don’t care what your excuse is….both of you!

And by the way…I LOVE bad English….its awesome!

M. Manasa Reddy
P: 703.471.7145 x454
manasa@euclidsys.commailto:manasa@euclidsys.com

Una opción que tienes es pasar el objeto Db a la librería external que estás llamando desde el BPM, tienes que tener mucho cuidado al hacer esto porque si dispones del objeto Db en tu codigo puedes causar muchos problemas. Pero luciría algo asi en tu librería externa

 public void MyMethod(object Db, String otherParam)
{
var myDBObject = (IceDataContext) Db;

}

Dentro de un Custom Action en el BPM llamarias a tu funcion externa y passas el DB Object

1 Like

Ok Manasa, sry for that, i response to him on spanish because he answer to me on spanish, i have no problem translating (or trying because my bad english haha) the text o post uphere.

What I need is to take the receptions to an accounting system that we have. For this same I have to accommodate the information required by such a system and have it delete or add rows in a table from an external DB to Epicor depending on whether it is marked as received or unchecked at the reception.

This is not as simple as taking the record and inserting it but I have other data that I need to obtain (GLAcount for PartClass and TaxCatID), but beyond that I also need some data from RcvHead.

The problem is that if I do with a Custom Code Action although I have access to such objects and data, I do not have the power to access the external database and do the pertinent, nor do the conversion of all fields for what Is needed in it.

regards

LoL no worries Dan I think she was just joking. Yo te ayudo en español pues es mas facil para ti! Tranquilo

hahaha no problem understanding english, maybe some writing or more talking, but understand at perfection.

im trying to use some like the code u give to me, but i dont figure IceDataContext from what epicor10 Dll is…
after that onl rest to try the solution and if work mark like solves the problem.

Thanks and regards

This should do it (disregard the DynamicQuery ones)

Also remember don’t dispose of that Db object.

DanB…thank you…I appreciate that….in all honesty I do understand those that are in other countries their needs to “write” in their native languages. I do understand…so if the group doesn’t have an issue with it and as long as we can translate in the message I can live with it.

How does that sound?

M. Manasa Reddy
P: 703.471.7145 x454
manasa@euclidsys.commailto:manasa@euclidsys.com

Thanks,
whit this i just find where is… (for help the rest who read this)

here is:

now time to try!

For the utility of everyone, from yesterday i advance from this point and post the finally working solution:

Custom code:

BpmCustomCode.MyReceipt testLib = new BpmCustomCode.MyReceipt();
testLib.TestMethod(vendorNum, purPoint, packSlip, packLine, ipReceived, ds, Db);

also have to reference dll on “References” tab.

External code

Finally used Erp.ErpContext, this have all tables like i needed:

public class MyReceipt
{

    public MyReceipt()
    {
    }
    public void TestMethod(int vendorNum, string purPoint, string packSlip, int packLine, bool ipReceived, ReceiptTableset ds, object db)
    {
                  string sPackSlip = p ackSlip;
                  int iPackLine = packLine;

                  ErpContext contextDB = (ErpContext)db;

                  RcvHead cabecera = contextDB.RcvHead.FirstOrDefault(rh => rh.PackSlip == sPackSlip);
                  RcvDtl detalle = contextDB.RcvDtl.FirstOrDefault(rd => rd.PackSlip == sPackSlip && rd.PackLine == iPackLine);
                  .....
    }

Enjoy :slight_smile: