Variables as field names

Might be a bit hard for me to explain what I’m trying to do here so bear with me…

I’m updating a SalesOrder tableset through a function. I can do things like:

this.CallService<Erp.Contracts.SalesOrderSvcContract> (boSO => {
    boSO.GetNewOrderHed(ref tsOrd);
    
//update fields in OrderHed
tsOrd.OrderHed[0].Company = "MyCompany";

That all works as expected. What I’m trying to achieve though is something like this:

string sField = "Company";
tsOrd.OrderHed[0].sField = "MyCompany";

Nope. Doesn’t like it. I’ve tried things like tsOrd.OrderHed[0].Fields[sField] and tsOrd.OrderHed[0].Item[sField] but also to no avail.

Is there a way to do this with an Epicor tableset?

Hope that made sense!

Cheers,

Ryan.

Have you tried tsOrd.OrderHed[0][sField]

1 Like

Have you tried tsOrd.OrderHed[0][sField]

I have now. This does what I wanted it to do. Thanks Zack.