Skip to main content
Post a question

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id : PfsYSu2fKuK5tTVCEQQU2O
Finance | Project Operations, Human Resources, ...
Suggested answer

How to end the execution in else

Like (0) ShareShare
ReportReport
Posted on 27 Apr 2023 12:02:36 by 80

Hi experts,

I need to insert some records to a temp DB table.

If it finds any duplicate value it should give an error message and end the entire process.

Kindly suggest me a solution.

Thank you.

  • Martin Dráb Profile Picture
    231,760 Most Valuable Professional on 27 Apr 2023 at 21:00:03
    RE: How to end the execution in else

    You can't expect us to deal with requirements that you didn't mention...

    How errors are presented is handled by the system, depending on how the code is executed. You'd need to run your code asynchronously.

    You can learn more in Messaging system for finance and operations apps > Will my message end up in a message bar or in the Action center?.

  • Suggested answer
    Vidhushan S Profile Picture
    80 on 27 Apr 2023 at 16:44:42
    RE: How to end the execution in else

    Hi Martin,

    I already tried the above approach.

    But the problem is it's popping up the error message in the full screen.

    I don't want this kind of error.

    Just need to give a error in the notification list

  • Suggested answer
    Bharani Preetham Peraka Profile Picture
    3,622 Moderator on 27 Apr 2023 at 16:35:45
    RE: How to end the execution in else

    Then give if and else. In if check if same record exists. If exists then throw some error. If it doesn't have duplicate record gets inserted.

    Also you can try keeping a primary key for table which doesn't need any conditions.

    Also you can write validate write at table level and while inserting records, you can explicitly call validate write and then insert the value

  • Martin Dráb Profile Picture
    231,760 Most Valuable Professional on 27 Apr 2023 at 12:29:05
    RE: How to end the execution in else

    Anitha's idea to leave the whole thing to standard logic is a good one.

    Regarding your question. if you want to abort execution, simply throw an exception. For example:

    throw error("Error message");

  • Anitha Eswaran Profile Picture
    312 on 27 Apr 2023 at 12:10:23
    RE: How to end the execution in else

    Hi Vidhushan,

    Can you include index in the table. Error will be displayed if there are any duplication.

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,884 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,760 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Product updates

Dynamics 365 release plans
Loading complete