web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

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 390

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;

I have the same question (0)
  • Suggested answer
    Inge M. Bruvik Profile Picture
    1,111 Moderator on at

    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.

  • Suggested answer
    Mohana Yadav Profile Picture
    60,999 Super User 2025 Season 2 on at

    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,111 Moderator on at
    [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.

  • Muhammad Anas Naeemi Profile Picture
    390 on at

    Do you of any set of code for that?

  • Muhammad Anas Naeemi Profile Picture
    390 on at

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

  • Suggested answer
    Mohana Yadav Profile Picture
    60,999 Super User 2025 Season 2 on at

    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
    390 on at

    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
    Inge M. Bruvik Profile Picture
    1,111 Moderator on at

    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.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 3,010

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 1,270 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 1,085 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans