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…
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"] = "";
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.
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.
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.
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.
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?
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.
@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.