Add "find by assembly sequence number" into job tree search

Since many places, especially in regards to purchasing, refer to an assembly sequence number, it would be incredibly useful to have a find by assembly sequence number in the job trees. Currently if I only have an assembly sequence number, I open up job traveler print to use the filter screen to find the part number. Then I search for that, and if it’s used in more than one place, I have to keep searching to find the right one.

In the same breath, a “find next” option when searching by part number on that search box would be great!

You can add this one yourself with a little bit of customization.
Here’s a quick one boiler plate. You’ll have to write the actual lookup yourself but it gets you most of the way there

// **************************************************
// Custom code for JobEntryForm
// Created: 7/26/2018 12:18:09 PM
// **************************************************

extern alias Erp_Contracts_BO_Project;
extern alias Erp_Contracts_BO_Part;

using System;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Windows.Forms;
using Erp.Adapters;
using Erp.UI;
using Ice.Lib;
using Ice.Adapters;
using Ice.Lib.Customization;
using Ice.Lib.ExtendedProps;
using Ice.Lib.Framework;
using Ice.Lib.Searches;
using Ice.UI.FormFunctions;

public class Script
{
	// ** Wizard Insert Location - Do Not Remove 'Begin/End Wizard Added Module Level Variables' Comments! **
	// Begin Wizard Added Module Level Variables **

	// End Wizard Added Module Level Variables **

	// Add Custom Module Level Variables Here **
	MenuItem findAssy =null;
	
	public void InitializeCustomCode()
	{
		// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Variable Initialization' lines **
		// Begin Wizard Added Variable Initialization

		// End Wizard Added Variable Initialization

		// Begin Wizard Added Custom Method Calls

		// End Wizard Added Custom Method Calls
		findAssy =  new MenuItem("Go To Assy Num", new EventHandler(cmFindAssy));
		
		
		oTrans.JobTree.BeforeShowContextMenu += new Ice.Lib.Framework.JobLib.MethodTree.BeforeShowContextMenuHandler(jobTree_BeforeShowContextMenu1);
		
	}

	public void DestroyCustomCode()
	{
		// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Object Disposal' lines **
		// Begin Wizard Added Object Disposal

		// End Wizard Added Object Disposal

		// Begin Custom Code Disposal

		// End Custom Code Disposal
		oTrans.JobTree.BeforeShowContextMenu -= new Ice.Lib.Framework.JobLib.MethodTree.BeforeShowContextMenuHandler(jobTree_BeforeShowContextMenu1);
	}
	private void cmFindAssy(object sender, System.EventArgs e)
    {
		MessageBox.Show("Do Search ,lookup work here");
	}
	private void jobTree_BeforeShowContextMenu1(object sender, Ice.Lib.Framework.JobLib.MethodTree.NodeArgs e)
    {
		oTrans.JobTree.TreeContextMenu.MenuItems.Add(findAssy);
	}
}

image

image

1 Like

If you do finish it (or someone) share the whole solution :stuck_out_tongue: I would but I’m slammed.

I (unfortunately) don’t have the technical skill to finish this solution, or I probably would.

I do think that this is a universal enough tool though that it should come out of the box from Epicor. Hence, why I put it in the feature requests and suggestions.

1 Like

Wanna see it get finished? Watch this… cough @Chris_Conn cough cough

1 Like

Lol not fair… Sitting in a doctor’s office

1 Like

You got your phone and RDP… #JustSaying

1 Like

Hence the coughing??? lol

2 Likes

try this - paste this in and replace joses MessageBox call with a call to MyStuff()

private void MyStuff()
	{
	var numstr = "10";
	if(ShowInputDialog(ref numstr ) == DialogResult.Cancel) return;
	
	int mtlseq = 10;
	if(!int.TryParse(numstr, out mtlseq))
	{
		MessageBox.Show(string.Format("No dice - {0} is not a number bro!",numstr));	
		return;
	}
	
		var jobMtl = oTrans.Factory("JobMtl");
		for(int row = 0; row < jobMtl.dataView.Count; row++)
		{
			if((int)jobMtl.dataView[row]["MtlSeq"] == mtlseq) 
			{
				oTrans.LastView = jobMtl;
				jobMtl.Row = row;
				oTrans.JobTree.ExpandAll();
				return;	
			}
		}
		
		MessageBox.Show("Bummer - MtlSeq not found!");
	
	}



private static DialogResult ShowInputDialog(ref string input)
    {
        System.Drawing.Size size = new System.Drawing.Size(200, 70);
        Form inputBox = new Form();

        inputBox.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
        inputBox.ClientSize = size;
        inputBox.Text = "Enter a MtlSeq";

        System.Windows.Forms.TextBox textBox = new TextBox();
        textBox.Size = new System.Drawing.Size(size.Width - 10, 23);
        textBox.Location = new System.Drawing.Point(5, 5);
        textBox.Text = input;
        inputBox.Controls.Add(textBox);

        Button okButton = new Button();
        okButton.DialogResult = System.Windows.Forms.DialogResult.OK;
        okButton.Name = "okButton";
        okButton.Size = new System.Drawing.Size(75, 23);
        okButton.Text = "&OK";
        okButton.Location = new System.Drawing.Point(size.Width - 80 - 80, 39);
        inputBox.Controls.Add(okButton);

        Button cancelButton = new Button();
        cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
        cancelButton.Name = "cancelButton";
        cancelButton.Size = new System.Drawing.Size(75, 23);
        cancelButton.Text = "&Cancel";
        cancelButton.Location = new System.Drawing.Point(size.Width - 80, 39);
        inputBox.Controls.Add(cancelButton);

        inputBox.AcceptButton = okButton;
        inputBox.CancelButton = cancelButton; 

        DialogResult result = inputBox.ShowDialog();
        input = textBox.Text;
        return result;
    }

And for JobAsm

private void MyStuff()
	{
	var numstr = "0";
	if(ShowInputDialog(ref numstr ) == DialogResult.Cancel) return;
	
	int asmseq = 0;
	if(!int.TryParse(numstr, out asmseq))
	{
		MessageBox.Show(string.Format("No dice - {0} is not a number bro!",numstr));	
		return;
	}
	
		var jobAsm = oTrans.Factory("JobAsmbl");
		for(int row = 0; row < jobAsm.dataView.Count; row++)
		{
			if((int)jobAsm.dataView[row]["AsmSeq"] == asmseq) 
			{
				oTrans.LastView = jobAsm;
				jobAsm.Row = row;
				oTrans.JobTree.ExpandAll();
				return;	
			}
		}
		
		MessageBox.Show("Bummer - AsmSeq not found!");
	
	}



private static DialogResult ShowInputDialog(ref string input)
    {
        System.Drawing.Size size = new System.Drawing.Size(200, 70);
        Form inputBox = new Form();

        inputBox.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
        inputBox.ClientSize = size;
        inputBox.Text = "Enter an AsmSeq";

        System.Windows.Forms.TextBox textBox = new TextBox();
        textBox.Size = new System.Drawing.Size(size.Width - 10, 23);
        textBox.Location = new System.Drawing.Point(5, 5);
        textBox.Text = input;
        inputBox.Controls.Add(textBox);

        Button okButton = new Button();
        okButton.DialogResult = System.Windows.Forms.DialogResult.OK;
        okButton.Name = "okButton";
        okButton.Size = new System.Drawing.Size(75, 23);
        okButton.Text = "&OK";
        okButton.Location = new System.Drawing.Point(size.Width - 80 - 80, 39);
        inputBox.Controls.Add(okButton);

        Button cancelButton = new Button();
        cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
        cancelButton.Name = "cancelButton";
        cancelButton.Size = new System.Drawing.Size(75, 23);
        cancelButton.Text = "&Cancel";
        cancelButton.Location = new System.Drawing.Point(size.Width - 80, 39);
        inputBox.Controls.Add(cancelButton);

        inputBox.AcceptButton = okButton;
        inputBox.CancelButton = cancelButton; 

        DialogResult result = inputBox.ShowDialog();
        input = textBox.Text;
        return result;
    }

1 Like

Several ways to skin the cat…

Could prob even create your own Dockable Tab and move the TreeView or TreePanel into your custom Tab (might have to do it via code) and then on top add filtering features via normal Customization =)

Example: This Panel has 2 textboxes and a Nav Control above the Tree.
2018-07-26_2000

couple of things that need to be change. (and I only am working with assembly sequence because material sequence are duplicated too many times to be useful)

FIrst, AsmSeq isn’t the right column name, it needs to be AssemblySeq

Needs to be

if((int)jobAsm.dataView[row]["AssemblySeq"] == asmseq)

After that it works… sort of.

After wasting a ton of time writing up a bunch of screen shots showing my testing, and realizing “no one cares about your testing”, I finally figured out that this search method will only search one level down from the assembly that you clicked on when you do the search.

This will need to iterate through the whole tree no matter where you are clicked on to make this useful. Since if I need to know the parent assembly, I am already only one click away anyways.

And I also commented out the “oTrans.JobTree.ExpandAll();” line, because it was really confusing…

It’s pretty close. Can it be made to look through the whole tree?

Lol - complex BOM eh?

Can it be made to search the whole tree. Yes, thought it would require some rework. Currently, it just looks at the jobAsm dataview - which I assume is parented (subscribed) to the parent asm - this is the reason it’s always looking at the tree level down.

I suppose a more flexible approach might be to crawl the tree itself (as opposed to the jobAsm dv) looking for Asm values matching your desired value BUT - we would also have the caveat that with a complex BOM, you could have multiple, nested ASM 0’s (or any asm) - I suppose it may be more useful to have the input box stay visible (until explicitly closed), this way - you could just keep hitting search until you get to the desired level. This should only start searching from the currently selected tree level. Definitely more involved.

Another fancier option might provide a list of all matches, that you can select from.

I wouldn’t need the search if we didn’t have complex boms, now would I? :wink:

I’m assuming that this is what the built in search does. Can we just hijack the programming used to make that and replace part number with AssemblySeq?

AsmSeq numbers are unique on the job. MtlSeq numbers are not.

This would work (be great!) for a part number search. I would not be necessary for assembly sequence number search though as there is only one per job of a certain AssemblySeq number

See! told you!

The existing code doesnt use to the tree to search, it uses:

public bool FindAssembly(string ipJobNum, int ipStartAssemblySeq, string ipPartNum, out int opAssemblySeq, out string opRowid)

Which uses the jobAdapter - it searches by part

Not sure it this will help in your case
I ended up adding a listview for assemblies that seem to help users working with complex structures. Pretty simple/easy to build - a BAQ, Dashboard & sheet wizard in Job Entry/tracker.
Note this dashboard really will show all parents and subassemblies, however the job displayed in this screenshot only had parent zero.

I had originally intended to modify the TreeView, but ran it similar issues with complex structures, many levels/subassemblies.
Was taking too much time & finally put it aside.but… thanks for shared the examples & ideas. I might try attacking this again… some day.

In the meantime… upvoted
.