Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Suggested answer

Default Dimension update error

(0) ShareShare
ReportReport
Posted on by 6
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! 
  • Default Dimension update error
    Thank you! I'm new to business central. 
     
    I updated the modify logic as below, and as show in the postman output, the system picks up the values for the 3 primary keys with an error messaging saying the DD does not exist. However, when i go to the DD table to find the record, I see the record that i want to modify there. I'm not sure why it says the DD does not exist when it's there. 
     
     
     
    local procedure ModifyDefaultDimension(JobNo: Code[20]; DimCode: Code[20]; DimValue: Code[20])
        var
            DefaultDimension: Record "Default Dimension";
        begin
            if DefaultDimension.Get(Database::Job, JobNo, DimCode) then begin
                DefaultDimension.Validate("Dimension Value Code", DimValue);
                DefaultDimension.Modify(true);
            end;
        end;
    -----------------------------------------------------------------------postman output-------------------------------------------------------------------------------------------------------------------------------
     
    {
        "error": {
            "code": "Internal_RecordNotFound",
            "message": "The Default Dimension does not exist. Identification fields and values: Table ID='167',No.='FINALTEST12',Dimension Code='SALESPERSON'  CorrelationId:  e1db6f71-9183-4556-91ad-7d9407ad4d72."
        }
    }
     
  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 74,115 Super User 2024 Season 2 on at
    Default Dimension update error
    Hi, a very simple question. For Job, you used GetBySystemId to get the record, but for Default Dimension, you just used Modify, and you haven't Get or Find it yet. The system doesn't know which record to modify.
     
    Hope this can give you some hints.
    Thanks
    ZHU

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,391 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,445 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans