Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Suggested answer

How to end the execution in else

(0) ShareShare
ReportReport
Posted on 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
    Martin Dráb 230,962 Most Valuable Professional on at
    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
    Vidhushan S 80 on at
    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
    Bharani Preetham Pe... 3,587 Super User 2024 Season 1 on at
    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
    Martin Dráb 230,962 Most Valuable Professional on at
    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
    Anitha Eswaran 312 on at
    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

Announcing Our 2025 Season 1 Super Users!

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

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Congratulations to the January Top 10 leaders!

Check out the January community rock stars...

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,962 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans