Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested answer

Executing actions conditionally

(0) ShareShare
ReportReport
Posted on by 386

Hello community, I want to ask that is there any that we can execute actions using an if-else condition rather than clicking on action. 

Like if (....this...) then begin 

(execute specific action)

end;

  • Suggested answer
    Inge M. Bruvik Profile Picture
    1,029 Moderator on at
    RE: Executing actions conditionally

    That is a lot of work and a potential risk of a lot if incorrect posting in order to save your user from a couple of clicks to start the posting.

    Something i would not recommend you to implement.

  • Muhammad Anas Naeemi Profile Picture
    386 on at
    RE: Executing actions conditionally

    I can give a condition like if all the fields of line are filled or some of the targeted field then directly post it without executing any action.

  • Suggested answer
    Mohana Yadav Profile Picture
    60,234 Super User 2025 Season 1 on at
    RE: Executing actions conditionally

    how does system know that you entered all the details?

    there should be a check or indicator that you entered all the data and the line is ready for posting etc.

    Like a status field or boolean field etc.

  • Muhammad Anas Naeemi Profile Picture
    386 on at
    RE: Executing actions conditionally

    The thing is that whenever I enter lines in Payment journal page I want it directly to be posted with executing the POST action.

  • Muhammad Anas Naeemi Profile Picture
    386 on at
    RE: Executing actions conditionally

    Do you of any set of code for that?

  • Suggested answer
    Inge M. Bruvik Profile Picture
    1,029 Moderator on at
    RE: Executing actions conditionally
    [quote user="Mohana Yadav"]

    We can create the procedures/functions with the code in OnAction trigger.

    and we can call those functions/procedures based on the conditions.

    IF something then

     Function1

    else

    Function 2;

    [/quote]

    But that approach requires that someone manually triggers the action by clicking on something.

  • Suggested answer
    Mohana Yadav Profile Picture
    60,234 Super User 2025 Season 1 on at
    RE: Executing actions conditionally

    We can create the procedures/functions with the code in OnAction trigger.

    and we can call those functions/procedures based on the conditions.

    IF something then

     Function1

    else

    Function 2;

  • Suggested answer
    Inge M. Bruvik Profile Picture
    1,029 Moderator on at
    RE: Executing actions conditionally

    3 ways you can achieve that. Either you can create a codeunit or a report that runs in a Job Queue at an interval to process data according to your conditions or you can try to use Power Automate to do that.  You can also look for an event publisher that is trigging the action you want to start processing on.

    What is the best approach depends a little on what you want to achieve with your processing.

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

Jainam Kothari – Community Spotlight

We are honored to recognize Jainam Kothari as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard >

Featured topics

Product updates

Dynamics 365 release plans