Job Receipt to Inventory BPM that checks whether an attachment exists for the selected serial numbers

Hi,

I need assistance with a BPM for “Job Receipt to Inventory.”

When a user clicks the “OK” button, they should receive an error message stating: “Please attach a document to the Serial Number.” I’ve included an image for reference.

I was able to create a BPM that functions correctly for a single Serial Number. However, when there are multiple serial numbers, I encounter an error: “The table ds.SelectedSerialNumbers has more than one record.”
image

This issue arises because I assign ds.SelectedSerialNumbers.SerialNum to a single string variable. I’m unsure how to create a list and add numbers to it, and then implement a loop to check each selected serial number.

Could you please help me resolve this issue? :sob: :sob: :sob:


@Tatiana_Kornilova Welcome. Wizards don’t really loop well. This bit of code should handle the process for this. Full disclosure: We don’t use serial numbers, so I have no way to test this, but it compiles and I took the code from our stop on over receiving in the same method, so it should be good.

/* Check sn has attachment */

Ice.Diagnostics.Log.WriteEntry("in check Sn has attachment");

foreach (var snRow in ds.SelectedSerialNumbers)
{
    bool snhasFile = Db.XFileAttch.Any(x => x.Company == Session.CompanyID && x.RelatedToFile == "SerialNo" && x.Key1 == snRow.PartNum && x.Key2 == snRow.SerialNumber);
    if(snhasFile == false)
    {
        CallContext.Current.ExceptionManager.AddBLException($"Please attach a Calibration Certificate to Part {snRow.PartNum} Serial No. {snRow.SerialNumber}");
    }
    
    Ice.Diagnostics.Log.WriteEntry($"Part {snRow.PartNum} Serial No. {snRow.SerialNumber} is good");
}
2 Likes

Hi Greg,

It works! Thank you!
I’m so grateful!
You saved me! :upside_down_face:

1 Like