adding unit cost field in the production BOM line

Dear all,

I would like to ask you if there is a nother coding if I want to add unit cost field in production BOM line, the codings are as follows:

CASE Type OF
Type::Item:
BEGIN
Item.GET(“No.”);

“Unit Cost” := xxx.“Unit Cost”;

in the properties I also set fieldclass and calcformula. I just want to know of there is another method besides the above, yes indeed my coding work good, if I select an item from item list and then press OK, the line in the production BOM will consists of unit cost in the unit cost field.

before I set properties, it can’t work. I wonder whether one or two or more of this forum members have done what I’ve done too. I am not a developer but I understand well enough about developing techniques.

Rgds,

Johnson

.

I do not know much about production, but …

… fieldclass and calcformula (if defined for a field) will not allow you to store any value in that field anymore. Instead it will display the result of your calcformula.

So maybe you can specify what exactly you want to achieve and about what field you are talking when referring to fieldclass and calcformula.

By the way, your coding looks great when used in “No.” - OnValidate trigger of the table. I just do not see enough code to see what happens when you remove the item no. from the field. Do you get an error or are you checking upfront if the “No.” field is empty ?

That’s a good point from tb.

CASE Type OF
Type::Item:
BEGIN
IF Item.GET(“No.”) THEN BEGIN
\ your code
“Unit Cost” := Item"Unit Cost"
END ELSE BEGIN
“Unit Cost” := 0;
END;

Dear Thomas,

in your last paragraph, you said about "…, your coding… Actually that’s not my coding. it’s available in the production BOM line. I just want to create a field in the line table name unit cost, so I put my coding there. But I work goods after I set fieldclass to be one of flowfield or flowfilter and of course calcformula must be filled to make the field can capture unit cost from item card. and the “…” sign I wrote, it doesn’t mean there is no coding here, but because there are many codings, that’s why I wrote “…” sign. Tks for your comment. I thought my field can work without setting the properties of new field I create in the line table.

Rgds,

Johnson