Add Operation or Add Subcontract Operation?

Hi All,
I am working on a post-processing directive for the EcoOprInitSNReqSubConShip method of the EngWorkBench BO.

We are working within the Engineering Workbench. The request is to automatically fill in the ECOOper.OpCode field with a value.

  • If the user clicks Add Operation - then set OpCode to “99999”.
  • If the user clicks Add Subcontract Operation - then set OpCode to “SC”.

My post processing code does well on the GetNewECOOpr method. Any new operations automatically have the OpCode set to 99999. However, the same method fires when the users adds a subcontract operation. So any operations added for subcontract have the 99999 OpCode, instead of SC.

In the trace the only difference I see for subcontract, is that the method EcoOprInitSNReqSubConShip is called right after the GetNewECOOpr.

So my idea was to place the same code in the post-processing for EcoOprInitSNReqSubConShip. That way the system would first change the OpCode to 99999 when the new op was added, but then once the next method fires it would change that OpCode to SC.

I am just about all the way there, but I am not sure how to access the parameters that GetNewECOOpr created when I am in the EcoOprInitSNReqSubConShip method. Specifically I need the GroupID, PartNum, and RevisionNum to pass into GetDatasetForTree.

EDIT - Further Complications:
I ended up pulling the values I needed from the passed ds dataset. but…
After some research I see that VendorID and Days Out are also requirements for subcontract operations. When I try to update these fields and the OpCode field, my post-processing directive keeps saying:

Error Detail

Description: Cannot change the SubContract flag once set.
Program: Erp.Services.BO.EngWorkBench.dll
Method: ECOOprBeforeUpdate
Line Number: 18290
Column Number: 17
Table: ECOOpr
Field: SubContract

I believe this error is occurring on the method: ChangeECOOprOpCode.

END EDIT

What am I missing here?
Thanks!
Nate

Why don’t you just have them click and drag from the operations? Then they can grab the one they want and you don’t have to mess with all that?

adding%20operations

In the Post Proc of GetNewEcoOpr set the OpCode to “99999”.
In the Pre Proc of EcoOprInitSNReqSubConShip set the OpCode to”SC”

When I execute ChangeECOOprOpCode, how can I pass a reply to the returned refreshMessage? The message is asking if I want to reschedule resources. Normally I would click YES. But I am not sure how to pass that value through a widget. I don’t see any likely methods in the trace that would set or get this response value.
Thanks!

I think I am having trouble because GetNewECOOpr is run at the start of both processes. So When I click ‘add new subcontract op’, first it is running the above method, setting the opcode to 99999, then it tries to run the ECOOprInitSN… method, resulting in an error.

Is there a way I can tell which process has been clicked, before either of them run? If I knew it was subcontract when the GetNew method fired, then I could run if statements to process it correctly.

Will it matter if you set it to one value first and then the second method sets it to something else?

Jason Woods
http://LinkedIn.com/in/jasoncwoods

I get an error: Row has been modified by another user and couldnt be updated.

Is there a way I can tell which menu item/process has been clicked? Add Operation, or Add Subcontract Operation, before either of them run?

I really think that if I knew which menu item the user clicked on, then I could process these requests correctly.

I scoured through the Object Explorer and found something called ProcessCaller. Is this the right location to look to identify which menu item the user clicked on? Is this value even available at the method-directive level?

If you are going to do any work on the Customization side, then that may be a better idea to perform the logic in the customization instead.

I would prefer to isolate it to the method-directive side. Just seems cleaner that way (if it is possible.)

I would have to see the code you are attempting to use. The error doesn’t seem like that is normal for this.

Also, The OpCode and OpDescription are the only things that change when you add a new record. You could simply hard set them and not run ChangeECOOperOpCode

Jason Woods

Thankfully I am not using code for this, yet… Do you think a custom code widget would be better?

Here are the widgets that I setup in the post-proc of Erp.EngWorkBench.GetNewECOOpr





When I click Add new Operation from the eng workbench, the op is added and defaults assigned. This part works just fine by itself.

Here are the widgets that I setup in the pre-proc of Erp.EngWorkBench.EcoOprInitSNReqSubConShip



When this is enabled, and I click on Add Subcontract Operation from the eng workbench Action menu, a new operation is added, and then I get this error:

Error Detail

Description: ECOOpr has not changed.
Program: Erp.Services.BO.EngWorkBench.dll
Method: ChangeECOOprOpCode
Line Number: 5465
Column Number: 17
Table: ECOOpr

The added op appears to be a subcontract op at first (the icon and the subcontract checkbox indicate this). However, if I save or refresh the form, then the op changes back to a regular operation with my default settings.

I have been trying to brute-force this solution by trying every various combination of widgets.

You can see that if I could tell which button the user pressed, then I could avoid setting the new operation to default settings when they actually click the subcontract op.

Thanks for your time and patience!
Nate

I noticed you can’t see which datasets I am using for each widget. Generally speaking, I create a new dataset when I getdsfortree. I call it dsw. This is the dataset I use through most of the directives. However, I also use the dataset ds (which refers to the ttResults data) in a couple of places. I am not sure on how or when to use existing or new datasets. IF you need more clarification on which datasets I used, just ask.
Thanks!
Nate

I think you are doing too many widgets :smile:
I see you are using the Update method. I would recommend that you let the user do that on the UI side instead. This is likely why you are getting the “ECOOpr has not changed.”.
Remember, you are only trying to default the OpCode (and OpDesc). This can be done with a single Set Field and and single BO Method call.

When I try to do everything in one call, the description is not updated.Going back to the post-proc of Erp.EngWorkBench.GetNewECOOpr, I did just this:


I used only the internal dataset ds. But the description is not updated. Even after I click save or refresh.

That is why I ended up having to set the description in two steps, with one UpdateTBQ for the OpCode, and one UpdateTBQ for the OpDesc.

Not a huge surprise. What is the query doing?

Shouldn’t this just be a Set Field on the Added Row.

Either way, if it doesn’t populate the description, you could use the Update Table by Query to get the Description.

Jason Woods

After some tweaking to the pro-proc method for EcoOprInitSNReqSubConShip, I came back upon an error I have seen before while trying to get this working:

A valid Supplier Purchase Point is required.
Cannot change the SubContract flag once set.

This last error is what is really tripping me up. Once my first method runs and sets the defaults, then that method is set as a regular op, and cannot be updated to a subcontract op. I can’t even do this manually if I add an op and try to click the checkbox to change it to a subcontract. This makes me think that there is some internal lock keeping me from making that update.

All of these errors would likely go away if I could just know which menu item the user selected before my methods start.

Is that value available anywhere? Do I have to access it through a form customization? Can I access the value without a customization using just the method directives?

I ended up trying @Banderson’s idea. Making the engineers click and drag their ops into the list. I noticed this fired a different method that I could access the OpCode in.

The original request was to set some default fields depending on if the user added a regular operation or a subcontract operation.

For the regular operation, just update the OpDesc field to match the PrimaryOpDesc field.
For subcontract operations, just update the OpDesc field, and set DaysOut = 5.

I accomplished this nicely with a post-proc directive for: Erp.EngWorkBench.InsertOperationOP






Thanks for your help!
Nate

1 Like

I have been searching for weeks now for something like this. I have a bunch of parts that I need to update the Days Out based on the vendor. Your example is the closest thing I have found to accomplishing this. Could you explain to me what you are doing in “get dsw” and your “condition 0”? Also, if you have any suggestions on what Method would be best to build this post process on, I am open for any help possible.

Hi!
Get dsw, just creates the dataset “dsw” by using the GetDatasetForTree BO method.
Condition 0 just checks the opcode, and if it is “SC” (subcontracter) then, it also asks the user how many days out, as this is a field that must be set.

To find the best method, run a trace to find what methods fire when you execute the process manually.

Good luck!
Nate