Parameters in the cloud

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...

Best Answer

  • SanderDkSanderDk Member Posts: 502
    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.

Answers

  • SanderDkSanderDk Member Posts: 502
    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.
  • MortenSteengaardMortenSteengaard Member Posts: 134
    Hi SanderDk,

    Thank you very much. That solved my problem!

    Best regards,

    Morten
Sign In or Register to comment.