Is It possible to mapp item attribute values after creating new item attributes like normal mapping
Is It possible to mapp item attribute values after creating new item attributes like normal mapping
Hi what are this SMBitemstaging and SMBitemimportsetup?
Are these Customized Table? If they are, then
Make sure that the SMBItemStaging table has data that matches the "Reference" code passed to the SetItemAttributeValue procedure and Verify that the SMBImportSetup table has the correct setup for the "Diameter mm" attribute.
Thank you for your support,I copied the same procedure and run but now it doesnot show any changes,Do you I need to make any changes in your code
Hi Can you Try The Below Written Code
local procedure SetItemAttributeValue(Reference: code[20]; AttributeName: Text; AttributeValue: Variant)
var
ItemAttribute: Record "Item Attribute";
ItemAttributeValueMap: Record "Item Attribute Value Mapping";
ItemAttributeValue: Record "Item Attribute Value";
SMBImportSetup: Record "SMB Import Setup";
Item: Record Item;
SMBItemStaging: Record "SMB Item Staging";
begin
if SMBItemStaging.Get(Reference) then begin
if SMBImportSetup.Get() then begin
ItemAttribute.SetRange("Name", AttributeName);
if ItemAttribute.FindFirst() then begin
ItemAttributeValue.SetRange("Attribute Name", AttributeName);
if AttributeValue.IsInteger then
ItemAttributeValue.SetRange("Numeric Value", AttributeValue);
if AttributeValue.IsDecimal then
ItemAttributeValue.SetRange("Numeric Value", AttributeValue);
if AttributeValue.IsText then
ItemAttributeValue.SetRange("Value", AttributeValue);
if not ItemAttributeValue.FindFirst() then begin
ItemAttributeValue.Init();
ItemAttributeValue."Attribute ID" := ItemAttribute.ID;
ItemAttributeValue."Attribute Name" := ItemAttribute.Name;
if AttributeValue.IsInteger then
ItemAttributeValue."Numeric Value" := AttributeValue;
if AttributeValue.IsDecimal then
ItemAttributeValue."Numeric Value" := AttributeValue;
if AttributeValue.IsText then
ItemAttributeValue.Value := AttributeValue;
ItemAttributeValue.Insert(true);
end;
ItemAttributeValueMap.Init();
ItemAttributeValueMap."Table ID" := 27;
ItemAttributeValueMap."No." := SMBItemStaging.Reference;
ItemAttributeValueMap."Item Attribute ID" := ItemAttribute.ID;
ItemAttributeValueMap."Item Attribute Value ID" := ItemAttributeValue.ID;
ItemAttributeValueMap.Insert(true);
end;
end;
end;
end;
Now The item attributes caption is coming while creating item I dont understand why the value is coming not , Any idea where I went wrong.
local procedure SetItemAttibuteValue(Reference: code[20]) var ItemAttributeL: Record "Item Attribute"; ItemAttributeValueMap: Record "Item Attribute Value Mapping"; ItemAttributeValue: Record "Item Attribute Value"; SMBImportSetupL: Record "SMB Import Setup"; ItemL: Record Item; SMBItemStagingL: Record "SMB Item Staging"; DiameterIntegerL: Integer; begin IF SMBItemStagingL.Get(Reference) THEN BEGIN if SMBImportSetupL.Get() then begin //Diameter: SMBImportSetupL.TestField("Diameter mm"); Evaluate(DiameterIntegerL, SMBItemStagingL."Diameter mm"); SetAttribute(SMBItemStagingL.Reference, SMBImportSetupL."Diameter mm", DiameterIntegerL, 0, ''); end end; end; local procedure SetAttribute(ItemNoV: Code[20]; AttributeIDV: integer; IntegerValueV: Integer; DecimalValueV: Decimal; TextValueV: Text) var ItemAttributeL: Record "Item Attribute"; ItemAttributeValueMap: Record "Item Attribute Value Mapping"; ItemAttributeValue: Record "Item Attribute Value"; SMBImportSetupL: Record "SMB Import Setup"; ItemL: Record Item; SMBItemStagingL: Record "SMB Item Staging"; DiameterIntegerL: Integer; StrapIntegerL: Integer; begin if SMBImportSetupL.Get() then begin ItemAttributeL.Get(SMBImportSetupL."Diameter mm"); ItemAttributeValue.SetRange("Attribute ID", AttributeIDV); if IntegerValueV <> 0 then ItemAttributeValue.SetRange("Numeric Value", DiameterIntegerL); if DecimalValueV <> 0 then ItemAttributeValue.SetRange("Numeric Value", DecimalValueV); if TextValueV <> '' then ItemAttributeValue.SetRange(Value, TextValueV); if not ItemAttributeValue.FindFirst() then begin ItemAttributeValue.Init(); ItemAttributeValue."Attribute ID" := ItemAttributeL.ID; ItemAttributeValue."Attribute Name" := ItemAttributeL.Name; if IntegerValueV <> 0 then ItemAttributeValue."Numeric Value" := DiameterIntegerL; if DecimalValueV <> 0 then ItemAttributeValue."Numeric Value" := DiameterIntegerL; if TextValueV <> '' then ItemAttributeValue.Value := TextValueV; ItemAttributeValue.Insert(true); end; ItemAttributeValueMap.Init(); ItemAttributeValueMap."Table ID" := 27; ItemAttributeValueMap."No." := ItemNoV; ItemAttributeValueMap."Item Attribute ID" := ItemAttributeL.ID; ItemAttributeValueMap."Item Attribute Value ID" := ItemAttributeValue.ID; ItemAttributeValueMap.Insert(true); end; end;
Hi, You need to pay attention to the following table. Item and Item Attribute are related through this table.
Hope this helps.
Thanks.
ZHU
Thanks for the reply, but here it shows only the functional part, but how we can map the item attribute for multiple records how to manually add them
ITEM NO | Diameter | length | width | height |
101 | ABC | 1 | 3 | 2 |
102 | ACB | 2 | 2 | 3 |
103 | BAC | 3 | 1 | 1 |
If I create these item through a function how can insert attribute and mapp them
YUN ZHU
448
Super User 2025 Season 1
Sagar Dangar, MCP
358
Mansi Soni
327