Why can't I linq to UserFile.Db?

I have been tasked with creating a stop in Epicor when receipting a PO. If a PO is over a certain value and is over 14 days early. when this stop happens I want to ping an email directly to the purchaser who created the PO.

So I write the BPM and put in a bit of custom code where I call upon the ttrcvdtl table. From there I can pull the required by date. i then add a comparison widget so as to check whether or not we are 2 weeks early. every thing works great so far.

I then look to use the ttrcvdtl table to link over to POHead.Db on the Po number so that I can pull the Entry person field so that I can start making my way over to the UserFile.Db. But for some reason, it doesnt fire. There is no Po Number coming from the ttRcvDetail.ds…and yet it was still able to pull the PODelivery date?? What on Earth am I missing here?

Anyone have any idea?? Many thanks in Advance

foreach (var ttRcvDtl_iterator in (from ttRcvDtl_Row in ds.RcvDtl where ttRcvDtl_Row.RowMod == "U" ||  ttRcvDtl_Row.RowMod == "A"
                                   select ttRcvDtl_Row))
{
  var ttRcvDtlRow = ttRcvDtl_iterator;
  
  var PORelRow = (from PORel_Row in Db.PORel
               where PORel_Row.PONum == ttRcvDtlRow.PONum && PORel_Row.POLine == ttRcvDtlRow.POLine && PORel_Row.PORelNum == ttRcvDtlRow.PORelNum
               select PORel_Row).FirstOrDefault();

    if (PORelRow != null)
    {      
 
         
         //Get the dates
         var DeliveryDate = PORelRow.NeedByDate;
         var Today = DateTime.Today;
         var interval = Today - DeliveryDate;
         
      
      //Convert the dates from TimeSpan so that we have the number of days to compare
       FirstDot = interval.ToString().LastIndexOf('.');
       TheDays = interval.ToString().SubString(0,FirstDot);
       Days = Convert.ToInt32(TheDays);
       
        var POHeadRow = (from POHead_Row in Db.POHeader
             where POHead_Row.PONum == ttRcvDtlRow.PONum
             select POHead_Row).FirstOrDefault();
             
             if (POHeadRow != null)
       
              {
              var UserFileRow = (from UserFile_Row in Db.UserFile
             where UserFile_Row.DcdUserID == POHeadRow.EntryPerson
             select UserFile_Row).FirstOrDefault();
                
               if (UserFileRow != null)
               
               {
                string Email = UserFileRow.EMailAddress;
               }
                
              }
       

    }   
    else
    {
      
      /*writer.WriteLine(System.DateTime.Now.ToString() + " JobHeadRow is null " );;*/
    }
     /*writer.WriteLine(System.DateTime.Now.ToString() + "JObHeadRow is not null   " + callContextBpmData.Character04.ToString());
      writer.Close();*/
}

I’m not seeing any obvious syntax errors and I know we’ve referenced that table before at other companies I worked for. Maybe try the Buyer table, as it’s going to be a smaller dataset to query and only people in the Buyer table can create POs.

In the structure that we have the buyers are actually groups of people, so I don’t really have that option unfortunately. I should have mentioned that I am trying to pull this info on a pre-processing at Update Master. Whether or not has something to do with it. But it certainly has got me thinking

1 Like

Why Update Master and not normal Update?

I use message boxes in code when developing to check that I’m getting the data I need for the next step.

// Show MsgBox - DEBUG
string body = "message here :" + PORelRow.NeedByDate +  Environment.NewLine + "more text if needed";
this.PublishInfoMessage(body, Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual,"FirstVar","SecondVar");

I went through trace it noted that the update of a receipt went through that method rather than normal update. So I thought I’d go through there.

I’ve decided to move away from using widgets and start again just using code blocks and publishing messages as you suggested. That showed data coming through so I guess the mystery here is resolved. Its like the light double slit experiment, until its observed epicor works in different and mysterious ways

2 Likes

:rofl: I’ve never read a more perfect description of Epicor. Well done! :rofl:

image

2 Likes