Method Directive BPM on Part.Update Help Please

Hi

Can somebody give me a hand with a BPM please. Currently have the below code working well on Part.Update Pre Processing Method Directive. I’d like to extend it, to add in a new PartWhse and then setting this newly added PartWhse as the default PartWhse on PartPlant. Not sure whether this can be achieved using BO calls on the GUI in BPM, or whether it’s custom coding.

Many Thanks
Mark

// AutoAssign Unique ID

Ice.Tables.UDCodes UDCodes = null;

foreach (var MyPart in (from ThisPart in ttPart where
                ThisPart.RowMod == IceRow.ROWSTATE_ADDED &&
                string.Equals(ThisPart.PartNum, "ENG", StringComparison.CurrentCultureIgnoreCase) == true
                select ThisPart))

                {

                                using (var txScope = IceContext.CreateDefaultTransactionScope())
                                {

                                                foreach (var MyUDCodes in (from ThisUDCodes in Db.UDCodes.With(LockHint.UpdLock) where
                                                                ThisUDCodes.Company == Session.CompanyID &&
                                                                ThisUDCodes.CodeTypeID == "AUTONUMBER" &&
                                                                ThisUDCodes.CodeID == "ENGPART"
                                                                select ThisUDCodes))

                                                                                {
                                                                                                int NextEngPartID;
                                                                                                int.TryParse(MyUDCodes.CodeDesc, out NextEngPartID);

                                                                                                MyPart.PartNum = "ENG" + NextEngPartID.ToString();
                                                                                                MyPart.ClassID = "ENG";
                                                                                                MyPart.ProdCode = "ENG";
                                                                                                MyPart.TaxCatID = "STD";

NextEngPartID += 1;
                                                                                                MyUDCodes.CodeDesc = NextEngPartID.ToString();
                                                                                }

                                                Db.Validate();
                                                txScope.Complete();
                                }

                }

To add PartWhse you’ll have to call the BO in a Post Processing directive since you can’t add PartWhse until the Part has been committed.
At the end of your pre-processing directive you should trigger the enable post processing directive action
Then in the post processing directive use the BO’s to add the new PartWhse.

Do a trace on the UI to figure out the parameters to call.

Hi Jose

I have the following Post process BPM on Part.Update as per your suggestion.

Condition checks that it has been enabled from PreProc, then explained as follows:

  1.   Part.GetNewPartWhse
    
  2.   Set field ttPartWhse.WarehouseCode = “EN”
    
  3.   Part.Update
    
  4.   Set field ttPartPlant.PrimWhse = “EN”
    
  5.   Part.Update
    

I https://epiusers.help/uploads/default/original/2X/a/a9d53ae7c8c041181c48cedb6cf0e33e7f5c034c.jpg

I am getting the PartWhse EN added to the new part, but it’s not able to set it as default on the PartPlant. I would also want to then delete the original PartWhse (WhseCode CS) record.

If I were to do all this in pre-proc, do you think it would be possible to achieve the same just be setting Warehouse Code = “EN” before it has saved the default?

Regards
Mark

TraceData18276.txt (351 KB)

@josecgomez, just in case you didn’t get a notification on the topic :smiley:

Thanks!

Sorry I’ve been slammed,
You can do all this but you should do it all in the post processing even not in preproc since you won’t have a PartWhse until the post proc.

Yep the image I showed is all post proc – enabled from the pre-proc.