web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

Multiple company in x++

(0) ShareShare
ReportReport
Posted on by 351

Hi all,

I have a custom form and table. 

I created transaction in my custom form.

below my code:

LETransactionSetup.TransactionFormat = strFmt('%1-%2',strUpr(curExt()), 'LETR');
LETransactionSetup.insert();

As i mentioned above code works good, but when i open another company its also USMF-LETR show.

Etc: If i go DAT company i want to DAT-LETR 

Note : properties save data per company set as a 'NO'

LETR is static.

Thanks 

I have the same question (0)
  • Suggested answer
    nmaenpaa Profile Picture
    101,166 Moderator on at

    Hi waytoD365,

    Basically you have stored some text in a field. And the system shows you the text that you saved. Correct?

    No matter which company you use to open the form, it will of course display what you stored in the table. If you stored "USMF-LETR" in the text field, then that's what will be displayed. If you would store "wayToD365" in that field, then the system would show "wayToD365". 

    If you want to have different text in different companies, then you need to produce part of the text dynamically (instead of saving one fixed text in the database), or create one record for each company, with the text that you want to see.

  • waytod365 Profile Picture
    351 on at

    Thanks for your replay sir,

    I already set as 'No' in save data per company, Now If I created record in USMF company then i will check another only i don't create another company any record only view if its :-  DAT-LETR.

    Would you mind to specify dynamically text?

  • Suggested answer
    nmaenpaa Profile Picture
    101,166 Moderator on at

    In this case you should not save the company id in your text field. You should only store 'LETR'.

    And when you read the record, the process who reads the record should apply "curExt()" in the beginning.

    For example:

    LETTransactionSetup.TransactionFormat = 'LETR';
    LETTransactionSetup.insert();
    info(strFmt('%1-%2', strUpr(curExt()), LETransactionSetup.TransactionFormat));

  • waytod365 Profile Picture
    351 on at

    Thanks for your answer sir,

    Sir I already set save data per company set 'No' if its yes it will come based on data Area id.

    Right now its show all company :- USMF-LETR just data sharing.

    I don't wanna change save data per company is there any other way ?

    As you mentioned the code same thing do like all company should be : USMF-LETR

  • nmaenpaa Profile Picture
    101,166 Moderator on at

    I'm sorry but I don't understand.

    Could you please try to describe the entire requirement as simply as you possibly can? Like you would be explaining to someone who doesn't know anything about what you're trying to achieve, what would be the required outcome, what's the business requirement etc. Because that's the situation we are in.

    Thanks!

  • waytod365 Profile Picture
    351 on at

    Okay, the thing is that if i insert the transaction format it should be show :- USMF-LETR not only a LETR i have a 11 static based on a transaction format.

    Now, If i inserted USMF company transaction number. in USMF it should be :- USMF-LETR,,,,,,

    If i go DAT company and i will check transaction format it should be ;- DAT-LETR.

    Not only DAT i will check all company it should be based on legal entity.

  • Suggested answer
    nmaenpaa Profile Picture
    101,166 Moderator on at

    So are you saying that you want to have as many records as there are legal entities?

    And that when you open the form in DAT company you should see only the record of DAT company?

    Because I still don't understand if you want to generate different data or display your existing data differently.

    Also, what exactly is the trigger for creating these transactions?

    Could you please share the full user process for this functionality? How is the data suppose to be created, how is it used etc. You should start from there, and also we should start from there in order to provide good help to you.

    UPDATE: (still knowing nothing about your functional requirement) - are you sure that you're not trying to reinvent the number sequence framework? Usually transactions get an id from number sequences, and you can define the format there.

  • waytod365 Profile Picture
    351 on at

    Good catch sir :) Yes its number sequence based on transaction. the issue is USMF its created USMF-TEES.

    when i check another its also show USMF-TEES in this case based on company i need to CurrentCompany-static(TEES, TSCR,,,, something)

  • Suggested answer
    ergun sahin Profile Picture
    8,826 Moderator on at

    There is only one record in the table. It's perfectly normal for the system to fetch what you've saved.

    You can write to the table without company information and show it with the Display method, and you can use this display method in the code.

  • waytod365 Profile Picture
    351 on at

    Thanks for your replay ergun sir, i followed your way of clicked method.

    below code:

       public void clicked()
            {
                
                NumberSequenceTable     numberSequenceTable;
                Counter                 counter;
               // MenuItemMessageAction menuItemMessageAction = new MenuItemMessageAction();
                void createNumSeqTable(NumberSequenceCode _numberSequence, name _description, NumberSequenceFormat _format)
                {
                    NumberSequenceScope     numberSeqScope;
                    NumberSequenceTable     numberSeq;
                    LETransactionNumSeq    	transactionNumSeq;
    
                    LETransactionSetup     setups = LETransactionSetup::find(_description);
    
                    select firstonly numberSeqScope
                        where numberSeqScope.DataArea == curExt();
                   
                    numberSeq.initValue();
                    numberSeq.NumberSequence = _numberSequence;
                    numberSeq.Txt = _description;
                    numberSeq.Continuous = NoYes::Yes;
                    numberSeq.Format = _format;
                    numberSeq.NumberSequenceScope = numberSeqScope.RecId;
                    numberSeq.AnnotatedFormat = NumberSeq::createAnnotatedFormatFromFormat(_format);
                    numberSeq.NextRec = 1;
                    numberSeq.Lowest = 1;
                    numberSeq.Highest = 999999;
                    if(!numberSeq.RecId)
                    {
                        numberSeq.doInsert();
                        if(setups.RecId)
                        {
                            select firstonly forupdate  transactionNumSeq
                            where transactionNumSeq.RefTransSetup == setups.RecId;
    
                            if(transactionSeqNum.RecId)
                            {
                                ttsbegin;
                                transactionNumSeq.TransNumSeq = numberSeq.RecId;
                                ttransactionNumSeq.doUpdate();
                                counter  ;
                                ttscommit;
                            }
                        }
                       
                    }
                }
                
                select count(RecId) from numberSequenceTable
                    where (numberSequenceTable.NumberSequence == strFmt('%1-%2',strUpr(curExt()), 'OATR')
                    || numberSequenceTable.NumberSequence == strFmt("%1-%2", strUpr(curExt()),"OCTR")
                    || numberSequenceTable.NumberSequence == strFmt("%1-%2", strUpr(curExt()),"LETR")
                    || numberSequenceTable.NumberSequence == strFmt("%1-%2", strUpr(curExt()),"ABTR")
                    || numberSequenceTable.NumberSequence == strFmt("%1-%2", strUpr(curExt()),"TETR")
                    || numberSequenceTable.NumberSequence == strFmt("%1-%2", strUpr(curExt()),"ODTR")
                    || numberSequenceTable.NumberSequence == strFmt("%1-%2", strUpr(curExt()),"OTTR")
                    || numberSequenceTable.NumberSequence == strFmt("%1-%2", strUpr(curExt()),"WATR")
                    || numberSequenceTable.NumberSequence == strFmt("%1-%2", strUpr(curExt()),"LOTR")
                    || numberSequenceTable.NumberSequence == strFmt("%1-%2", strUpr(curExt()),"ESTR")
                    || numberSequenceTable.NumberSequence == strFmt("%1-%2", strUpr(curExt()),"VATR")
                    || numberSequenceTable.NumberSequence == strFmt("%1-%2", strUpr(curExt()),"LRTR")
                    || numberSequenceTable.NumberSequence == strFmt("%1-%2", strUpr(curExt()),"BTTR"));
    
                    if(numberSequenceTable.RecId != 13)
                    {
                        if(box::yesNo('Are you sure want to generate the number sequence?', dialogButton::Yes, 'Confirmation') == dialogButton::Yes)
                        {
                            createNumSeqTable(strFmt("%1-%2", strUpr(curExt()),'OATR'), "Additions", 'OATR-######');
                            createNumSeqTable(strFmt("%1-%2", strUpr(curExt()),"OCTR"), "cost", 'OCTR-######');
                            createNumSeqTable(strFmt("%1-%2", strUpr(curExt()),"LETR"), 'Encashment', 'LETR-######');
                            createNumSeqTable(strFmt("%1-%2", strUpr(curExt()),"ABTR"), 'Absence', 'ABTR-######');
                            createNumSeqTable(strFmt("%1-%2", strUpr(curExt()),"TETR"), 'Ticket Encashment', 'TETR-######');
                            createNumSeqTable(strFmt("%1-%2", strUpr(curExt()),"ODTR"), 'Deductions', 'ODTR-######');
                            createNumSeqTable(strFmt("%1-%2", strUpr(curExt()),"OTTR"), 'Overtime', 'OTTR-######');
                            createNumSeqTable(strFmt("%1-%2", strUpr(curExt()),"WATR"), 'Warning', 'WATR-######');
                            createNumSeqTable(strFmt("%1-%2", strUpr(curExt()),"LOTR"), 'Loan', 'LOTR-######');
                            createNumSeqTable(strFmt("%1-%2", strUpr(curExt()),"ESTR"), 'EES', 'ESTR-######');
                            createNumSeqTable(strFmt("%1-%2", strUpr(curExt()),"VATR"), 'leave', 'VATR-######');
                            createNumSeqTable(strFmt("%1-%2", strUpr(curExt()),"LRTR"), 'Leave Return', 'LRTR-######');
                            createNumSeqTable(strFmt("%1-%2", strUpr(curExt()),"BTTR"), 'Business', 'BTTR-######');
                            
                            info(strFmt("Number sequence inserted : %1", counter));
                        }
                    }
                    else
                    {
                        throw Error("Numbser sequence already exists!");
                    }
               
                super();
               
                LETransactionSetup_ds.research(true);
               LETransactionNumSeq_ds.research(true);
     

    Above code works great but if created the USMF company then i will go to an another company read only i don't wanna create.

    Above code USMF - 13 created , DAT 13 created sometime USSI another 4 only created but table level 13 created form level 4 only show i don;t know what that issue that is why i moved only create the record USMF remaining company based on data area id   only i want to.

    O/p : I'm expecting output If its I take first only example (USMF-OATR) if its DAT (DAT-OATR) if its USSI (USSI-OATR)

    I hope its clear you and Mr.Nikolaos

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 659

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 465 Super User 2026 Season 1

#3
Syed Haris Shah Profile Picture

Syed Haris Shah 304 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans