Looking for a little assistance in writing custom code. I’m trying to sum up the weight on all receipt lines and populate the misc charge amount field after a new misc charge has been added to the receipt.
Looking for assistance in writing code to get the total weight for all receipt lines so that I can set it to a variable.
Unfortunately, I’m not a coder so I don’t even know where to start. I can populate the amount field on the misc charge line in the BPM but don’t know how to query for the weight. Total weight is not stored in the RcvHead so I have to sum it up from the receipt lines.
Well, I don’t generally like handing out code to people who don’t understand what they are looking at… but I guess you’re lucky.
//This line is to get the pack slip number and vendor number which you will need in the next line. If you can just get these with normal variables, that will work too.
var myPackSlip = ds.RcvHead.Select(z=>new {z.PackSlip, z.VendorNum}).FirstOrDefault();
//this does a lookup from the database and gets your dtl lines, selects the weights, and sums it up into a single decimal field. You can make a variable if you want to assign it to that instead of Var.
var totalWeight = Db.RcvDtl.Where(z=>z.Company == this.Session.CompanyID && z.PackSlip == myPackSlip.PackSlip && z.VendorNum == myPackSlip.VendorNum).Select(z=>z.Weight).Sum();