Epicor 10.2: There is no argument given that corresponds to the required formal parameter 'dataContext' of 'ContextBoundBase<ErpContext>.ContextBoundBase(ErpContext)'

I am trying to build my existing objects for Epicor 10.2. Here taking all the references with respect to E10.2
Getting the below error message at the time of build:
There is no argument given that corresponds to the required formal parameter ‘dataContext’ of 'ContextBoundBase.ContextBoundBase(ErpContext)'

NOTE: For E10.1.600 not getting such error.

Any solution for this error!!..

THANKS in advance

What existing object… what are you referring to specifically?
SDK Work ? Adapter, BO? Customization? BPM? Report? BAQ? Data Directive?

1 Like

Code snippet would be wonderful too :slight_smile:

Hello Josecgomez,
This code for making DLL to be called as external reference by the BPM, which is validate for the Commitment control.

Below is the code:

global_error

Same code is works in Epicor-10.1.600.18 but it is failing in E-10.2

And below with the error:

Line 38 is wrong - not sure why it ever worked to be honest. Possibly something specific to the service. If you are deriving the class off CBB then the ctor needs to be the same Type - ErpContext.

I assume line 38 should be:
public GlobalProcedures(ErpContext context)

but I may be missing something

based on my understanding replace line number 33 with public class GlobalProcedures and try

Dear @Bart_Elia,

Thanks for your suggestion.
I have been changed the code as per your suggestion & also added :base(context). Code has build successfully, but it is showing an error while trying to execute User defined Stored Procedure. Code is not reaching inside the For Each loop due to Db is getting Null.
Below is a code which we are using.

foreach (var DataGetGlobalData in Db.ExecuteStoreQuery("Sp_storeProcedureName " + “@code = {0}”, code))
{
ParamValue = Convert.ToString(DataGetGlobalData.Value);
}

Facing Run-time Error: ‘Object reference not set to an instance of an object’

Thanks & Regards…

ok, I think I misspoke. You are doing this for BPM External Method? Sorry, I was thinking of the Externalization framework so my statement was invalid…

If you are calling the external Method, the ‘Create API’ will generate a POCO - no base class. The DB Context will be passed to you. There is no need to derive off ContextBoundBase unless you are creating new services and libraries. I work with a lot of partners - internal and external - who go into creating whole new products on the SDK so was not thinking about the BPM aspect.

If doing a simple External Method than generate the API from the Actions on the main page and it will give you something like this (This is from UserFIle)
namespace BpmCustomCode
{
public class MyUserFile
{
private Ice.IceContext dataContext;

    public MyUserFile(Ice.IceDataContext context)
    {
        // 
        // TODO: should not be disposed, as custom assembly does not own the context
        // 
        this.dataContext = (Ice.IceContext)context;
    }

    public void Update(Ice.Tablesets.UserFileTableset ds, Ice.Tablesets.ContextTableset context)
    {
        // 
        // TODO: Replace the throw statement with any code for an action in UserFile.Update() method invoke
        // 
        throw new System.NotImplementedException();
    }
}

}

You should be able to just drop in your logic in the method you specified when creating the BPM or create local, private methods for your logic.

1 Like

Thanks @Bart_Elia
I am writing this code for making DLL to be called as external reference from the BPM on Update method. Shared sample code is working for Epicor 10.1, but failing in 10.2.
Above mentioned code has been written in external DLL & then this external DLL used in BPM code as a reference.

If I remove Inheritance of Context, I will not get Db Object to access the objects of Database.
Basically, I want to execute user defined stored procedure using current data-Context connection from external DLL.

Thanks @surendrapal for reply…
If I remove inheritance of ContextBoundBase then I am unable to access Db object.
Basically I want to execute user defined stored procedure using current db context connection.
Below mentioned code is used to execute stored procedure:

foreach (var DataGetGlobalData in Db.ExecuteStoreQuery("Sp_storeProcedureName " + “@code = {0}”, code))
{
ParamValue = Convert.ToString(DataGetGlobalData.Value);
}

I have just created a object of ErpContext class & used to execute user defined stored procedure.
And solution is worked for me. I got the dbContext object with database objects.

ErpContext Dbctx = new ErpContext();

and then I have used above Dbctx object to execute stored procedure from c#

foreach (var DataGetGlobalData in Dbctx.ExecuteStoreQuery("Sp_storeProcedureName " + “@code = {0}”, code))
{
ParamValue = Convert.ToString(DataGetGlobalData.Value);
}

1 Like

I have no issue as well. I am still trying to understand where this code was being executed from and how It does not align with an External Method in a BPM so confuses me. How was that code instantiated??