Updating JobMtl Record during Get Details with BPM

We have a number of jobs where all the material is bought directly to the job. Once the Get Details step has been done from the method, users are manually going to each material record in Job Entry and selecting the Purchase Direct box. They would like for this box to be selected automatically so every material record does not need to be touched.

There is no BuyIt(field name from JobMtl) field in the PartMtl table or the ECOMtl table, so I can’t set it as True elsewhere.

I have tried to add a Post-Processing BPM to method Erp.JobEntry.GetDetails where custom code sets the field to True. The code works and sets the field (verified with message boxes), but when checking the field either in Job Entry, or with a BAQ, it didn’t truly get set.

Another trace on actually clicking the Purchase Direct box in Job Entry revealed that 2 methods are called, CheckJobMtlBuyIt and ChangeJobMtlBuyIt. I’m thinking I need to call those 2 methods in my code to get the value to set, and also call the Update method to save the change.

Is achieving this through code the best way to go? If it is, I’ve looked at the Programming Guide on EpicWeb on calling methods, but I’m not sure how to call the right method and how to know what to pass to the method.

If doing this through code is not best way, what is a better way?

one “simple” thing to try…

  1. create an IN-Transaction Data BPM on the JobMtl record…

  2. Trigger when the JobMtl record is ADDED.

  3. Set the ttJobMtl.BuyIt to true.

Then look at the results and see if you get Purchase suggestions when you run suggestions. If you do, then make POs for them and make sure all the links are correct.

If the part is set as non stock, it will be set as purchase direct when you get details.

Also for setting the purchase direct flag, you have to set DSP buy it ( it’s called something similar to that) as well as the buyit flag. that field isn’t in the database schema, but it shows up in the tttables for some reason. That’s probably why your BPM isn’t working.

Can you set that checkbox on the UI itself with code?

When you set the purchase flag in the UI it seems to set both check boxes in one UI check box. I don’t know why the TT tables (and DMT) have both, but the UI only has one. I just know that to manipulate it you need to set both in BPM or DMT. If you only try to set buyit it doesn’t take the change.

Tim is correct: Create a data directive on JobMtl - In transaction and paste the code below- tested and it works:

using (var txScope = IceContext.CreateDefaultTransactionScope())
{
var ttJobMtl_xRow = (from ttJobMtl_Row in ttJobMtl
where ttJobMtl_Row.RowMod == IceRow.ROWSTATE_ADDED
select ttJobMtl_Row).FirstOrDefault();

if (ttJobMtl_xRow != null)

 { 
    ttJobMtl_xRow.BuyIt  = true;

  }

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

BUT… go Codeless with a widget… no need for all that dangerous coding… and it will upgrade better later.

5 Likes

Thanks everyone! Just needed to do this in quoting and adapted the data directive for QuoteMtl.BuyIt and it worked first time.

1 Like

What if I want to filter this action by part class

do a create query condition in which you join the ttpart number to the part table, and only include the part classes you want.

Why am I not seeing that condition?

It’s amazing how much you loose when you take a year off from this stuff. Thanks for the nudge in the correct direction.

1 Like

I keep getting the following error

image

The error seems to be associated with my query criteria. I feel like I am missing something that is glaringly obvious to someone else.

What happens when you put single quotes around your ‘160’ constant?

Yup just before you replied that is what I tried and it worked. Thanks!

2 Likes

Yeah, it’s one of those things where it looks like a SQL BAQ, but it’s actually C# so some of the rules change. I wish they would fix that. (by fix I mean just make a more intelligent error message, and preferably one that shows up earlier)

Why can’t I get this query to work?

It should be ‘Glass’ (single quotes), and I don’t know what * are going to do. Are you trying to find something that contains glass? Try Like.

When I try single quotes I get the following error.image