Customization pull Part Revision Comment to PO Detail Comment

I’m trying to do a customization and need some help. In Part Maintenance under Revisions and then Comments, I would like to pull this information into my Purchase Order detail line Comments box. With examples I got from this forum, I tried to do the same, but being fairly new, I might be missing something.

With my section of code, I am looking at the PartNum and RevisionNum change in Purchase Order detail. However, I am getting an error. Can someone take a look at this code snippet and see what I need? Seems like the textbox txtCommentText.Value or “Text” doesn’t exists? The error I am getting is “The name ‘txtCommentText’ does not exist in the current context”. How would I reference an existing textbox and pre-populate it?

private void PODetail_AfterFieldChange(object sender, DataColumnChangeEventArgs args)
{
	// ** Argument Properties and Uses **
	// args.Row["FieldName"]
	// args.Column, args.ProposedValue, args.Row
	// Add Event Handler Code

	EpiDataView edvPartRev=(EpiDataView)oTrans.EpiDataViews["PODetail"];
	string PartNum = edvPartRev.dataView[edvPartRev.Row]["PartNum"].ToString();
	string RevisionNum = edvPartRev.dataView[edvPartRev.Row]["RevisionNum"].ToString();
	
	switch (args.Column.ColumnName)
	{
		case "PartNum":
		case "RevisionNum":			
				try
				{
			             Ice.Proxy.Lib.BOReaderImpl _bor = WCFServiceSupport.CreateImpl<Ice.Proxy.Lib.BOReaderImpl>((Ice.Core.Session)oTrans.Session, Epicor.ServiceModel.Channels.ImplBase<Ice.Contracts.BOReaderSvcContract>.UriPath);
			                DataSet ds2 = _bor.GetList("Erp:BO:PartRevSearch", "PartNum = '"+PartNum+"' AND RevisionNum = "+RevisionNum.ToString(), "");
				               
						 if(ds2 != null)
						{
						txtCommentText.Text = ds2.Tables[0].Rows[0]["RevDescription"];
						}
	
				}
				catch(Exception e)
				{
					MessageBox.Show("Error: "+e.Message);
				}
			break;
	}
}

Probably txtCommentText is not declared?

Make a messagebox to see what you are reading…do you have access to a debugger ?

I personnaly did this via use a Method directive during a save of a sales order to make such “transfer” of comments…On a condition that new record, or Part rev or partnum has changed I use code to then read from the Partrev table …
simple example: on the ChangePartNumMaster of sales order…

foreach(var dtl in ttOrderDtl)
{

	dtl["CertComment_c"] = "";

	foreach(var memo in Db.Memo.Where(x => x.Company == dtl.Company && ((x.RelatedToFile == "Part" && x.Key1 == dtl.PartNum) )))
	{

			
				switch(memo.CategoryID)
				{
					
					case "CERTFORM":
					 dtl["CertComment_c"] = memo.MemoText;
						
		
		
						break;
				}
					
		
	}

}

1 Like

Didn’t think about using Method Directives. Still very new to Epicor and learning what can and cannot be done. This is actually much simpler without having to do any customization within the program.

I tried your approach and need a bit of help.

  1. So I created a condition that if ttPODetail.RevisionNum field change row is not “”, then execute the code.

  2. Since what you provided is similar to what i wanted to do, I changed it to look at ttPODetail and changed the fields to match what’s in ttPODetail.

I am using Post-Processing since I want it to populate the “Comment” textbox after RevisionNum is populated. After enabling the method directive and saving it, I went to test my PO. Nothing is coming over and I know there’s Revision comments for this part. Am I not using the right directive type?

I noticed there are two method code.

Erp.PO.ChangeDetailRevisionNum
Erp.PO.ChangingDetailRevisionNum

What’s difference between the two?

Also I am only using the Script Editor within Epicor. Not even sure which debugger to use. Is there one you can recommend that works with Epicor?

Add this in initialize

EpiTextBox txtComment = (EpiTextBox)csm.GetNativeControlReference(“the guid of the desired control goes here”);

PS this was hard to type on a phone

Thank you Chris.

I really like the solution propose by Hogardy using BPM with Method Directive Maintenance. I’m running into a bit of an issue and doesn’t seem to be triggering it. What is the difference between the following:

Erp.PO.ChangeDetailRevisionNum
Erp.PO.ChangingDetailRevisionNum

I want to pull what’s in the PartRev table whenever the PO RevisionNum changes. So this is what I did.

  1. I created a post-processing (I tried pre-processing and no luck either).

  1. I create a condition that if “RevisionNum” change and not empty, then execute custom code.

  1. Pull comment from PartRev and updating the PO -->Lines–>comments. In this case I just want a pop up message to test to ensure it triggered it. However, I am not getting anything.

I found the pop-up below and seems to be working somewhat. It only pop-up if I change the “RevisionNum”. If it auto-populate the RevisionNum when I change part number, it doesn’t fire off the pop-up.

this.PublishInfoMessage(“Testing 123”, Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, “”, “”);

Just add the condition “OR” partnum change with your revisionnum change… it will fire on either change!
Pierre

I did tried that as well without luck. It works if my Method Directive code is set to Erp.PO.ChangeDetailPartNum. However, I want to trigger it when there’s a revision value.

This is what I have.

I see…well assuming it is valid to transfer comments on a part change OR or revision change…Maybe use the update method instead?
On new row call your custom code
On a changed row, if field partnum has changed or if revisionnum has changed
call your custom code.

That should work

I’ll probably have to play some more with this BPM. I like it that you don’t have to really customize the program, but just the BPM. However, I am on a time crunch and so will go back to what I initially started with the example from Chris_Conn and take a closer look at this at another time.

Chris,

I am able to get the comment and insert it into a textbox I created. However, I am still unable to insert it into the txtCommentText textbox in the Revision Tab in purchase line detail.

So I added this to initialize:

Then in my PO detail change, this is my code. Am I missing something? If I just put it in txtComment.Text, which is a textbox I created than it works fine. However, it will not work if I put it in the Epicor comment textbox txtCommentText.

private void PODetail_AfterFieldChange(object sender, DataColumnChangeEventArgs args)
{
	// ** Argument Properties and Uses **
	// args.Row["FieldName"]
	// args.Column, args.ProposedValue, args.Row
	// Add Event Handler Code

	//EpiDataView edvPart=(EpiDataView)oTrans.EpiDataViews["Part"];
	//string Company = edvPart.dataView[edvPart.Row]["Company"].ToString();
	//string Plant = edvPart.dataView[edvPart.Row]["Plant"].ToString();
	//EpiTextBox txtCommentText = new EpiTextBox();
	
	EpiDataView edvPartRev=(EpiDataView)oTrans.EpiDataViews["PODetail"];
	string PartNum = edvPartRev.dataView[edvPartRev.Row]["PartNum"].ToString();
	string RevisionNum = edvPartRev.dataView[edvPartRev.Row]["RevisionNum"].ToString();

	txtComment.Text = string.Empty;		

	switch (args.Column.ColumnName)
	{
		case "PartNum":
		case "RevisionNum":
			if (!string.IsNullOrEmpty(RevisionNum))
			{
				try
				{
			            Ice.Proxy.Lib.BOReaderImpl _bor = WCFServiceSupport.CreateImpl<Ice.Proxy.Lib.BOReaderImpl>((Ice.Core.Session)oTrans.Session, Epicor.ServiceModel.Channels.ImplBase<Ice.Contracts.BOReaderSvcContract>.UriPath);
			            DataSet ds2 = _bor.GetList("Erp:BO:PartRevSearch", "PartNum = '"+PartNum+"' AND RevisionNum = '"+RevisionNum+"'", "");
				               
						if(ds2 != null)
						{
						txtComment.Value = ds2.Tables[0].Rows[0]["RevDescription"];
						txtCommentText.Text = (txtComment.Value).ToString();
						}
	
				}
				catch(Exception e)
				{
					MessageBox.Show("Error: "+e.Message);
				}
			}
			break;
	}
}

For whatever control you are trying to add it to, are you copying that controls GUID?

You can also look at the EpiBinding field of the control (example, Part.Description) and do:
var edv = oTrans.Factory(“Part”);
edv.dataView[edv.Row][“Description”] = “Your value to set”;

This is what I want to add my comment to is the PODetail.CommentText. So I went and copied the EpiGuid from here. However, kept getting error that “The name ‘txtCommentText’ does not exist in the current context”.

Thanks again Chris. That other alternative worked. I would like to understand why it didn’t work with using the control and GUID.