Parameters in the cloud

MortenSteengaard
Member Posts: 144
Hi experts,
In an old NAV, I have a solution where some code is added in the middle of codeunit 80, procedure PostItemJnlLine. The code must only be run sometimes. It is controllede by an extra parameter on the procedure. So depending on where PostItemJnlLine is called from, the extra parameter is set to true or false.
How do I do that in Business Central cloud?
I can add my code to one of the "On..." procedures, but is there a way to send an extra parameter to a standard procedure like PostItemJnlLine or can I set a global variable in codeunit 80 somehow?
Is it possible for my code in the "On..." procedure to communicate with one of the calling programs higher up in the call stack?
My situation is like this:
Procedure A:
PostItemJnlLine(..., true);
Procedure B:
PostItemJnlLine(..., false);
PostItemJnlLine:
...
if parameter then
runExtraCode...
In an old NAV, I have a solution where some code is added in the middle of codeunit 80, procedure PostItemJnlLine. The code must only be run sometimes. It is controllede by an extra parameter on the procedure. So depending on where PostItemJnlLine is called from, the extra parameter is set to true or false.
How do I do that in Business Central cloud?
I can add my code to one of the "On..." procedures, but is there a way to send an extra parameter to a standard procedure like PostItemJnlLine or can I set a global variable in codeunit 80 somehow?
Is it possible for my code in the "On..." procedure to communicate with one of the calling programs higher up in the call stack?
My situation is like this:
Procedure A:
PostItemJnlLine(..., true);
Procedure B:
PostItemJnlLine(..., false);
PostItemJnlLine:
...
if parameter then
runExtraCode...
0
Best Answer
-
Not knowing what you needs to check on and so on I can add a general way of doing it:
In Procecure A and B
Add a variable to a singleinstance codeunit so you can know where the posting is called from.
Then add a procedure that subscriper on a event publisher ind the PostItemJnlLine Procedure.
You can in your subscriper codeunit get the value set by the singleinstance codeunit and do your code there.
Just remember to add some code that cleans up the singleinstance codeunit variable :-)For help, do not use PM, use forum instead, perhaps other people have the same question, or better answers.0
Answers
-
Not knowing what you needs to check on and so on I can add a general way of doing it:
In Procecure A and B
Add a variable to a singleinstance codeunit so you can know where the posting is called from.
Then add a procedure that subscriper on a event publisher ind the PostItemJnlLine Procedure.
You can in your subscriper codeunit get the value set by the singleinstance codeunit and do your code there.
Just remember to add some code that cleans up the singleinstance codeunit variable :-)For help, do not use PM, use forum instead, perhaps other people have the same question, or better answers.0 -
Hi SanderDk,
Thank you very much. That solved my problem!
Best regards,
Morten0
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