Hi all,
I'm working on a requirement to create and update records in the jobs and default dimension tables through an API page. I've created the api page, and tested out the insert (POST) method through postman and it successfully inserts the record into jobs table (Job no, description) and default dimension table (sales person) dimension.
However, when I run the PATCH method through postman to update the job no I created above, the jobs table updates fine. But I'm facing an issue with the default dimension table. Instead of updating the records, it deletes the sales person dimension from the default dimension table for that job no.
Below is the code. Could someone please advise what i'm missing here.
trigger OnModifyRecord(): Boolean
var
Job: Record Job;
begin
JobsSetup.Get();
Job.GetBySystemId(Rec.SystemId);
if Rec./No./ = Job./No./ then
Rec.Modify(true);
ModifyDefaultDimension(Rec./No./, 'salesperson', SalesPerson);
end;
local procedure ModifyDefaultDimension(JobNo: Code[20]; DimCode: Code[20]; DimValue: Code[20])
var
DefaultDimension: Record /Default Dimension/;
begin
DefaultDimension.Validate(/Table ID/, Database::Job);
DefaultDimension.Validate(/No./, JobNo);
DefaultDimension.Validate(/Dimension Code/, DimCode);
DefaultDimension.Validate(/Dimension Value Code/, DimValue);
DefaultDimension.Modify(true);
end;
Thank you!