Skip to main content

Notifications

Announcements

No record found.

Business Central forum
Suggested answer

Flowing few lines of General Journals lines from one company to another company

Posted on by 10
Hi All,
 
I created a custom field named TransferCompany in the General Journal Line page. With this field, I am transferring a few lines from the current company to another company. All my lines are going through perfectly, but the only problem I am facing is sending the dimension data from the current company to another company. Is there any way to send the dimensions using ChangeCompany? If possible, I would appreciate any help. Thanks in advance for your advice!
 
Thanks & Regards,
Sarath.. 
Categories:
  • gdrenteria Profile Picture
    gdrenteria 9,472 Most Valuable Professional on at
    Flowing few lines of General Journals lines from one company to another company
    Hi
    Is it possible that this codeunit on dimension management in intercompany transactions can help you?Or give you some ideas.
    Best
    GR
  • Sarath Profile Picture
    Sarath 10 on at
    Flowing few lines of General Journals lines from one company to another company
    Hello Yong,
     
    The Function DimensionManagment.GetDimensionID(TempDimensionsetEntry) is running on the current company and it is checking current company dimensionsetid on the IC Company and if it finds it is showing those dimensions, else if it did not find anything it is inserting my dimensions, other than that method can we use any other approaches for finding the dimension set id in the IC company.....
     
     
    Thanks & Regards,
    Sarath.
  • Suggested answer
    Yi Yong Profile Picture
    Yi Yong 771 Super User 2024 Season 2 on at
    Flowing few lines of General Journals lines from one company to another company
    Hello Sarath,
     
     
    I believe you are referring to this line of code in the above statement.
     
    Then I think this part might not be right.
    Yes, you ran ChangeCompany on the record NewDimensionsetEntry.
    But I think the DimensionManagement.GetDimensionSetID(TempDimensionSetEntry) function is called in the current company, not in the IC Company.
     
    You might want to double-check and run in debug mode.
     
  • Sarath Profile Picture
    Sarath 10 on at
    Flowing few lines of General Journals lines from one company to another company
    Hello Yong,
     
    Currently, my code does not generate any errors; however, its functionality involves selecting dimensions within the current company. It retrieves a dimension set ID and searches for this Dimension Set ID is  in the IC company. If records associated with the dimension set ID are found, the corresponding dimension values it is taking in the  IC company. Conversely, if no records are found, the code creates the dimensions selected in my current company  to my IC Company, there are any alternative methods available for transferring dimensions beyond this approach.
     
    Thanks Yong, Gdrenteria, Yun Zhu, Valentin for your advices...
     
    Thanks & Regards
    Sarath.
  • Suggested answer
    Yi Yong Profile Picture
    Yi Yong 771 Super User 2024 Season 2 on at
    Flowing few lines of General Journals lines from one company to another company
    Hello Sarath,
     
    Could you provide us with the error message and tell us which line is causing the error?
     
    Instead of generating Dimension Set ID on the IC company, can you just insert the TempDimensionSetEntry to the journal individually?
     
    I haven't tried this but I doubt the codeunit is calling from the IC Company.
    You passed the IC Company TempDimensionSetEntry while the functions inside this codeunit are running and getting from the current company data.
  • gdrenteria Profile Picture
    gdrenteria 9,472 Most Valuable Professional on at
    Flowing few lines of General Journals lines from one company to another company
  • Sarath Profile Picture
    Sarath 10 on at
    Flowing few lines of General Journals lines from one company to another company
    Hi All,
     
    As Yong said, I am using a Temporary table to save the dimensions of my current company and after that i am trying to insert them in the new company but it is not working it is showing already existed dimensions in the new company, I am attaching my code for it if anything is wrong give me advices to correct, advance thanks for your replies...
     
                NewDimensionSetID := 0;
                TempDimensionSetEntry.DeleteAll();
                DimensionSetEntry.Reset();
                DimensionSetEntry.SetRange("Dimension Set ID", GenLine."Dimension Set ID");
                TempDimensionSetEntry.ChangeCompany("IC Company Name");
                if DimensionSetEntry.FindSet() then
                    repeat
                        TempDimensionSetEntry.Init();
                        TempDimensionSetEntry.Validate("Dimension Code", DimensionSetEntry."Dimension Code");
                        TempDimensionSetEntry.Validate("Dimension Value Code", DimensionSetEntry."Dimension Value Code");
                        TempDimensionSetEntry.Insert();
                    until DimensionSetEntry.Next() = 0;

                NewDimensionsetEntry.Reset();
                NewDimensionsetEntry.ChangeCompany("IC Company Name");
                NewDimensionSetID := DimensionManagement.GetDimensionSetID(TempDimensionSetEntry);
                NewDimensionsetEntry.SetRange("Dimension Set ID", NewDimensionSetID);
                if not NewDimensionsetEntry.FindFirst() then begin
                    if TempDimensionSetEntry.FindSet() then
                        repeat
                            NewDimensionsetEntry.Init();
                            NewDimensionsetEntry.Validate("Dimension Set ID", NewDimensionSetID);
                            NewDimensionsetEntry.Validate("Dimension Code", TempDimensionSetEntry."Dimension Code");
                            NewDimensionsetEntry.Validate("Dimension Value Code", TempDimensionSetEntry."Dimension Value Code");
                            NewDimensionsetEntry.Insert();
                        until TempDimensionSetEntry.Next() = 0;
                end;
                if NewDimensionSetID <> 0 then
                    GenJnlLine.Validate("Dimension Set ID", NewDimensionSetID);
                TempDimensionSetEntry.DeleteAll();
     
    Thanks & Regards,
    Sarath
  • Suggested answer
    Yi Yong Profile Picture
    Yi Yong 771 Super User 2024 Season 2 on at
    Flowing few lines of General Journals lines from one company to another company
    Hello Sarath,
     
    You can't send the 'Dimension Set ID' field to another company because the same combination will likely be of a different Set ID.
     
    You need to look into the Dimension Set ID from the current company and store their dimensions and values individually.
    Then, transfer these Dimensions and values individually to the next company.
     
    As @YUN ZHU mentioned, you can use the standard codeunit 408 DimensionManagement to look for the dimensions and values.
     
    You can look at the standard General Ledger Entries page, Dimension action button.
    In our GLE, the system only records the Global 1 and 2 and the rest of the dimensions are contained in the Dimension Set ID.
    This action button will look for the Dimensions and Values from the Ledger Entry Dimension Set ID.
     
     
  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 69,639 Super User 2024 Season 2 on at
    Flowing few lines of General Journals lines from one company to another company
    Hi, the handling of Dimension is rather special in Business Central, you can refer to the standard methods in the following Codeunit.
    codeunit 408 DimensionManagement
     
    Hope this helps.
    Thanks.
    ZHU
     
  • Suggested answer
    Valentin Castravet Profile Picture
    Valentin Castravet 22,181 Super User 2024 Season 2 on at
    Flowing few lines of General Journals lines from one company to another company
    Have you looked into using the intercompany module which does this out of the box? Is there a reason you're creating your own functionality when the system already does it out of the box?
     

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

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,532 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,501 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans