Open Form with Job Number from Button

I have customized the MES screen with buttons to open some forms (Issue Material, Job Receipt to Inventory, Return Material. I have it working and opening the correct form but unable to get the form to load with the job number. I am able to capture the job number and throw up in a message box. (If I were able to purchase AMM then this would already be done but cost not approved to purchase)

I am a novice at best. Hoping one of you gurus out here can help me with the code.

Here is the code on the MES screen

private void epiButtonC1_Click(object sender, System.EventArgs args)
{
// ** Place Event Handling Code Here **
MyJob = (EpiTextBox)csm.GetNativeControlReference(“e4253ffa-67f0-4074-b6c3-c85433229f82”);
MyOpr = (EpiNumericEditor)csm.GetNativeControlReference(“09b340c3-c8dd-420b-b91b-d3e989b755c6”);
LaunchFormOptions lfj = new LaunchFormOptions();
LaunchFormOptions lfo = new LaunchFormOptions();
lfj.ContextValue = MyJob.Text;
lfo.ContextValue = MyOpr.Text;
lfj.IsModal = false;
lfo.IsModal = false;
lfj.SuppressFormSearch = true;
lfo.SuppressFormSearch = true;
MessageBox.Show (MyJob.Text);
MessageBox.Show (MyOpr.Text);
ProcessCaller.LaunchForm (oTrans, “IMGO3001”, lfj);
}

Here is the code on the form I am trying to open which is Issue Material.

private void IssueMaterialForm_Load(object sender, EventArgs args)
{
// Add Event Handler Code
LoadJob();
if(IssueMaterialForm.LaunchFormOptions != null)
{
object ctxvalue = IssueMaterialForm.LaunchFormOptions.ContextValue;
}
}

private void LoadJob()
{
	MessageBox.Show(IssueMaterialForm.LaunchFormOptions.ContextValue.ToString());
}

Try

lfj.ValueIn = MyJob.Text;

In LoadJob() call this method passing in the job number. I didn’t test this, but it may work for what you want.

oTrans.GetByID(<jobnum>);
1 Like

Thanks I will try the oTrans.GetByID();

Which form do I put this on? The MES screen or the Issue MAterial screen? Thanks in advance.

You would place the code i described on the Caller (MES), the Callee (Issue) already has code built in to process that.

Update…well that is true in E10 - can’t speak for E9:

protected override void OnFormLoaded()
{
    this.baseToolbarsManager.Tools["NewTool"].SharedProps.Enabled = false;
    if (((base.LaunchFormOpts != null) && (base.LaunchFormOpts.ValueIn != null)) && !string.IsNullOrEmpty(base.LaunchFormOpts.ValueIn.ToString()))
    {
        this.baseToolbarsManager.Tools["PrimarySearchTool"].SharedProps.Enabled = false;
        this.trans.GetNew(base.LaunchFormOpts.ValueIn.ToString());
        this.trans.KeyPassedOnLaunch = true;
    }
    this.issueMtlDock1.issueMtlPanel1.Focus();
    base.OnFormLoaded();
}

Along the lines of what @tkoch said, it specifically does this (in E10):

this.trans.GetNew(base.LaunchFormOpts.ValueIn.ToString());

Well I gave it a try but unfortunately a novice at best. I put the lfo.ValueIn=MyJob.Text; in the code below for button 1 click but no luck. I guess I am not grasping of what to put where. The Code does open the Issue Material Form but the Job is not populated. Any help would be appreciated. This code is on the MES screen. I did not follow the protected override void OnFormLoad

private void epiButtonC1_Click(object sender, System.EventArgs args)
{
// ** Place Event Handling Code Here **
MyJob = (EpiTextBox)csm.GetNativeControlReference(“e4253ffa-67f0-4074-b6c3-c85433229f82”);
LaunchFormOptions lfo = new LaunchFormOptions();
lfo.ContextValue = MyJob.Text;
lfo.IsModal = false;
lfo.SuppressFormSearch = true;
lfo.ValueIn = MyJob.Text;
//MessageBox.Show (MyJob.Text);
ProcessCaller.LaunchForm (oTrans, “IMGO3001”, lfo);
}

I broke out the E9 dll’s I can see its mostly the same (assuming I am looking at the right screen IssueMaterialEntry. When I dug a bit deeper I see that it’s looking for a MtlQueueRowID in E9, not a job,

That may not suit your fancy, but you can test it by getting the sysrow of some line in your queue to issue.

if you wanna write you own, go back to your original code, but in the Issue forms OnLoad event try:

            if(IssueMaterialForm.LaunchFormOptions != null)
            {
                 str myJob = IssueMaterialForm.LaunchFormOptions.ContextValue.ToString();

                string pcTranType = "STK-MTL";
		string pcMtlQueueRowid = "?";
		this.imAdapter.GetNewIssueReturn(pcTranType, pcMtlQueueRowid, "IssueMaterial");
                this.IMView.dataView[this.imView.Row]["ToJobNum"] = myJob;

}

or maybe even:

  if(IssueMaterialForm.LaunchFormOptions != null)
            {
                 str myJob = IssueMaterialForm.LaunchFormOptions.ContextValue.ToString();
                  loadSingleJob(myJob,"0"); //string job, string asm
              }

If you wanna pass in both job and asm, you can make a class (needs to be in both caller and callee)

class MyStuff
{
string job;
string asm;
string whateva;
}


//then you create it in caller
var stuff = new MyStuff();
stuff.job = "MyJob#";
stuff.asm = "MyAsm";


now stuff that guy into the contextValue
lfo.ContextValue = stuff;


// --- in the callee, you are gonna get that object and unbox it:
MyStuff stuffInCallee = (MyStuff)lfo.ContextValue;
//now you can get all your dataz
 loadSingleJob(stuffInCalee.job,stuffInCalle.asm);

With all that said, this was all written off the top of my head in this text editor with no checking/testing so no warranties :smiley: Not to mention - I’ve never used E9.

Oh Thank You. Will work on putting that in now.

One thing to add Is I do not have the (AMM - Advandced Material Management module) as the 20K is not an expenditure we can afford right now or it would work from the standard buttons. I am doing this to get us by as we are moving from KanBan to Jobs in manufacturing. Don’t know if not having that module limits us or not.

Understandable. I dont think not having the AMM will limit you in this case as long as you arent needed any of the following:

Advanced Material Management (AMM) enables businesses to produce electronic requests for materials, dispatch those materials, and track inventory movements of all inventory including raw materials and work in process. Using wireless terminals and bar coding technology you are able to track inventory in real-time with complete control and visibility of raw materials and work in process as it travels throughout the enterprise.

Bar Coding on Demand and Scanning
Print tags on demand enabling employees to properly label containers or to create custom labels (via Seagull Scientific, Inc. BarTenderÂŽ) to meet customer requirements. Eliminate data entry mistakes and increase transaction speed by simply scanning a bar code tag to complete an entire transaction.

Handheld
Allows for the transaction of work either on a graphical touch screen station or via mobile Radio Frequency (RF) enabled device.

Material Handler Interface
Use an online queue of raw material and WIP parts to manage requests to locate and deliver the right parts to the correct resource at the appropriate time.

Material Movement
Different movement transactions are available for you to move a job to stock, move stocked material, or perform different returns to a job or stock.

Prioritizing Orders
Lets you treat your best customers with the highest priority by automatically allocating inventory to the highest priority orders first. Reserve or allocate materials from stock or directly from a linked job to make certain that you ensure your highest priority customers the greatest care.

Reserving Inventory and Sales Order Allocation
Reserve specific parts in inventory for designated orders. Manage sales order allocations with greater efficiency and create more effective picking and shipping.

IssueMaterial.xml (25.9 KB)

Here is the Trace I did. I opened the Issue Material Form and then manually put in the Job#, Assembly, and Operation.

From the other post this is certainly a stretch for me. How do I go about getting a consultant to help? Still going to try as it would be rewarding to figure it out but know the odds are stacked against me.

I am all for learning. As long as you have the free time and can avoid throwing things at your computer, it’s a great thing :smiley:

One thing to note is that you can also get consultants for teaching as well. They can give you pointers, code snippets, explanations of what’s happening in a given situation. Even without doing an outright learning session - looking at what a consultant delivers for your solution, and trying to make sense of it goes a long way.

Also have you checked out all of the programming docs at epicweb.epicor.com?

Re: your trace, here’s the tasty stuff:
BO.JobEntry.GetList → whereClause = “JobNum = ‘TT063910’”

BO.IssueReturn.GetNewJobAsmblMultiple ->pcTranType=“STK-MTL” ,
pcMtlQueueRowID = “?”
pCallProcess’ = “IssueMaterial”

BO.IssueReturn.OnChangingToJobSeq → piToJobSeq = 10

BO.IssueReturn.OnChangeToJobSeq()

This is a process that I’ve recently done with my companies MES program as well. Essentially there are two separate pieces of code that need to be entered. One for the MES customization and another for the resulting form that opens from it. Also, you need to make sure that you are utilizing the correct MES customization. It personally took me some time to figure out how exactly to go about that process. But, I have attached the general code for how this process works. Feel free to tell me if you have any problems understanding the code or process!

Epicor Code - Transfer Value to New Menu.docx (13.3 KB)

was going to try this but not sure how to change the VB to C#. Thanks. I have quite a few options. Just a matter of putting the right combination together.

There’s some online VB to C# conversion websites you can find that would help. You will most likely have to mess with the syntax a little afterwards for the more unique Epicor functions though if you went that route.

Okay I went back and took your instructions and did the code in VB for the MES and C# for the Issue Material. The MES form below and worked and the pop-up message “Test” Worked. I then Clicked the Button and it did try to open the Issue Material form but had error which I guess I have the code wrong. Maybe it is the wrong DataView? Both code I have is below. Any help to figure out what is wrong would be appreciated.

MES Menu code
’ **************************************************
’ Custom code for MESMenu
’ Created: 06/20/2018 9:09:59 PM
’ **************************************************
Imports System
Imports System.ComponentModel
Imports System.Data
Imports System.Diagnostics
Imports System.Windows.Forms
Imports Microsoft.VisualBasic
Imports Epicor.Mfg.BO
Imports Epicor.Mfg.UI
Imports Epicor.Mfg.UI.Adapters
Imports Epicor.Mfg.UI.Customization
Imports Epicor.Mfg.UI.ExtendedProps
Imports Epicor.Mfg.UI.FormFunctions
Imports Epicor.Mfg.UI.FrameWork
Imports Epicor.Mfg.UI.Searches

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 **

Public Sub 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

	AddHandler Me.epiButtonC1.Click, AddressOf Me.epiButtonC1_Click
	' End Wizard Added Custom Method Calls
End Sub

Public Sub DestroyCustomCode()
	' ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Object Disposal' lines **
	' Begin Wizard Added Object Disposal

	RemoveHandler Me.epiButtonC1.Click, AddressOf Me.epiButtonC1_Click
	' End Wizard Added Object Disposal

	' Begin Custom Code Disposal

	' End Custom Code Disposal
End Sub

Private Sub MESMenu_Load(ByVal sender As Object, ByVal args As EventArgs) Handles MESMenu.Load 
' Add Event Handler Code

epiButtonC1 = CType(csm.GetNativeControlReference("25650da8-84c2-4a36-ab1e-a0d956fc9c40"), EpiButton)
epiButtonC1.ReadOnly = False 
MessageBox.Show("Test")

End Sub

Private Sub epiButtonC1_Click(ByVal sender As Object, ByVal args As System.EventArgs)
	' ** Place Event Handling Code Here **
	Dim lfo As LaunchFormOptions = New LaunchFormOptions()

	Dim edvSK As EpiDataView = CType(oTrans.EpiDataViews("LaborDtl"),EpiDataView)
    Dim strPartNumber As String
	

	If edvSK.DataView.Count() > 0 THEN
		strPartNumber = edvSK.dataView(0)("JobNum").ToString()
		lfo.ContextValue = strPartNumber
		ProcessCaller.LaunchForm(oTrans, "IMGO3001", lfo)
	Else
		lfo.ContextValue = ""
		ProcessCaller.LaunchForm(oTrans, "IMGO3001", lfo)

	End IF

End Sub

End Class

Issue Material Code

// **************************************************
// Custom code for RcptToInvForm
// Created: 06/20/2018 9:43:54 PM
// **************************************************
using System;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Windows.Forms;
using Epicor.Mfg.BO;
using Epicor.Mfg.UI;
using Epicor.Mfg.UI.Adapters;
using Epicor.Mfg.UI.Customization;
using Epicor.Mfg.UI.ExtendedProps;
using Epicor.Mfg.UI.FormFunctions;
using Epicor.Mfg.UI.FrameWork;
using Epicor.Mfg.UI.Searches;

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 **

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
}

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
}

private void RcptToInvForm_Load(object sender, EventArgs args)
{
	// Add Event Handler Code
	if (RcptToInvForm.LaunchFormOptions != null) 
		{ 
			EpiDataView edv = (EpiDataView)oTrans.EpiDataViews["SelectListView"]; 
			edv.dataView[edv.Row]["field1"] = RcptToInvForm.LaunchFormOptions.ContextValue.ToString(); 
		} 
}

}

Well tried some other options from other suggestions here but still no luck. I even sought out some help and was told it would be 4 weeks before I could even get help. Very Sad. I will go back to some of your suggestions and see if I can get something to work. Both examples I am able to put a button on the MES and open up the Issue Material form but nothing ever loads in the Job, Assembly, or Operation field. Will keep trying.

In customize mode, open the Object explorer → Data Tab
Expand until you get into the selectListView (assuming thats really the name)
Find the correct field name (I assume Field1 is not a valid field).
Update this line accordingly _> edv.dataView[edv.Row][“field1”] = RcptToInvForm.LaunchFormOptions.ContextValue.ToString(); }

and for good measure, at the end of that function, add oTrans,NotifyAll();

Btw - I see you’re a fellow southerner. I am just west of Nashville