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.
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.
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?
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
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.
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
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.
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
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.