Method Directive that updates a field upon save

Hi all,

Looking to write a “simple” post processing method against Erp.BO.Part.GetNewPart which checks that the Part.TypeCode = ‘M’, if it meets this condition it then updates PartPlant.PrepTime with ‘30’ and PartPlant.KitTime as ‘10’.

I’m very new to using the Update Table by Query widget, and have only used it in a data directive, would this be best way to achieve these results please? I’ve started to build it but have got stuck on trying to set an expression on both PrepTime and KitTime, unsure what expression to set a field.

Thank you as always for any help!! :smiley:

The GetNewPart method basically returns an empty dataset for the part so there wouldn’t be a TypeCode to go off of.

You could put it on Part.Update and then set your conditions so it only ran when a row is added (RowMod=A) and when TypeCode = M.

After the condition widget, a couple Set Field widgets to set the PartPlant fields that you want to set.

1 Like

Hello Cory,

Thank you so much for your help. We’ve now applied this to ERP.BO.Part.Update instead.

We ended up switching to a pre-processing method which checks for TypeCode = M and some other criteria, which works. Then we added a ‘Enable Post Directive’ widget for setting the fields.

Pre:

The bit that isn’t happening, is in the post process, it just will not update the PartPlant fields. We have even tried removing all conditions and doing a simple Set Field widget on PartPlant.PrepTime but it just will not update… it’s almost like a different method is happening at the point of saving the part :thinking:

Post:

We did it this way with the widgets as haven’t really dabbled too much with custom code, but would it be possibly be better to do it via code please?

You said the goal was for this to fire on new part entries correct? In your MicTest pre-processing directive, you have the conditions looking for “the updated row” if you click on that you will see a list of options. From my understanding Added Row should be new rows, Changed Row would be added or updated, and Updated Row would only be updating an existing row. I’ve also found this to be a little unreliable which is why I try to include the rowmod as a condition.

I would also suggest adding in some show message widgets to verify what is firing and what isn’t.

If you’re unsure of what method is happening, you should check the dev tools in the browser and watch. Check out this post from @hmwillett for more details on that How To: Debugging Kinetic (Browser)

1 Like

Thanks Cory!! Sorry to ask another, how do you set RowMod == A, is there an expression editor I’m missing or a specific condition you pick from this condition drop-down please?

Yeah we want this to fire when creating new parts, just can’t seem to get the PartPlant bit updating unless we do an in transaction/data directive.

Thanks so much for sharing the debug tools, this is going to be super helpful!! :slight_smile:

I would setup the initial condition in MicTest like this:

Also since all you want to do is set 2 fields, I would just do it in the pre-processing directive. I use the enable post processing when I’m concerned that whatever I’m going to do will take enough time that the user would notice the save time is slow. So if I’m pulling a bunch of variables to put into an email and send, I’ll enable a post processing and do the email there. Setting two fields wouldn’t make a significant impact on the save time (I wouldn’t think), but obviously you can test it and if you can get it working in one pre-processing bpm, you can then work on moving that part to a post-processing one.

Thanks Cory, this has been super helpful!! We’ve added in the extra condition, and changed the condition criteria to ‘changed’. When adding a message box to the end of this, it worked when creating a new part and was able to see the message.

Now we have replaced the Message with Set Field

Production Prep Buffer remains 0 :frowning:

Will check debugging again to see if I can spot what is happening.

Just a guess - maybe you might have to convert the ‘222’ to type INT?

It looks like you’re coming off the false side of you’re condition, the bpm editor isn’t always super clear where the lines are going, but make sure you drew that connection from the true side (on the left) to your set field.

Ahhh yes!! Sorry my bad, I did it on the true side for the message, and decided to do false for the set field :sweat_smile:

I’ve switched it to true and the Prep Buffer remains 0 :frowning:

I tried Set Field on a Part.LotShelf field to see if it was a int issue and it set it there no problem :thinking:

Seems bringing in PartPlant, is where the issue seems to be

I might have been wrong about doing it all in pre-processing. Since you’re doing this when adding a new row, there is no PartPlant record for this part at this point in the method. It will get created as part of the base processing.

Now that you’ve got the condition working, go back to enabling post processing and try setting it there.

1 Like

It looks like a PartPlant record is not available in the Update unless one of the fields being updated is in a PartPlant record. With this info message, asking to show the PartPlant.Plant, it will be blank unless I actually modify a PartPlant field:

1 Like

Ah yes! Thank you so much for looking at this! So I just tried this out by changing the purchasing min order qty, and the BPM fired/updated the Prep Buffer field to 222 as it was a change on the Part Plant record like you said.

I’ve been doing some testing on setting the field as a post process but it doesn’t do it there either. The only place it actually does update is when we do an In Transaction Data Directive on PartPlant, but then we lose the condition from the Part table :thinking:

We almost need it so that we set the condition on the part.update pre-processing, then somehow bring this into a data directive against the partplant :sweat_smile:

1 Like

See the BPM in this comment. This might do the trick

1 Like