FirstArt Standard Data Directive Not Firing From JobHead Standard Data Directive

,

I’m working BPM to auto generate First Article Inspection Records under certain conditions on the JobHead table. I have an email being sent for added records on the FirstArt table on the Standard Data Directive. The generating First Article code I have works on both the In-Transaction and Standard.

The problem I’m having is when the code is run from a Standard Data directive on JobHead, it won’t fire the Standard Directive of the FirstArt table. If I move the code to an In-Transaction directive on JobHead, it will fire the FirstArt Standard Directive and I get an email.

What gives? I don’t know what I’m doing wrong. I’ve never come across this where the Standard Directive was never fired unless you ignored the “Facade” when using the service. I try to steer away from In-Transactions as it doesn’t need to happen within the transaction. Especially with JobHead and MRP. Here is example POC code for the First Art generation.

using (var txScope = Erp.ErpContext.CreateDefaultTransactionScope())
{
	using (var service = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.FirstArtSvcContract>(this.Db, false))
	{
		foreach( var ttRecord in ttJobHead.Where(w => w.Updated()))   
		{
			var dsFAI = new Erp.Tablesets.FirstArtTableset();
			var operation = this.Db.JobOper.Where(w=> w.Company == ttRecord.Company && w.JobNum == ttRecord.JobNum).FirstOrDefault();

			if(operation != null)
			{
			  
				var fa = this.Db.FirstArt.Where(w=> w.Company == operation.Company && w.JobNum == operation.JobNum && w.AssemblySeq == operation.AssemblySeq && w.OprSeq == operation.OprSeq && w.ResourceID == "" ).Any();
				if(!fa)
				{
					service.GetNewFirstArt(ref dsFAI, ttRecord.JobNum, operation.AssemblySeq, operation.OprSeq, "");


					var dsFAIRow = dsFAI.FirstArt.Where(w => w.JobNum == operation.JobNum && w.AssemblySeq == operation.AssemblySeq && w.OprSeq == operation.OprSeq && w.ResourceID == "" && w.ExpectedQuantity == 0 && w.UOMCode == "").FirstOrDefault();
					if (dsFAIRow != null)
					{
						dsFAIRow.ExpectedQuantity = 1;
						dsFAIRow.UOMCode = "EA";
						dsFAIRow.CommentText = "Auto Generated";
						dsFAIRow.SeqNum = 2;
						service.Update(ref dsFAI);
					}


					if (dsFAI.FirstArt.Any(w => !w.Unchanged()))
					{
						service.Update(ref dsFAI);
					}
				}
			}
		}
	}
  this.Db.Validate();
  txScope.Complete();
}

not sure why your BPM is not running, but one thing about this type of BPM on JobHead and MRP would be to put a condition at very condition to NOT run the code if the job is Unfirm so that you only run your logic for “real” jobs.

Absolutely. MRP is the reason why I really don’t want to put it in the In-Transaction directive.