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;