BPM to Copy UD field Value from Part to QuoteDtl

,

Happy Friday…

I think this should be relatively easy, but I’m having a Friday afternoon brainfart and think it’s time to go home.

I have a UD field on the Part table (Part.SaleLeadTime_c) and I want it to populate a field on the QuoteDtl table (QuoteDtl.LeadTime) when Part is added or changed on the Quote line.

I know the Method is Quote.ChangePartNumMaster, but no matter what I try it isn’t working…

Any pointers would be great. Thanks!

I did something similar, but wanted to populate 2 fields from Quote to Sales:

Erp.Tables.Part Part;

{
foreach (var ttQuoteDtl_xRow in (from ttQuoteDtl_Row in ttQuoteDtl
where (ttQuoteDtl_Row.Company == Session.CompanyID &&
(ttQuoteDtl_Row.RowMod == “A” || ttQuoteDtl_Row.RowMod == “U”))
select ttQuoteDtl_Row))
{
if (ttQuoteDtl_xRow != null)
{
/* For each line on the Quote - retrieve UD Fields from Part table*/
Part = (from Part_Row in Db.Part
where Part_Row.Company == ttQuoteDtl_xRow.Company && Part_Row.PartNum == partNum
select Part_Row).FirstOrDefault();
{
if (Part != null)
{
ttQuoteDtl_xRow[“ConfigComment1_c”] = Convert.ToString(Part[“ConfigComment1_c”]);
ttQuoteDtl_xRow[“ConfigComment2_c”] = Convert.ToString(Part[“ConfigComment2_c”]);

  		}
  		else    /* Part not found - initialize fields */
  		{
  			ttQuoteDtl_xRow["ConfigComment1_c"] = "";
  			ttQuoteDtl_xRow["ConfigComment2_c"] = "";
  		}
  	} 
  }	

Yours shouldn’t be too much different.

Yes, as posted in the example,

ttQuoteDtl_xRow[“ConfigComment1_c”] = “”;

works, but

ttQuoteDtl_xRow.ConfigComment1_c = “”;

doesn’t. For me, anyway.

Joe

Thanks, @Jonathan_Lang & @jdtrent, for your help.

I’m just getting back to this today, and I’m still failing. Guess I can’t blame Friday Friday noon after all. I think I now know why it’s not working, but I’m not sure how to fix it.

Also, I’m not trying to set the UD field; I’m trying to set the QuoteDtl.Leadtime field to the value in the UD field.

Here’s what I have;

  • Pre-Processing Method Direct on Epr.Quote.ChangePartNumMaster
  • Execute Custom Code
var QDtlRow = ( from ttQuoteDtl_row in ttQuoteDtl 
			   where (ttQuoteDtl_row.RowMod == "A" || ttQuoteDtl_row.RowMod == "U") 
			   select ttQuoteDtl_row).FirstOrDefault();
Erp.Tables.Part Part;

if (QDtlRow != null)
{
	PublishInfoMessage("QDtlRow != null & PartNum=" + QDtlRow.PartNum, Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "QDtlRow != null", "Update");

	Part = (from Part_Row in Db.Part
		    where (Part_Row.Company == QDtlRow.Company && Part_Row.PartNum == QDtlRow.PartNum)
		    select Part_Row).FirstOrDefault();
	
	if (Part != null)
	{
		PublishInfoMessage("Part != null", Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "Part != null", "Update");
		
		QDtlRow.LeadTime = Part.SaleLeadTime_c.ToString();
	}
}

I get the first message box; however the QDtlRow.PartNum is blank, which is why it’s not working.

1 Like

Dumb question here, but are you possibly switching from a part, not in the part master, to one that is? The code worked fine when I tried it, except for that scenario.

@danbedwards, at this point there are no dumb questions. However, yes this is a part in the part master, and I set a Sales Price of 999.00, which does copy over.

When you say;

The code worked fine when I tried it

Are you talking about the code I just posted?

Yes, I thought that was still giving you problems.

Yes, it is… so why is it working for you… :expressionless:

I guess when I say working I can get a value back and populate the field. The part number it does use is the original and not the new part number. I assume you want to change to a new part number and look up the Part.SaleLeadTime_c on the new part record, correct? I would use ChangePartNum (not Master) and this will work for you.

Try moving your code to post processing

Perhaps a moot point considering the meat of the discussion but regarding using:
ttQuoteDtl_xRow[“ConfigComment1_c”] = “”;
vs
ttQuoteDtl_xRow.ConfigComment1_c = “”;

Instead of using foreach (var ttQuoteDtl_xRow in (from ttQuoteDtl_Row in ttQuoteDtl -

Add Using Erp.Tablesets and the change the var to QuoteDtlRow.

Will it work? I don’t know! Presumably is would force the strong typed class and allow you to use the fields.

Thank you @danbedwards! I didn’t notice that there was a ChangePartNum & a ChangePartNumMaster. Putting the above code on the non-master BO solved the issue!

I knew I was missing something simple, I even messed around with an external dll, so I could run remote debugging to see if I could fix it, but had the same thing happen using the ChangePartNumMaster.

Thanks again!

I have a similar issue. I have two UD fields in OrderDtl and I want them to populate two UD fields in InvcDtl which are identical. I thought I could use a BPM without code, but I am thinking I will need it after reading this post. Any pointers?

What is the point of storing the same data in two locations? Can you not just join the tables to get to the fields?

Not that two fields is a big deal, just could see this method get out of control in the long run.

Because it may not always be the same I would guess. If you update your master file you don’t want to retroactively change all of your transaction records at the same time.

1 Like

good point.

I think a BPM should work though, when field changes update other ud field.

@knash, Mike is correct. It changes all the time. So I need it to copy whatever is in the field directly over. I have run a BPM several times (no code) and it will not copy the data from the field in OrderDtl to InvcDtl.

what does it look like.

I would guess an conditional widget.
Then a GetById widget
Then a set widget
Then an update widget

That isn’t working?

I’ve had different versions:
Condition Widget
Update Table by Query

I do not see GetById Widget.

Here is the screen shot of the latest one I’ve tried:

You will need to get the record you want to update, by using the Invoke BO Method widget

Fill/Set record by using a setter widget

Then Update it using the Invoke BO Method widget.