Issue Material screen - should Not issue if the Job's material is marked Direct

In an attempt to prevent “Make Direct” job material from being issued in this screen (i.e. storekeepers should use the Job Receipt to Job screen), I’m trying to stop the transaction from occurring if the BAQ checking the material returns JobMtl.Direct = true.

I have several ValueChanged checks on PartNumber, Qty and LotNumber in an attempt to prevent the transaction, but I have been able to issue direct material anyways.

I tried using throw new Exception(MessageBox.Show(“Make Direct Parts Cannot Be Issued Here”).ToString()); but it just issued anyways.

How can I stop the issue transaction from occurring when the part is marked “direct”? The only options in the Form Event Wizard for EpiViewNotification are: CallContextBPMData, CallContextClientData, Done, IM, Select, and Select List.

Any suggestions are welcome,
Karen

Have you tried doing this in a BPM rather than customization?

I considered a BPM, but wouldn’t that prevent the Direct material from ever being issued to a job, even by the Job Receipt to Job screen?

You should be able to set it up to only throw an exception when you are in that specific module, and the exception message works like a charm in the BPM designer.

In the BPM designer, you can access what module the BPM gets fired in with that CallContextClientData -> ProcessId.

EDIT:

Sorry, referenced the wrong CallContextClientData field to use. AssemblyName will have the module’s id, not ProcessId

Hi Adam,
So I’ve been working on a Method Directive BPM on the IssueReturn BO for PrePerformMaterialMovement and I realized I probably don’t need to check CallContextClientData using AssemblyName because the bpm is for that method itself.
The JobReceiptToJob form doesn’t call that BO (at least I can’t find it in my Trace Data) so I can just prevent issuing Direct material in that BO.

My problem is that now I need to check if the material is “Direct” but I can’t seem to refer to any transactional variables in the BPM’s execute custom code box. I’m declaring both JobMtl and PartTran, and referring to their current values unsuccessfully. In previous BPMs I could refer to the current record associated with the BPM but in this one, it doesn’t recognize it. Any ideas on how to grab the JobNum and MtlSeq being issued to?
Thanks for any light you can shed on this,
Karen

Hey Karen,

I see what you mean, it looks like that BO method doesn’t use those (temporary) tables you were referencing previously. Can you post your code? How are you declaring the JobMtl/PartTran tables? You should be able to do this with just the standard BPM blocks also. It may be easier in a data directive, but if you want to try with this IssueReturn.PrePerformMaterialMovement:

That method has some temp-tables you can work with that contain those transactional variables you are looking for (or some). An easy way to view which temp tables are used in a method is to go to the “Set Argument/Variable” block, and getting to the Specify C# expression window. It looks like the ttIssueReturn table is your best bet here, there is the PartNum and ToJobNum you could try using (Not sure which of those are mtl sequence, but this shouldnt be an issue if a part is always EITHER make direct or not).

To try this without the custom code block (the Epiusers.help certified way), you can set those fields from the ttIssueReturn as variables with the “Set Argument/Variable block”

Then you can use these variables in a condition block and the condition that uses a designed query.


EDIT: Replaced picture to include true rather than the error prone 1 in the criteria’s bool statement

So if there’s a record on the JobMtl table that meets the Table criteria, the error will throw.

If you have issues getting this to work with that BO/Method, a data directive on the JobMtl should work. The approach will be very similar to the one above, but your temp table for the variables will actually be from the JobMtl table. And since this will get fired anytime material is issued, you would need to use the CallContextClientData.AssemblyName in your conditional block. Also a condition to only proceed when a row gets updated.

Hope this helps!

EDIT:
Just realized, if you go the data directive route, you can skip the query part since you have the ttJobMtl table. So you can just check in a conditional statement if the mtl is direct.

image

Hi Adam,
Wow! You’ve given me lots of options! Thank you very much for the level of detail in your response. I was able to emulate the Method Directive but am currently experiencing a “Server Side Exception” error that I’m trying to work through.
One reason I’m not using the Data Directive on JobMtl is because I don’t know the order of row insert/update/delete on all the tables involved when the transaction occurs.
i.e. Does the PartTran get added to first and then the PartBin decremented and then JobMtl updated? I figure if I kill the method, none of the transactions will occur. Does that make sense?
Thank you again for your generous assistance and instructions,
Karen

I think as long as you do an In-Transaction data directive, the exception will stop the update to JobMtl as well as associated table updates. I’m not completely certain, but I would hope Epicor doesn’t make it that easy to screw your data up! Definitely something I’m going to look into. What error message are you getting for the server-side error?

Hi Adam,

Even though I did the validation step after entering the two “Set Argument/Variable” command boxes, and after the “Condition” box and the “Raise Exception” box, it gave me the following compilation error when I tried to enable it:

Server Side Exception

There is at least one compilation error.

Exception caught in: Epicor.ServiceModel

*Error Detail *
============
Description: There is at least one compilation error.
*Details: *
Error CS1593: Delegate ‘System.Func<Erp.Tables.JobMtl,int,bool>’ does not take 1 arguments [PrePerformMaterialMovement.Pre.StopMakeDirectPa.cs(121,21)]
Error CS1660: Cannot convert lambda expression to type ‘string’ because it is not a delegate type [PrePerformMaterialMovement.Pre.StopMakeDirectPa.cs(121,21)]
Error CS0019: Operator ‘==’ cannot be applied to operands of type ‘bool’ and ‘int’ [PrePerformMaterialMovement.Pre.StopMakeDirectPa.cs(123,28)]
Program: Epicor.Customization.dll
Method: PrepareException
Line Number: 99
Column Number: 13
Server Trace Stack: at Epicor.Customization.Standard.CustomizationCompiler.PrepareException(CompilerErrorCollection errors) in C:_Releases\ICE\3.1.500.15\Source\Framework\Epicor.Customization\Standard\CustomizationCompiler.cs:line 99

Within the Pre-Processing step, when I hit “Validate”, it always reports “Directive validation succeeded. No issues were found”, which is obviously not the case.

I’m attempting to do the Data Directive now, on the JobMtl table.

Thanks again for your support Adam,
Karen

Hey Karen,

I think I see a possible reason for the error in some of my snapshots…The BAQ designer for BPM’s is slightly different than the normal one. It needs true and false for boolean types, 1 and 0 will throw errors. If you used my images above (sorry!), try changing all 1’s and 0’s in boolean statements to either true or false (no quotes, all lower case)
image

Hi Adam,

I’m still getting an error on the Method Directive. I was getting an error that said ‘True’ didn’t exist in the current context so I changed it back to one. It made no difference.
I did remove the Direct = 1 condition and there were no other validation errors but then I had to put it back in, and it’s unhappy again.

Here’s the first portion of the Server Side Error:

Server Side Exception

There is at least one compilation error.

Exception caught in: Epicor.ServiceModel

*Error Detail *
============
Description: There is at least one compilation error.
*Details: *
Error CS1593: Delegate ‘System.Func<Erp.Tables.JobMtl,int,bool>’ does not take 1 arguments [PrePerformMaterialMovement.Pre.StopMakeDirectPa.cs(121,21)]
Error CS1660: Cannot convert lambda expression to type ‘string’ because it is not a delegate type [PrePerformMaterialMovement.Pre.StopMakeDirectPa.cs(121,21)]
Error CS0019: Operator ‘==’ cannot be applied to operands of type ‘bool’ and ‘int’ [PrePerformMaterialMovement.Pre.StopMakeDirectPa.cs(123,28)]
Program: Epicor.Customization.dll
Method: PrepareException
Line Number: 99
Column Number: 13
Server Trace Stack: at Epicor.Customization.Standard.CustomizationCompiler.PrepareException(CompilerErrorCollection errors) in C:_Releases\ICE\3.1.500.15\Source\Framework\Epicor.Customization\Standard\CustomizationCompiler.cs:line 99

I googled the “Delegate ‘System.Func<Erp.Tables.JobMtl,int,bool>’ does not take 1 arguments” and realized its trying to tell me its looking for another argument but since its one line of criteria that are restricted by drop-down options, not sure how I’d provide another argument.

Also, I did build the Data Directive in lieu of this one and it still allowed the Direct material to be issued (and yes I had it enabled) so don’t know where I went wrong there either. Clearly I’m not providing the right criteria for it to stop the issue.

Still circling the airport but grateful for your input and suggestions Adam!

Karen

Hey Karen,

Did you try True or true? If you did True (capital T), try true (all lowercase no quotes) I THINK your error is still related to the boolean statement. Still kicking myself for giving you bad pictures… here’s a post with that error message. OP has issues with 0 and False, finally false worked.

2 Likes

Hi @kfreeman,
i have an In-Tran data BPM on the PartTran table stopping issue / return material transaction when certain condition at PartLot table to be met, i can share it here if you want, so you can alter it to call, then validate the direct field data of the JobMtl instead.

Hi Adam,

It worked!! The ‘true’ instead of ‘True’ or ‘1’ worked! Thank you very much!

I tested the BPM and that also worked in stopping the Direct material issue in the “Issue Material” screen.

I am so relieved to finally get this issue stoppage to work I cannot put it into words!

Thank you so very much for your support on this!

Karen

Hi Al,

I finally got the Method Directive BPM to work… by changing the Boolean comparison value to ‘true’ from ‘True’. One little letter.

Thank you for your offer to place your code for the In-Tran BPM but since my Method Dir. BPM is working now, thanks to Adam Szoka, please don’t feel obligated to do so. You certainly can if you’d like as I’m sure I’ll need the resource in the future. :slight_smile:

Thank you for your support Al,
Karen

1 Like

Good deal! Glad to hear it! Happy to help, sorry to lead you down a path of errors haha

It was certainly a learning experience! All of your suggestions were great except for one capital T.
And then you resolved that one too!

Thanks again Adam!
Karen :grinning:

1 Like