If you have questions or if you want to share your opinion about Aware IM post your message on this forum
#51800 by Jaymer
Fri Oct 11, 2019 6:56 pm
Either there is a need for this, or I'm doing something the "non-Aware" way.

Lets say you have a table of Products and only 1 can be "Featured".
Either by manual selection, or algorithm, the desired product gets referenced in a tmp field in the LoggedInRegularUser record (because we don't really have temp memory variables, so we have to store this in LIRU)
You have a Process "Set Featured Product"
You want to call this Process and set the one to Featured. Its pointed to by LIRU.tmp_featured_Product
You need to find any previously/current Featured one(s) out there (should only be 1, might be none) and UnFeature it, then mark the desired one.

1. FIND Product WHERE Featured='Yes' /* Found 1 object */
2. Product.Featured = 'No' /* Looks good so far. Previous one gets UnFeatured */
3. FIND Product WHERE Product = LIRU.tmp_featured_Product /* Found 1 object */
4. Product.Featured = 'Yes' /* Sets BOTH Products, because both are in Context */

Existing Solution: Add another Process "Set Featured Product_clear"
Above Process becomes:
1a. Set Featured Product_clear
3. FIND Product WHERE Product = LIRU.tmp_featured_Product /* Found 1 object */
4. Product.Featured = 'Yes' /* Sets only 1 Product, because the other one was not found in this process. Its long forgotten */


Proposed Solution - NEW Function
1. FIND Product WHERE Featured='Yes'
2. Product.Featured = 'No' /* Looks good so far. Previous one gets UnFeatured */
2b. CLEAR CONTEXT Product
3. FIND Product WHERE Product = LIRU.tmp_featured_Product /* Found 1 object */
4. Product.Featured = 'Yes' /* Sets only 1 Product, because we cleared the 1st record from Context */

This isn't a showstopper - because you can always get around the issue by creating a sub process - but thats just ONE MORE Process, and we know how tedious it gets searching through long Process lists.
Would be nice to add 1 Rule to keep from Making a New Process

What do y'all think?
#51809 by eagles9999
Sat Oct 12, 2019 7:02 am
I would do it like this...unless I am missing something...

Featured Test BS
(37.53 KiB) Downloaded 1 time
#51810 by hpl123
Sat Oct 12, 2019 8:55 am
Jaymer wrote:Either there is a need for this, or I'm doing something the "non-Aware" way.

Lets say you have a table of Products and only 1 can be "Featured".
Either by manual selection, or algorithm, the desired product gets referenced in a tmp field in the LoggedInRegularUser record (because we don't really have temp memory variables, so we have to store this in LIRU)
You have a Process "Set Featured Product"
You want to call this Process and set the one to Featured. Its pointed to by LIRU.tmp_featured_Product
You need to find any previously/current Featured one(s) out there (should only be 1, might be none) and UnFeature it, then mark the desired one.

1. FIND Product WHERE Featured='Yes' /* Found 1 object */
2. Product.Featured = 'No' /* Looks good so far. Previous one gets UnFeatured */
3. FIND Product WHERE Product = LIRU.tmp_featured_Product /* Found 1 object */
4. Product.Featured = 'Yes' /* Sets BOTH Products, because both are in Context */

Existing Solution: Add another Process "Set Featured Product_clear"
Above Process becomes:
1a. Set Featured Product_clear
3. FIND Product WHERE Product = LIRU.tmp_featured_Product /* Found 1 object */
4. Product.Featured = 'Yes' /* Sets only 1 Product, because the other one was not found in this process. Its long forgotten */


Proposed Solution - NEW Function
1. FIND Product WHERE Featured='Yes'
2. Product.Featured = 'No' /* Looks good so far. Previous one gets UnFeatured */
2b. CLEAR CONTEXT Product
3. FIND Product WHERE Product = LIRU.tmp_featured_Product /* Found 1 object */
4. Product.Featured = 'Yes' /* Sets only 1 Product, because we cleared the 1st record from Context */

This isn't a showstopper - because you can always get around the issue by creating a sub process - but thats just ONE MORE Process, and we know how tedious it gets searching through long Process lists.
Would be nice to add 1 Rule to keep from Making a New Process

What do y'all think?


Yes yes yes. I often have scenarios where this would be useful.
#51813 by eagles9999
Sat Oct 12, 2019 9:56 pm
As can be seen in the Demo bsv
#51814 by hpl123
Sun Oct 13, 2019 6:46 am
BLOMASKY wrote:Isnt this what THIS and THAT were created for?

Find....
Product.... = No
Find....
ThisProduct.featured = 'Yes'

Bruce


Yes, This That and Other works in many cases but you are limited to 3 "batches" of data (sometimes more complex operations with data etc. is needed) and sometimes the This, That and Other is buggy. Another thing is, sometimes even with subprocesses and measures to work with data completely independant from original data, Aware confuses the context and applies operations and data change from the old data operations to the new data operations (which it shouldn't i.e it's buggy as well). NB: This functionality works 98% of the time i.e it´s not a big thing but it still happens.

Having a function to simply CLEARCONTEXT would enable us to work around all this (sometimes a real clean slate is what you need) and also as Jaymer pointed out, minimize total number of processes.

When talking about new context function/ideas. I would love to have memory slots for context (think calculator M button) where we could allocate a context batch to a slot e.g M1Context, M2Context etc. and then (after clearing context) work with some other things before returning/calling/using data from the memory slots. A cool and maybe better variation of this would be to give us state management like functions where we could use "variable" names like PRODUCTCONTEXT = X (current context or operation to populate context with stuff).
Last edited by hpl123 on Sun Oct 13, 2019 5:05 pm, edited 2 times in total.
#51815 by PointsWell
Sun Oct 13, 2019 9:17 am
BLOMASKY wrote:Isnt this what THIS and THAT were created for?

Find....
Product.... = No
Find....
ThisProduct.featured = 'Yes'

Bruce


Or create a non persisted BO with a single attribute reference to your desired BO
#51816 by Jaymer
Sun Oct 13, 2019 8:26 pm
If you're looking at this as just a way to prove that THIS or THAT "may" work, then you're missing the point.

Try this alternate scenario.

FIND n records FROM CUST WHERE xyzzy /* Finds 3 records this time
CALL Process /* Send the found Context off for processing
FIND n records FROM CUST WHERE plugh /* Find another set of 5 records, for example
CAL Process /* SENDS ALL 8 records off for processing, INSTEAD of the 5 you want

USING CLEAR CONTEXT CUST inbetween the steps would make this work as desired (and as Obvious to most people reading the rule)
#51817 by PointsWell
Sun Oct 13, 2019 9:47 pm
Jaymer wrote:If you're looking at this as just a way to prove that THIS or THAT "may" work, then you're missing the point.

Try this alternate scenario.

FIND n records FROM CUST WHERE xyzzy /* Finds 3 records this time
CALL Process /* Send the found Context off for processing
FIND n records FROM CUST WHERE plugh /* Find another set of 5 records, for example
CAL Process /* SENDS ALL 8 records off for processing, INSTEAD of the 5 you want

USING CLEAR CONTEXT CUST inbetween the steps would make this work as desired (and as Obvious to most people reading the rule)


Generally if I have this type of challenge then I am trying to do too much with a single process. If you are doing searches to then process the find results afterwards I find it best from a code containment point of view to drop these to a lower process.

If you need the results back in the main process then I create a non persisted BO, pass that to the sub process run the sub process and then attach the result to the NPBO to pass back to the main process.

Personally I have hundreds of processes. All of them pretty small and all of them with a standard naming convention of:

BOname_action_stepInProcess_SpecificAction

Eg
Contact_Create_1000_AttachEmployer

To me that is easier to follow, easier to debug and easier to find than monolithic processes.

Who is online

Users browsing this forum: Google [Bot], MSN [Bot] and 15 guests