Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Business Central forum

How to Define return values in Business Central Subscriber events

(0) ShareShare
ReportReport
Posted on by 25

 Hello all.,

    Can we define a return Value in event function ,if we can not return a value is there any alternative Solution for this Problem.

Thanks in Advance.

Categories:
  • Suggested answer
    Avinash B Profile Picture
    1,455 on at
    RE: How to Define return values in Business Central Subscriber events

    Hi

    You can refer CU 81 - event OnBeforeConfirmSalesPost for understanding.

    If you are using the standard publisher then return might not be possible unless the boolean is available in your Publisher.

    If the publisher is created by you, then you can handle it using the first scenario.

    regards,

    Avinash B

  • Manikanta_501 Profile Picture
    245 on at
    RE: How to Define return values in Business Central Subscriber events

    Thanks for your Reply..

    If I want to Return Boolean Type value then how can I Use First Scenario.

  • Suggested answer
    Avinash B Profile Picture
    1,455 on at
    RE: How to Define return values in Business Central Subscriber events

    Hi

    Scenario 1: Using VAR

    When you use VAR on the variable, the changes that you make in the subscribers will remain.

    For Ex. 

    pastedimage1567080535754v1.png

    This is one of the events in CU 80. Where the SalesLine variable is having VAR and SalesHeader doesn't have it. So when you subscribe to this event any changes you make to the variable SalesLine will be also available after coming out Subscriber.

    Scenario 2: Using Single Instance CU

    For this, you must create a Codunit and set the property SingleInstance=true.

    So in this case, u can create a function in this CoduUnit like SetValue and GetValue.

    pastedimage1567080980952v2.png

    You can use the SetValue function to store the value in the variable and GetValue can be called where you want to use it.

    Refer to the below link for better understanding,

    https://docs.microsoft.com/en-us/dynamics-nav/singleinstance-property

    Help the community by making answer verified if it solves your issue.

    Regards,

    Avinash B

  • Manikanta_501 Profile Picture
    245 on at
    RE: How to Define return values in Business Central Subscriber events

    Can you give an example for better understand.

  • Suggested answer
    Avinash B Profile Picture
    1,455 on at
    RE: How to Define return values in Business Central Subscriber events

    Hi

    You can use VAR to the variable to return the value from the subscriber.

    Otherwise, you can create a single instance codeunit for the purpose.

    Please verify the answer to help community, if the suggestion solves the issue.

    Regards,

    Avinash B

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard > Business Central forum

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans