I have an In-Transaction data directive on Part.Update.
What I am trying to do is set the part and site inspection required dropdown to inspection required IF:
- Part.typecode is P
- part.ClassID is in “RHVA”, “RINS”, “RMET”, “ROTH”
- PartPlant.Plant equals LOU
It’s failing where I have the var partPlant section. there is no error message it just doesn’t see that part to pick up the partPlant.Plant.
If I comment out that section and the partPlant.Plant ==“LOU” in the if statement it works.
bool isNewPart = false;
var partRow = ttPart.FirstOrDefault();
if (partRow != null && partRow.RowMod == "A")
{
isNewPart = true;
}
bool requiresInspection = partRow != null &&
partRow.TypeCode == "P" &&
new[] { "RHVA", "RINS", "RMET", "ROTH" }.Contains(partRow.ClassID);
var partPlant = (from s in Db.PartPlant
where s.Company == partRow.Company && s.PartNum == partRow.PartNum
select s).FirstOrDefault();
if (isNewPart && requiresInspection && partPlant !=null && partPlant.Plant == "LOU")
{
partRow.RcvInspectionReqPart = "Y";
partPlant.RcvInspectionReqPart = "Y";
}