Lee_Myers
(Epicor!!)
February 24, 2020, 2:56pm
1
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
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);
}
}
}
richardh
(Richard Hubbard)
February 24, 2020, 4:28pm
2
To show the custom code widget i think you need to enable the option “BPM Advanced User” in user account security maintenance
2 Likes
Lee_Myers
(Epicor!!)
February 25, 2020, 10:30am
3
Lee_Myers:
/* 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);
}
}
}
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.
nhutchins
(Norman Hutchins)
February 25, 2020, 11:21pm
4
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
JEvans
(Jadon Evans)
July 22, 2021, 1:59pm
5
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?
nhutchins
(Norman Hutchins)
July 22, 2021, 2:12pm
6
Hello, Jadon,
Could you send me your code or a screenshot? I’d be happy to review it for you.
JEvans
(Jadon Evans)
July 22, 2021, 2:41pm
7
Norman,
I just copied and pasted from your code above. Screen shots as below.
nhutchins
(Norman Hutchins)
July 22, 2021, 2:49pm
8
If you double-click on that code, which line does it highlight?
nhutchins
(Norman Hutchins)
July 22, 2021, 2:54pm
9
Also, if you type ‘ttSh’ and then CTRL+SPACE does ttShipDtl show up as an option?
JEvans
(Jadon Evans)
July 22, 2021, 2:57pm
10
Double click highlights the ttShipDtl as circled below
JEvans
(Jadon Evans)
July 22, 2021, 3:17pm
11
Sorry I missed the ‘Also, if you type ‘ttSh’ and then CTRL+SPACE does it…’ This is what it give
nhutchins
(Norman Hutchins)
July 22, 2021, 3:54pm
12
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.
JEvans
(Jadon Evans)
July 22, 2021, 4:18pm
14
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.
gpayne
(Greg Payne)
July 22, 2021, 4:49pm
15
@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
nhutchins
(Norman Hutchins)
July 22, 2021, 4:59pm
16
Thanks, @gpayne , I was going to blame SaaS, but I guess it’s a Kinetic 2021 thing! Glad there is a solution.
Doug.C
(Doug Crabtree)
July 22, 2021, 5:10pm
17
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…
JEvans
(Jadon Evans)
July 22, 2021, 6:30pm
18
@Doug.C @gpayne @nhutchins Thanks to all for the great help. The change to ds.ShipDtl did the trick.