I am inserting sales header of Company A into sales header table of company B so I want to insert it with current document no series of company B's document not with document no of company A.
I suppose you are transfer the Documents using COMPANYCHANGE function. In this case I will recommend to check the No. Series for that document no as Manual so you will be able to insert and document no between other data.
If you work in CompanyA and do RecA.CHANGECOMPANY('CompanyB') and then run Rec.VALIDATE(SomeField, 'SomeValue'), or Rec.INSERT(TRUE) then all the code executed inside trigger code, all the variables the trigger code will use, all of this will execute in the context of CompanyA, NOT in CompanyB.
If you insert a record from Company A into Company B and you want to use serial number from company B you must code everying manually, without using any triggers, any standard codeunits/functions calls, and making sure to call CHANGECOMPANY on every variable table you will be using
Answers
Regards
If you work in CompanyA and do RecA.CHANGECOMPANY('CompanyB') and then run Rec.VALIDATE(SomeField, 'SomeValue'), or Rec.INSERT(TRUE) then all the code executed inside trigger code, all the variables the trigger code will use, all of this will execute in the context of CompanyA, NOT in CompanyB.
If you insert a record from Company A into Company B and you want to use serial number from company B you must code everying manually, without using any triggers, any standard codeunits/functions calls, and making sure to call CHANGECOMPANY on every variable table you will be using
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
I also surgested using WebService, and keeping everything separate even if in the same database.