JobNum data to MtlTags form

Hi friends. I’ve built a simple form customization with a custom button that takes data from text boxes on my form and also from a BAQ that I called in the customization and then formats the data into a string. Then I call the standard Epicor “MtlTags” form (dll) and pass this string to it. This all works great except I cannot seem to get the JobNum value passed into the string. I have the data for JobNum (which I can prove with a pop-up message), but can’t seem to find where in the string to put it. When I add it at the beginning of the string (or in the middle), it yells about not having the right data in column “PORel” (for example). So, I’m pretty sure the first 11 segments of the string are listed in the correct order below. If I put the JobNum value at the end, it completely ignores it. My resulting material tag (processed through Bartender) has all the appropriate data in the correct place except for JobNum.
Has anyone had any luck calling the MtlTags form this way? If so, what string position was the JobNum value in?
My code is posted below.
Thanks!
-Sharla

private void btnPrintTag_Click(object sender, System.EventArgs args)
{
string currentVal = getParametersForMtlTags();
ProcessCaller.LaunchForm(oTrans, “Erp.UIRpt.MtlTags”, currentVal);
}

private string getParametersForMtlTags()
{
string str = “~”;
StringBuilder builder = new StringBuilder(string.Empty);

//PartNum
builder.Append(txtPartNum.Text);
builder.Append(str);

//PartDesc
builder.Append(txtPartDesc.Text);
builder.Append(str);

//Qty
builder.Append(txtQty.Text);
builder.Append(str);

//TagTitle
builder.Append(“WIP”);
builder.Append(str);

//UOM
builder.Append(txtUOM.Text);
builder.Append(str);

//VendorNum
builder.Append(“0”);
builder.Append(str);

//PONum
builder.Append(“0”);
builder.Append(str);

//POLine
builder.Append(“0”);
builder.Append(str);

//PORel
builder.Append(“0”);
builder.Append(str);

//WhseCode
builder.Append(txtWhse.Text);
builder.Append(str);

//BinNum
builder.Append(txtBin.Text);
builder.Append(str);

return builder.ToString();

}

I dont see JobNum as a param - perhaps its pulled from the PO?

image

Hi Chris.
I don’t see how the JobNum would come from PO since, in my case, I have a job without a PO. It’s just a make to stock job. For example, when I end an activity in MES, I can “print tags” on that screen which calls this MtlTags form and there’s no PO involved, yet it prints the JobNum (and everything else) just fine.
So, I’m trying to mimic this “print tags” button on the MES End Activity screen.
Thanks, Sharla

Chris-
Also, where are you getting to those params you pasted in your reply?
Thanks, Sharla

I am decompiling the DLL for the MtlTagForm.

I can see lots of diff handling of parameters based on the calling form. So I can see now you are using MES End Activity.
Here is how they get the params:

        this.incomingParams = base.LaunchFormOpts.ValueIn.ToString();
        char[] separator = new char[] { '~' };
        string[] parameters = this.incomingParams.Split(separator);

Here are the params for that:

    if (parameters[0] != "")
    {
        base.ReportParmsView.dataView[base.ReportParmsView.Row]["PartNum"] = parameters[0];
    }
    if (parameters[1] != "")
    {
        base.ReportParmsView.dataView[base.ReportParmsView.Row]["PartDesc"] = parameters[1];
    }
    if (parameters[2] != "")
    {
        base.ReportParmsView.dataView[base.ReportParmsView.Row]["TotalQty"] = Convert.ToDecimal(parameters[2]);
    }
    if (parameters[5] != "")
    {
        base.ReportParmsView.dataView[base.ReportParmsView.Row]["UnitOfMeasure"] = parameters[5];
    }
    if (parameters[2] != "")
    {
        base.ReportParmsView.dataView[base.ReportParmsView.Row]["QtyPer"] = Convert.ToDecimal(parameters[2]);
    }
    if (parameters[3] != "")
    {
        base.ReportParmsView.dataView[base.ReportParmsView.Row]["TagFormat"] = parameters[3];
    }
    if (parameters[4] != "")
    {
        base.ReportParmsView.dataView[base.ReportParmsView.Row]["Revision"] = parameters[4];
    }
    if (parameters[6] != "")
    {
        base.ReportParmsView.dataView[base.ReportParmsView.Row]["JobNum"] = parameters[6];
    }
    if (parameters[7] != "")
    {
        base.ReportParmsView.dataView[base.ReportParmsView.Row]["AssemblySeq"] = Convert.ToInt32(parameters[7]);
    }
    if (parameters[8] != "")
    {
        base.ReportParmsView.dataView[base.ReportParmsView.Row]["OprSeq"] = Convert.ToInt32(parameters[8]);
    }
    if (parameters[9] != "")
    {
        base.ReportParmsView.dataView[base.ReportParmsView.Row]["PONum"] = Convert.ToInt32(parameters[9]);
    }
    if (parameters[10] != "")
    {
        base.ReportParmsView.dataView[base.ReportParmsView.Row]["POLine"] = Convert.ToInt32(parameters[10]);
    }
    if (parameters[11] != "")
    {
        base.ReportParmsView.dataView[base.ReportParmsView.Row]["PORel"] = Convert.ToInt32(parameters[11]);
    }
    if (parameters[12] != "")
    {
        base.ReportParmsView.dataView[base.ReportParmsView.Row]["VendorNum"] = Convert.ToInt32(parameters[12]);
    }
    if (parameters[13] != "")
    {
        base.ReportParmsView.dataView[base.ReportParmsView.Row]["PurPoint"] = parameters[13];
    }
    if (parameters[14] != "")
    {
        base.ReportParmsView.dataView[base.ReportParmsView.Row]["NonConfTranID"] = Convert.ToInt32(parameters[14]);
    }
    if (parameters[15] != "")
    {
        base.ReportParmsView.dataView[base.ReportParmsView.Row]["ReasonCode"] = parameters[15];
    }
    if (parameters[0x10] != "")
    {
        base.ReportParmsView.dataView[base.ReportParmsView.Row]["ReasonType"] = parameters[0x10];
    }
    if (parameters[0x11] != "")
    {
        base.ReportParmsView.dataView[base.ReportParmsView.Row]["Comment"] = parameters[0x11];
    }
    if (parameters[0x12] != "")
    {
        base.ReportParmsView.dataView[base.ReportParmsView.Row]["WarehouseCode"] = parameters[0x12];
    }
    if (parameters[0x13] != "")
    {
        base.ReportParmsView.dataView[base.ReportParmsView.Row]["BinNum"] = parameters[0x13];
    }

Chris, thank you for the code behind that dll!
So, when I pass in the data to the form in this exact order, I’m back to the columns not matching up. See the screenshot. below. Some values are hard-coded just to be sure there’s data in every field (for now).
image

Here’s my updated string building code that produces this error:
private string getParametersForMtlTags()
{
string str = “~”;
StringBuilder builder = new StringBuilder(string.Empty);

	//PartNum
	builder.Append(txtPartNum.Text);
    builder.Append(str);

	//PartDesc
	builder.Append(txtPartDesc.Text);
	builder.Append(str);

	//TotalQty
	builder.Append(txtQty.Text);
	builder.Append(str);

	//UOM
	builder.Append(txtUOM.Text);
	builder.Append(str);

	//QtyPer
	builder.Append("1");
	builder.Append(str);

	//TagFormat
	builder.Append("WIP");
	builder.Append(str);

	//Revision
	builder.Append("_");
	builder.Append(str);

	//JobNum
	builder.Append(txtJobNum.Text);
	builder.Append(str);

	//AssemblySeq
	builder.Append("0");
	builder.Append(str);

	//OprSeq
	builder.Append(txtLastOpSeqComp.Text);
	builder.Append(str);

	//PONum
	builder.Append("0");
	builder.Append(str);

	//POLine
	builder.Append("0");
	builder.Append(str);

	//PORel
	builder.Append("0");
	builder.Append(str);

	//VendorNum
	builder.Append("0");
	builder.Append(str);

	//PurPoint
	builder.Append("0");
	builder.Append(str);

	//NonConfTranID
	builder.Append("0");
	builder.Append(str);

	//ReasonCode
	builder.Append("0");
	builder.Append(str);

	//ReasonType
	builder.Append("0");
	builder.Append(str);

	//Comment
	builder.Append("0");
	builder.Append(str);

	//WhseCode
	builder.Append(txtWhse.Text);
	builder.Append(str);

	//BinNum
	builder.Append(txtBin.Text);
	builder.Append(str);

    return builder.ToString();
}

Thanks for your help!!
-Sharla

At a quick glance, I see some issues with your ordering.

The order of the code I posted isnt important, it’s the order of the indexes [x] that count

TotalQty AND QtyPer are the same param idx 2 (the third item)
TagFormat is idx 3 (the 4th item)
Revision is idx 4 (the 5th item)
UOM is idx 5 (the 6th item)

I’d start by making it more clear, take the code I posted and trim it down so it looks like:

"PartNum" = parameters[0]
"PartDesc" = parameters[1];
"TotalQty" AND "QtyPer" = parameters[2];
etc...

This will clearly define the format/order

So the way that I’m building my string, wouldn’t it just be like this?..

             //PartNum
	builder.Append(txtPartNum.Text);
    builder.Append(str);

	//PartDesc
	builder.Append(txtPartDesc.Text);
	builder.Append(str);

	//TotalQty and QtyPer
	builder.Append(txtQty.Text);
	builder.Append(str);

	//TagFormat
	builder.Append("WIP");
	builder.Append(str);

Yep - so long as you build it in the right order - in you latest example, things look good so far.

Once you are done building, you can do something like this to test. It should display all of your parameters in order on different lines.

string myParams = builder.ToString();
string msg = myParams.Replace("~", Environment.NewLine);
MessageBox.Show(msg);

Yep, the display of my string looks perfect. But the form is still griping about me putting data into the wrong field. That’s what I don’t understand. For example, the latest error says "can’t store [the uom] in the VendorNum column. However, I have the UOM stored in the 5th array spot. And VendorNum is in the 12th array spot. I don’t understand what it’s doing.

image

private string getParametersForMtlTags()
{
    string str = "~";
    StringBuilder builder = new StringBuilder(string.Empty);

	//PartNum
	builder.Append(txtPartNum.Text);
    builder.Append(str);

	//PartDesc
	builder.Append(txtPartDesc.Text);
	builder.Append(str);

	//TotalQty and QtyPer
	builder.Append(txtQty.Text);
	builder.Append(str);

	//TagFormat
	builder.Append("WIP");
	builder.Append(str);

	//Revision
	builder.Append("_");
	builder.Append(str);

	//UOM
	builder.Append(txtUOM.Text);
	builder.Append(str);

	//JobNum
	builder.Append(txtJobNum.Text);
	builder.Append(str);

	//AssemblySeq
	builder.Append("0");
	builder.Append(str);

	//OprSeq
	builder.Append(txtLastOpSeqComp.Text);
	builder.Append(str);

	//PONum
	builder.Append("0");
	builder.Append(str);

	//POLine
	builder.Append("0");
	builder.Append(str);

	//PORel
	builder.Append("0");
	builder.Append(str);

	//VendorNum
	builder.Append("0");
	builder.Append(str);

	//PurPoint
	builder.Append("0");
	builder.Append(str);

	//NonConfTranID
	builder.Append("0");
	builder.Append(str);

	//ReasonCode
	builder.Append("0");
	builder.Append(str);

	//ReasonType
	builder.Append("0");
	builder.Append(str);

	//Comment
	builder.Append("0");
	builder.Append(str);

	//WhseCode
	builder.Append(txtWhse.Text);
	builder.Append(str);

	//BinNum
	builder.Append(txtBin.Text);
	builder.Append(str);

	string myParams = builder.ToString();
	string msg = myParams.Replace("~", Environment.NewLine);
	MessageBox.Show(msg);

    return builder.ToString();
}

You should confirm that the MtlForm does indeed think that “Erp.UI.EndActivityEntry” is the sender. You can do this in dev mode.

If it is not, then the default processing happens.

Val[0], Part
Val[1], Desc
Decimal.Parse(Val[2]), Qty
Val[3], Uom
Val[4], Format
Val[5], VnedorNum
Val[6], PONum
Val[7], POLine
Val[8], PORel
Val[9], WHCode
Val[10] BinNum

Also, if not, maybe you can set the WhoAmI manually??
((ILaunch)LaunchFormOpts.Sender).WhoAmI = “Erp.UI.EndActivityEntry”;

Yes! That’s it exactly. The MtlTags form didn’t know I wanted to act like I was calling it from the End Activity form. Thank you for that!
Next issue is that this line of code:

launchObject.WhoAmI = “Erp.UI.EndActivityEntry”;

…gives me this error:

‘Ice.Lib.Framework.LaunchFormOptions’ does not contain a definition for ‘WhoAmI’ and no extension method ‘WhoAmI’ accepting a first argument of type ‘Ice.Lib.Framework.LaunchFormOptions’ could be found (are you missing a using directive or an assembly reference?)

…not sure if the .WhoAmI property doesn’t exist or if I really need some type of custom assembly ref added.
Ideas?

1 Like

Try this:

(LaunchFormOpts.Sender as ILaunch).WhoAmI = “Erp.UI.EndActivityEntry”;

It liked that syntax, but now got a new error. :confused:

Property or indexer ‘Ice.Lib.Framework.ILaunch.WhoAmI’ cannot be assigned to – it is read only

Ok, let’s brute force this baby. No warranties :stuck_out_tongue:

//this will NOT be in a method
public class Hack:ILaunch
{
	public string WhoAmI
	{
		get {return “Erp.UI.EndActivityEntry”;}	
	}

	public object Session
	{
		get {return  "Nothing, dont return a damn thing";}	
	}
}


//in your method, BEFORE sending lfo to form
Hack hacky = new Hack();
LaunchFormOpts.Sender = hacky;

Here is a more <finger quotes> **professional** </finger quotes> version.

FormImpersonator hacky = new FormImpersonator("Erp.UI.EndActivityEntry",oTrans.Session);


public class FormImpersonator:ILaunch
{
	private	string _formname;
	private	object _session;

	public FormImpersonator(string form, object session)
	{
		_formname = form;
		_session = session;
	}

	public string WhoAmI
	{
		get {return _formname;}	
	}

	public object Session
	{
		get {return  _session;}	
	}
}

1 Like

Chris-
Neither way seems to be firing. No new errors… the MtlTags form thinks it’s still being called from UD39 instead of End Activity. Maybe I’m not placing the code in the right place? I put the “FormImpersonator hacky…” line right before my call to the MtlTag form. Then I tried to move the entire “public class FormImpersonator:ILaunch…” code snip above the “public class Script” statement and also after the “public class Script” (but before my actual method).
Apologies for some of my newbie-type questions in here. I’m learning C# on the fly. :slight_smile:
Any other ideas for me? :grimacing:
Thanks! -Sharla

(Correction)
I dont know how you are passing the lfo. Probably need to do something like:

//create our hack
Hack hacky = new Hack();
//create an LFO
var lfo = new LaunchFormOptions();
lfo.Sender = hacky; //set the sender

string currentVal = getParametersForMtlTags();
lfo.ValueIn = currentVal; //the actual data

ProcessCaller.LaunchForm(oTrans, “Erp.UIRpt.MtlTags”,lfo);  //pass the lfo
}

Chris-
Yes, that’s basically how I was calling the form and passing the params.
Here’s (the important parts of) my current code. It still thinks I’m calling it from UD39 form (which I am) instead of faking that it’s from End Activity. Do you see anything wrong below?
Thanks, Sharla

//using statements…

public class Hack:ILaunch
{
public string WhoAmI
{
get {return “Erp.UI.EndActivityEntry”;}
}

public object Session
{
	get {return  "Nothing, dont return a damn thing";}
}

}

public class Script
{
//other methods here…

private void btnPrintTag_Click(object sender, System.EventArgs args)
{
	Hack hacky = new Hack();
	LaunchFormOptions LaunchFormOpts = new LaunchFormOptions();
	LaunchFormOpts.Sender = hacky;
	string currentVal = getParametersForMtlTags();
	LaunchFormOpts.ValueIn = currentVal;
	ProcessCaller.LaunchForm(oTrans, "Erp.UIRpt.MtlTags", LaunchFormOpts);
}


private string getParametersForMtlTags()
{
	string str = "~";
	StringBuilder builder = new StringBuilder(string.Empty);
	builder.Append(txtPartNum.Text);
	builder.Append(str);
	//more string building in here.....
	return builder.ToString();
}

}

It still thinks I’m calling it from UD39 form (which I am)

Are you basing that from the dialog that shows the caller? If so, that wont ever change.

I tested the code above, works for me in 10.2