Trigger something into another Company

ajayjain
Member Posts: 119
How can I run a codeunit for another company without using job queue
I want to approve a Purchase Invoice in another company.
so we have 5 companies
approver will have to go into every company and approve it
I can display all approvals from all company into one list but when he approves it errors, even I use changecompany function.
Any advise?
Thanks
I want to approve a Purchase Invoice in another company.
so we have 5 companies
approver will have to go into every company and approve it
I can display all approvals from all company into one list but when he approves it errors, even I use changecompany function.
Any advise?
Thanks
Ajay Jain
UK
UK
0
Answers
-
Try using STARTSESSION.
[OK :=] STARTSESSION(VAR SessionID, CodeunitID [, CompanyName] [,Record])
0 -
Thank youAjay Jain
UK0 -
Or if you need data from another company you can use ChangeCompany() method.
For more details:https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/record/record-changecompany-method0 -
Take note that CHANGECOMPANY should not be used to write data to the other company. Trigger code is run in the context of the current company i.e. rec variables in such triggers do not inherit the foreign company.
Chang log management has special code to write to the foreign company's change log entry, but at least part of the setup is taken from the current one.
I have never analized how events behave under these circumstances.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions