BPM stop shipment if job is not complete

Hello,

Has anyone created a BPM to stop shipment if job is not complete or if last operation is not complete?

Also my BPM work flow designer is not showing the custom code option

my work flow designer
image

from another post.

I do have this code but not able to test it at the moment.

/* TO DO: replace object variables with typed variables. Add reference if necessary.*/
object MESSAGE_ERR = null;
Erp.Tables.JobHead JobHead;
Erp.Tables.PartWhse PartWhse;
var ttshipdtl_xRow = (from ttshipdtl_Row in ttshipdtl
where string.Equals(ttshipdtl_Row.RowMod, IceRow.ROWSTATE_ADDED, StringComparison.OrdinalIgnoreCase) || string.Equals(ttshipdtl_Row.RowMod, IceRow.ROWSTATE_UPDATED, StringComparison.OrdinalIgnoreCase)
select ttshipdtl_Row).FirstOrDefault();
if (ttshipdtl_xRow != null)
{
if (ttshipdtl_xRow.OurJobShipQty > 0)
{
JobHead = (from JobHead_Row in Db.JobHead
where string.Compare(JobHead_Row.JobNum, ttshipdtl_xRow.JobNum, true) == 0 && JobHead_Row.JobComplete == false
select JobHead_Row).FirstOrDefault();
if (JobHead != null)
{
Lib.PublishInfoMsg(“For Shipment the Job should be Completed !”, MESSAGE_ERR);
}
}
if (ttshipdtl_xRow.OurInventoryShipQty > 0)
{
PartWhse = (from PartWhse_Row in Db.PartWhse
where string.Compare(PartWhse_Row.PartNum, ttshipdtl_xRow.PartNum, true) == 0
select PartWhse_Row).FirstOrDefault();
if (PartWhse != null && PartWhse.OnHandQty < ttshipdtl_xRow.OurInventoryShipQty)
{
Lib.PublishInfoMsg(“Not enough qty to ship !”, MESSAGE_ERR);
}
}
}

To show the custom code widget i think you need to enable the option “BPM Advanced User” in user account security maintenance

2 Likes

Great thanks for that, i now have the custom code option available, the down side is my code is not working. back to the drawing board.

Here’s what we use to make sure that the qty is completed and they don’t over-ship the qty complete.

var ttShipDtl_Row = (from row in ttShipDtl select row).LastOrDefault();

            if (ttShipDtl_Row != null)
            { 
                Erp.Tables.JobPart JobPart = Db.JobPart.Where(jp => jp.Company == ttShipDtl_Row.Company && jp.JobNum == ttShipDtl_Row.JobNum).FirstOrDefault();
                
                if (JobPart != null)
                {
                    if (ttShipDtl_Row.OurJobShipQty > (JobPart.QtyCompleted - JobPart.ShippedQty) || JobPart.WIPQty <= 0)
                    {
                        return true;
                    }
                    else 
                    {
                      return false;
                    }
                }
                else 
                {
                  return false;
                }
            }
            else 
            {
              return false;
            }

Hope this helps.

4 Likes

This is exactly what I am looking for, but it gives errors (The name ‘ttShipDtl’ does not exist in the current context). I am new to custom code (and have 0 background in C# though use VBA now and Fortran back in the day). Is there something that needs set in the ‘usings & references’ side to make this work?

Hello, Jadon,

Could you send me your code or a screenshot? I’d be happy to review it for you.

Norman,
I just copied and pasted from your code above. Screen shots as below.

If you double-click on that code, which line does it highlight?

Also, if you type ‘ttSh’ and then CTRL+SPACE does ttShipDtl show up as an option?

image.png

Double click highlights the ttShipDtl as circled below

Sorry I missed the ‘Also, if you type ‘ttSh’ and then CTRL+SPACE does it…’ This is what it give
image

hmm… that’s odd I get the whole list… what version are you on?

Isn’t this easily accomplished with widgets? This shouldn’t require custom code.

Norman - I am on Epicor SaaS doing this in our Pilot environment. It is Kinetic 2021.1.7 (or in the old world Epicor 11.1.100.0)

Garret - I tried with widgets first (what I am more used to) but I couldn’t get it to work well because some of the data we are looking at for the condition statement is not showing / available in the object we are starting from. That’s when I found Norman’s original post and was hopeful it will do the trick.

@nhutchins @JEvans In 11 tt is now ds.tablename. Change the ttShipDtl to ds.ShipDtl and it will compile.

I looked at my 10.2.400 bpm custom code and it was all converted to ds. from tt when I ran the 11.1 conversion. Thanks Epicor !!

1 Like

Thanks, @gpayne, I was going to blame SaaS, but I guess it’s a Kinetic 2021 thing! Glad there is a solution.

I just looked at my code in our UAT for the upgrade. I didn’t realize all of those had changed. Thank goodness I didn’t have to go in and change all of those one by one…:partying_face:

@Doug.C @gpayne @nhutchins Thanks to all for the great help. The change to ds.ShipDtl did the trick.