Debugging (Tracing) System Button

I am working on the Work Queue screen in the MES. I am attempting to automate the search for work based on Resource Group.

Currently, you have to click the button “RESOURCE GROUP” which opens up a Resource Group search, when you select a record, it automatically closes the search (calls LoadUserResults), then performs WorkQueueAdapter.GetOpsInResourceGroup.

I have created a button, and I manually call GetOpsInResourceGroup using the data I want - OK here, no problems. It goes like this:
wq.GetOpsInResourceGroup(ResGrupID, EmpID, WhereWork, WherePart, 0, 1, out res,LaborType,out WorkRecs,ClearCache,Filter);

No data appears. So I add oTrans.Refresh(); It appears that it runs GetOpsInResourceGroup again but with whatever PARAMS the system uses. I.E. - Since I didn’t manually pick a resource, I get “No valid ResourceGroupID”.

Ultimately, how do I find out where the process is pulling it’s PARAMS from, I assume they will be available to me, IF I can find them. Tracing showed me what methods are called, and what params are passed - but I cant find the damn things.

If it helps, the MES screen is: DEGO1080

The button EPI binding is: WorkQueue.ResourceGroupButton
The button GUID is: 36da63c1-8ce7-4f2c-9c5b-6de0d778b39b

Try getting your resource ID and your resourceeGroupDescription and then do the following

Then it gets tricky you need to set ClearWorQueueCACHE to true but this is an internal private variable so you’ll have ot use reflection… (do you know how to use reflection?)
the variable name is ClearWorQueueCACHE and you want to set it to true, it is defined in the oTrans object

Then you want to invoke another private function this time defined in WorkQueueEntry.WorkQUeueForm called setUpWorkQeueueRecordsPageInfo() again this needs to be invoked via reflection
last you want to also invoke the private function OnAfterResrouceGroupSearch() also defined in oTrans

If you don’t know reflection i can put an example together but otherwise this should do it

1 Like

I know the purpose of reflection, but I have never used it. A basic example in Epicor would be Epic :smiley:

Also, there is a parameter in WorkQueue.GetOpsInResourceGroup called ClearCache 0 is this different than what you are describing?

I am not sure about that param…

Note I can’t test the below example so I am going to do my best to type without scrwing thing up! But I can’t guarantee it, so if you have syntax issues let me know

using System.Reflection; //Add
public void mySelection(String resourceGroupID, String resourceGroupDesc)
         var prop = oTrans.GetType().GetField("ClearWorQueueCACHE", System.Reflection.BindingFlags.NonPublic    |      System.Reflection.BindingFlags.Instance);
         prop.SetValue(oTrans, true);
         workQueueForm.GetType().GetMethod("setUpWorkQueueRecordsPageInfo",System.Reflection.BindingFlags.NonPublic    |      System.Reflection.BindingFlags.Instance).Invoke(workQueueForm,null);
         oTrans.GetType().GetMethod("OnAfterResourceGroupSearch",System.Reflection.BindingFlags.NonPublic    |      System.Reflection.BindingFlags.Instance).Invoke(oTrans,null);

1 Like

Meh - edit fail

You have to decompile the epicor DLL’s which I do for fun on my spare time :wink: jk

1 Like

Error: CS0103 - line 127 (291) - The name ‘s’ does not exist in the current context

LoL paste your code gonna need some context. Paste the line its erroring at… actually I see it

prop.SetValue(s, true);

should be

prop.SetValue(oTrans, true);

Paste MY code? Haha, I’ve stole yours! :smiley:

public void mySelection(String resourceGroupID, String resourceGroupDesc)
var prop = oTrans.GetType().GetField(“ClearWorQueueCACHE”, System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
prop.SetValue(s, true); //<----- OFFENDER, what is the s object supposed to represent?
WorkQueueForm.GetType().GetMethod(“setUpWorkQueueRecordsPageInfo”,System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).Invoke(WorkQueueForm,null);
oTrans.GetType().GetMethod(“OnAfterResourceGroupSearch”,System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).Invoke(oTrans,null);


I edited my earlier response it should be prop.SetValue(oTrans,true) instead of s

1 Like

Dude, I am now convinced, you are the BORG! What’s your paypal, I owe you a case of beer - Works great!

hehe no need just mark the answer as solution :slight_smile:

Why do they force us to use a ResourceGroup? I’d love to use just a Resource (representing a machine).

I am sure I can filter my results right in the EpiDataView though it would nice to make use of those Where clauses in the GetOpsInResourceGroup().

OR … You can Assign a Default Resource Group and Resource to the Employee ID and it will automatically pull that when you open the work queue:

1 Like

@TGCTSE Terry, awesome thanks! I’ll see how that works tomorrow.