This is custom code on a post processing method directive for OrderJobWizard.CreateJobs. I’m trying to pair down the results to only the jobs being created using Order Job Wizard. Since we create jobs for every release I’m using the ttJWOrderRel table. I’m testing using an order with 2 lines and 2 releases. I’m creating jobs for both releases of 1 line, my code returns the would-be job numbers of all 4 releases, rather than just the 2 releases I’m attempting to create jobs from.
Here’s the code:
foreach (var ttJWOrderRel_Row in (from row in ttJWOrderRel select row))
{
var Rel = (from por in Db.OrderRel
where por.Company == Session.CompanyID
&& por.OrderNum == ttJWOrderRel_Row.OrderNum
&& por.OrderLine == ttJWOrderRel_Row.OrderLine
&& por.OrderRelNum == ttJWOrderRel_Row.OrderRelNum
select new {por.Company, por.OrderNum, por.OrderLine, por.OrderRelNum}).ToArray();
if (Rel != null)
{
foreach(var Rels in Rel)
{
int OrderNum = Rels.OrderNum;
int OrderLine = Rels.OrderLine;
int OrderRelNum = Rels.OrderRelNum;
string job = (OrderNum + "-" + OrderLine + "-" + OrderRelNum).ToString();
this.PublishInfoMessage(job, Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "", "");
}
}
}
Anyone have any suggestions on how to pair down the results to only the releases I’m cutting jobs for?
I have tried using an IF statement after my first foreach line.
foreach (var ttJWOrderRel_Row in (from row in ttJWOrderRel select row))
{
if(ttJWOrderRel_Row.RelJobChkBox == true)
{
What I posted earlier is the full code, for the time being. Once I have the correct job numbers being returned I’ll be using them in another foreach linq statement to grab JobOper fields, AssemblySeq and OprSeq, to create purchase orders with. I tried that foreach statement and it’s not working for me, if I remove where row.RelJobChkBox == true I do get the message box with the would-be job numbers.
I have working code to create the Purchase Orders with, from a previous project, but I can’t seem to pair down my results to only the jobs actually being made.
@ridgea, while that is cool, and you taught me something new, Data Directives don’t work for what I’m trying to do.
Got it. Was this a Pre-Processing or Post Processing Directive?
I would think you need to collect a List in Pre-Processing, but perform your work in Post-Processing.
Okay, so I decided to tackle this a little differently and I think I may have gotten some traction. Logically, since this is Post-Process, these jobs already exist when the code runs, right? I believe they are, so instead of linqing to OrderRel, let’s try JobProd instead. Boom, got it.
I’m now only returning jobs that are actually made, as I’m looking at the JobProd table, grabbing the job number from there; rather than trying to string together the job number from OrderRel table.
foreach (var ttJWOrderRel_Row in (from row in ttJWOrderRel select row))
{
var JobProd = (from jp in Db.JobProd
where jp.Company == Session.CompanyID
&& jp.OrderNum == ttJWOrderRel_Row.OrderNum
&& jp.OrderLine == ttJWOrderRel_Row.OrderLine
&& jp.OrderRelNum == ttJWOrderRel_Row.OrderRelNum
select new {jp.Company, jp.OrderNum, jp.OrderLine, jp.OrderRelNum, jp.JobNum}).ToArray();
if (JobProd != null)
{
foreach(var Rels in JobProd)
{
string JobNum = Rels.JobNum;
this.PublishInfoMessage("Job: " + JobNum, Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "", "");
}
}
}
@Jason_Woods, thanks again for the help and holding my hand, I knew I would get it eventually.