BPM to Copy UD field Value from Part to QuoteDtl

,

I worked with one of my programmers and we developed some code but we are still running into an error. See screen shot below:

3 of the 4 UD fields say they do not contain a definition but I set them up all the same way in their respective tables. Should I re do them?

i’d write it like this

foreach(var i in ttInvcDtl.Where(id => id.Updated()))
{
var myOrder = Db.OrderDtl.Where(od => od.Company == i.Company && 
od.OrderNum == i.OrderNum &&
od.OrderLine == i.OrderLine ).FirstOrDefault();
if(myOrder != null)
{
   i.SKTotalQty_c = myOrder.TotalQtyUnit_c;
   i.AvgPerPer_c = myOrder.AvgPrice_c;
}
}

2 notes - first this will only work if this is a PRE process
Next, are you sure that The custom fields you are referencing are on those tables you are referencing?

After creating the new UD fields, did you run Data Model Regen & Recycle IIS App Pool?

Yes, we just did it again because I updated the labels for each of those field.

you declare a variable as ttInvcDtl_xRow… but then call ttInvcDtl

check out this snippet. for the UD field on the right side.

foreach (var part in (from ttPart_Row in ttPart select ttPart_Row))
{
	foreach(var PartWhse in Db.PartWhse.Where(pw=> pw.PartNum == part.PartNum && pw.WarehouseCode == "Stock" && pw.Company == part.Company))
	{		
		if (part.TrackSerialNum == true)
		{	
			PartWhse.SystemAbc = "S";
		}
		else
		{
			PartWhse.SystemAbc = part.UDField<System.String>("PurABC_c");
		}
		PartWhse.ManualABC = true;
	}
}

others are faster than me sorry for the extra post you are close just make sure the variables are what they should be and then using UD fields are sometimes a bit tricky.

Can you explain what you mean in by “declare a variable as ttInvcDtl_xRow but then call ttInvcDtl”

I also rewrote the code as suggested above and it still gave me the same error. I think I am going to read the UD fields (as different names) and try it again. Maybe the field are just corrupted?

the two lines

ttInvDtl.SKTotalQty_c …
ttInvDtl.AvgPerPer_c …

where is ttInvcDtl declared? do you mean to have ttInvcDtl_xRow there??

Did you try my code?

I do not think I have it declared but it still doesn’t explain why I am getting the error on 3 of the 4 UD fields…

@Chris_Conn, I did and it gave me the same error. Is it possible the fields are just corrupted?

this sound like a data model regen. Did you stop the app pool when you did that?

My colleague does the Regen. I went ahead and redid the fields and he will do the sync in the morning. I will try from there.

Look in the Extended UD Tab;e maintenance screen for those tables. First, it should show the data and table are sync’d

While you are there check the field names - just asking because PricePerPer sounds weird lol

@Chris_Conn, we verified that everything is syncing properly. I recreated the 3 fields that were erroring out and did a regen and still getting the same error but only for the InvcDtl fields. Here is the code:

Erp.Tables.OrderDtl OrderDtl;

var ttInvcDtl_results = (from ttInvcDtl_Row in ttInvcDtl
where (ttInvcDtl_Row.RowMod == “U”) select ttInvcDtl_Row);
foreach (var ttInvcDtl_xRow in ttInvcDtl_results)
{
var Company = ttInvcDtl_xRow.Company;
var OrderNum = ttInvcDtl_xRow.OrderNum;
var OrderLine = ttInvcDtl_xRow.OrderLine;
var OrderDtl_row = (from ttOrderDtl_Row in Db.OrderDtl
where (ttOrderDtl_Row.Company == Company) select ttOrderDtl_Row).FirstOrDefault();
//Issue finding custom fields?
ttInvcDtl.RCTrkQty_c = OrderDtl_row.RCTrkTtlQty_c;
ttInvcDtl.AveragePerRCTrk_c = OrderDtl_row.AvgPrice_c;

}

Errors:

image

I keep going back to declaring ttInvcDtl. I am new to C# and getting help from our programmer so I need some more guidance.

Thanks,

Charles

You can’t reference extended UD fields on the ttTables that way.

@josecgomez, then how would you go about doing it?

See @knash example above. It is like this:

theRowHere.UDField<TheTypeHere>("FieldNameHere"); 
//using my code above as a reference
i.UDField<decimal>("SKTotalQty_c") = myOrder.UDField<decimal>("TotalQtyUnit_c");
1 Like

I think I got it… this would before the statement:

ttInvcDtl.RCTrkQty_c = OrderDtl_row.RCTrkTtlQty_c;
ttInvcDtl.AveragePerRCTrk_c = OrderDtl_row.AvgPrice_c

Right?

Here is where I am now:

The syntax through ttInvcDtl_xRow.UDField(“RCTrkQTY_c”);
is ok, but it errors on the next line.