JobNum data to MtlTags form

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

No, I’m basing my conclusion on the fact that I still get the error below (like it’s being called from PO Receipt with the expected parameters in a different sequence). So, it must still think I’m still calling it from UD39.
Are you able to pass a JobNum in your parameters and have it show on the Material Tag “report”? I see it’s blank in your screenshot.

image

Interesting - the calling dialog shows the proper form name now:
image

Note: I simply changed this line:
ProcessCaller.LaunchForm(hacky, “Erp.UIRpt.MtlTags”,lfo); //to pass hacky instead of oTrans

Also notice how my rev/bin/wh is skewed? Cuz you shouldnt have this:
image

Hi Chris.
When I changed the line:
ProcessCaller.LaunchForm(hacky, “Erp.UIRpt.MtlTags”,lfo); //to pass hacky instead of oTrans
…then I got the following 2 errors one right after the other:
image

image

Here’s my code around the call. Do you see anything else out of place?
Thanks, Sharla

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(hacky, "Erp.UIRpt.MtlTags", LaunchFormOpts);
	}

You need to be using the other one I made, as it returns a session (FornImpersonator).

When you create it, you’ll pass it the formname and oTrans

Got it! Thank you for sticking with me Chris! You’re awesome!!! :star_struck:
-Sharla

1 Like

Excellent - mark the appropriate post as the solution if you would please :smiley: