Job Entry - Customer PO Information

Laughing at @klincecum’s “thinking” on this one because he already (kinda) solved this.

Job Entry contains a JobProd dataview which has the OrderNum you could build off of.

But, the first hurdle (I agree with @Mark_Wonsil) is that JobProd COULD be 1-to-many. You could have (1) job making parts for multiple sales orders. In which case, which PONum would you display in the text box?

~~
You guys already talked through that while I was testing the below, so we’ll ignore that…
~
~

You can pull this off via BPM. Ref thread:

I tested by creating a BPM (Post) on JobEntry.GetDatasetForTree which is the method Job Entry calls which populates the JobProd dataview.

Code (starting with @klincecum’s… massaging for our purpose… and then using AI to improve efficiencies cause Davey-no-Codey):

// Distinct, non-zero OrderNums from the temp dataset
var orderNums = result.JobProd
    .Where(r => r.OrderNum != 0)
    .Select(r => r.OrderNum)
    .Distinct()
    .ToList();

if (orderNums.Count > 0)
{
    // Query only matching orders (SQL does filtering)
    var poByOrderNum = Db.OrderHed
        .Where(oh => orderNums.Contains(oh.OrderNum))
        .Select(oh => new { oh.OrderNum, oh.PONum })
        .ToDictionary(x => x.OrderNum, x => x.PONum);

    foreach (var row in result.JobProd)
    {
        string poNum; // C# 6: declare up-front

        if (row.OrderNum != 0 && poByOrderNum.TryGetValue(row.OrderNum, out poNum))
            row["CustPONum"] = poNum ?? "";
        else
            row["CustPONum"] = "";
    }
}
else
{
    foreach (var row in result.JobProd)
        row["CustPONum"] = "";
}

Going this route adds the “CustPONum” column directly to the JobProd dataview. So, no real customization work is needed in Application Studio other than binding your textbox to JobProd.CustPONum.

And/Or, you could add the CustPONum column to the existing “Demand” grid, which is already bound to the JobProd dataview:

2 Likes