Sales Order Gross Weight

Hi everyone,
We have a requirement of getting the Total Gross Weight of the Sales Order based on the parts added on the Sales Order.
Added UD field Grossweight under OrderHed.
Gross weight will be coming from part detail table.
I have an error (The name ‘OrderNum’ does not exist in the current context’ when compiling the code below:
var CalcWeight = (from orderDtl in Db.OrderDtl
join part in Db.Part on orderDtl.PartNum equals part.PartNum
where orderDtl.OrderNum == OrderNum
select orderDtl.OrderQty * part.GrossWeight
).ToList().Sum();

using (var txScope = IceContext.CreateDefaultTransactionScope())
{

foreach (var OrderHed in (from OrderHedRow in Db.OrderHed
where OrderHedRow.Company == Session.CompanyID
&& OrderHedRow.OrderNum == OrderNum
select OrderHedRow))
{
TotalWeight = Convert.ToDecimal(CalcWeight);
OrderHed.GrossWeight_c = Convert.ToDecimal(CalcWeight);
}

Db.Validate();
txScope.Complete();
}

Help please.

Doesn’t seem to like that OrderNum you’re using there:

where orderDtl.OrderNum == OrderNum
&& OrderHedRow.OrderNum == OrderNum

Is that a variable ? Where are you getting that from ?

1 Like

where is the ttDataSet to start with ? could you put the BPM details in here?

Hi all,
The variable declared on the BPM was the issue.
It is good now.
image

Thanks everyone.

1 Like