Copy Sales Order notes (OrderComment) to Job Entry (CommentText) comments on button click

Does anyone know the code to copy over Sales Order Notes (OrderHed.OrderComment) to Job Entry Comments (JobHead.CommentText) on button click located on the job entry header form?

Its definitely doable but coding that is a little tricky, as the OrderHead table data isn’t pre-loaded into the JobEntry form when it launches.

Have you considered just making a BPM or 2 that copy over the OrderComment to Job Entry automatically? Trigger upon job creation and upon ordercomment change.

I have, however when using the order job wizard to create jobs, in the case of creating multiple jobs from multiple lines at the same time it only moves over the notes for the first job created.

We do similar. For job creation, we use a data directive on JobHead to pull data. This works for multiple jobs:

//Get the order info
var Result = (from t1 in Db.JobProd
  where t1.Company == callContextClient.CurrentCompany
  && t1.JobNum == gJobNum
  select new{t1.OrderNum, t1.OrderLine, t1.OrderRelNum}).FirstOrDefault();

//Set the global variables to those found values
if (Result != null) {  //Will be null if no more rows
  gOrderNum = Result.OrderNum;
  gOrderLine = Result.OrderLine;
  gOrderRelNum = Result.OrderRelNum;
} else {
  gOrderNum = 0;
  gOrderLine = 0;
  gOrderRelNum = 0;
}

For updates, we use method directive on SalesOrderUpdate to push new data. This is for updating product group.

//Get the next Job Number that need changing of Product Group
var JobNum = (from t1 in Db.JobProd
  where t1.Company == callContextClient.CurrentCompany
  && t1.OrderNum == gOrderNum
  && t1.OrderLine == gOrderLine
  && string.Compare(t1.JobNum,gJobNum) == 1  /* StringCompare = 1 if s1>s2 */
  orderby t1.JobNum
  select t1.JobNum).FirstOrDefault();

//Set the global variables to those found values
if (JobNum != null) {  //Will be null if no more rows
  gJobNum = (string)JobNum;
} else {
  gJobNum = "";
}

This is great, are you able to show what code you have in “Get ORder UD vals” in your first BPM?

Sure. This is very specific to us though.

//Get the order LQL
var Result = (from t1 in Db.OrderHed
  where t1.Company == callContextClient.CurrentCompany
  && t1.OrderNum == gOrderNum
  select new{t1.QALevel_c}).FirstOrDefault();

//Set the global variables to those found values
if (Result != null) {  //Will be null if no more rows
  gQALevel = Result.QALevel_c;
} else {
  gQALevel = "";
}

//Get the order RAL #
var Result2 = (from t1 in Db.OrderDtl
  where t1.Company == callContextClient.CurrentCompany
  && t1.OrderNum == gOrderNum
  && t1.OrderLine == gOrderLine
  select new{t1.ShortChar01}).FirstOrDefault();

//Set the global variables to those found values
if (Result2 != null) {  //Will be null if no more rows
  gRALNum = Result2.ShortChar01;
} else {
  gRALNum = "";
}

//Get the order D&I and AWaiting Customer Equipment values
var Result3 = (from t1 in Db.OrderRel
  where t1.Company == callContextClient.CurrentCompany
  && t1.OrderNum == gOrderNum
  && t1.OrderLine == gOrderLine
  && t1.OrderRelNum == gOrderRelNum
  select new{t1.DandI_c, t1.AwaitingCust_c}).FirstOrDefault();

//Set the global variables to those found values
if (Result3 != null) {  //Will be null if no more rows
  gDNI = Result3.DandI_c;
  gAwaitCust = Result3.AwaitingCust_c;
} else {
  gDNI = false;
  gAwaitCust = false;
}

I just had one more question about your order validation condition. What did you use for that?

image

This worked, I appreciate the help.