Find 1 record, Delete 2???

If you have questions or if you want to share your opinion about Aware IM post your message on this forum
Post Reply
BLOMASKY
Posts: 1473
Joined: Wed Sep 30, 2015 10:08 pm
Location: Ocala FL

Find 1 record, Delete 2???

Post by BLOMASKY »

This is version 8.8 build 3127. The screen shot shows it all. I have a FIND that returns 1 record, then next line is a DELETE and if there are only 2 records in the BO it deletes them both. If I have more then it usually works OK.

Any suggestions?
Screenshot 2023-07-14 at 8.11.40 PM.png
Screenshot 2023-07-14 at 8.11.40 PM.png (420.91 KiB) Viewed 9923 times
Jaymer
Posts: 2455
Joined: Tue Jan 13, 2015 10:58 am
Location: Tampa, FL
Contact:

Re: Find 1 record, Delete 2???

Post by Jaymer »

thats because there are 2 in context.
you've done 2 FINDs

do a LOG2 CONTEXT
Click Here to see a collection of my tips & hacks on this forum. Or search for "JaymerTip" in the search bar at the top.

Jaymer
Aware Programming & Consulting - Tampa FL
BLOMASKY
Posts: 1473
Joined: Wed Sep 30, 2015 10:08 pm
Location: Ocala FL

Re: Find 1 record, Delete 2???

Post by BLOMASKY »

I thought it would only delete the LAST find.

Thanks

Bruce
PointsWell
Posts: 1460
Joined: Tue Jan 24, 2017 5:51 am
Location: 'Stralya

Re: Find 1 record, Delete 2???

Post by PointsWell »

BLOMASKY wrote: Sat Jul 15, 2023 6:08 pm I thought it would only delete the LAST find.

Thanks

Bruce
Only if you've:
  • Used DELETE ThatPermanentSchedule or
  • created a sub process that doesn't feed the PermanentSchedule record to it to do the FIND
OR: Put a failsafe in

Code: Select all

IF SEARCH_COUNT = 1 THEN DELETE PermanentSchedule
ELSE IF SEARCH_COUNT < 1 DISPLAY MESSAGE ASYNC " No records found"
ELSE IF SEARCH_COUNT > 1 REPORT ERROR "Process stopped multiple records found"
Personally I am a fan of many small processes with controlled context and either fresh FIND actions or the use of NP BOs as a carrier to pass the required BO but disguised as a different BO.

Eg

TempPermSch with one attribute psPermanentSchedule that you can then pass to a sub process and interact with without having to remember This or That
customaware
Posts: 2405
Joined: Mon Jul 02, 2012 12:24 am
Location: Ulaanbaatar, Mongolia

Re: Find 1 record, Delete 2???

Post by customaware »

Another way of doing it which is great when you have more than one instance.....but more applicable when you have 3 or more....

Create a Non Persistent Business Object that has as many Reference Attributes as you need... For example.... assume you need to bring 4 different instances of a BO into context to do some comparison or whatever.

Create NP_My4BOs with ps_Instance_1, ps_Instance_2, ps_Instance_3 and ps_Instance_4. Injected each of your instances into the Reference Attributes and then you can pass the NP BO between any Processes and it takes all of the instances with it.
Cheers,
Mark
_________________
AwareIM 6.0, 8.7, 8.8, 9.0 , MariaDB, Windows 10, Ubuntu Linux. Theme: Default, Browser: Arc
Upcloud, Obsidian....
Image
PointsWell
Posts: 1460
Joined: Tue Jan 24, 2017 5:51 am
Location: 'Stralya

Re: Find 1 record, Delete 2???

Post by PointsWell »

eagles9999 wrote: Sun Jul 16, 2023 3:47 am Another way of doing it which is great when you have more than one instance.....but more applicable when you have 3 or more....

Create a Non Persistent Business Object that has as many Reference Attributes as you need... For example.... assume you need to bring 4 different instances of a BO into context to do some comparison or whatever.

Create NP_My4BOs with ps_Instance_1, ps_Instance_2, ps_Instance_3 and ps_Instance_4. Injected each of your instances into the Reference Attributes and then you can pass the NP BO between any Processes and it takes all of the instances with it.
I've used a similar setup to create quite complex double entry bookkeeping transactions (I.e. transaction plus commission plus tax) using only a few process steps.
Post Reply