LightningFlowComponents icon indicating copy to clipboard operation
LightningFlowComponents copied to clipboard

Checked in 2 components

Open ctalbotSFDC opened this issue 2 years ago • 5 comments

getNextFiveRecords & getAggregateSOQL

ctalbotSFDC avatar Oct 04 '21 17:10 ctalbotSFDC

GetNext5RecordsFlowAction Apex Action that takes a position and a list, and returns the next 5 records from the list, starting at the position provided (or null if no records found) into separate variables

Add this apex action to a flow & pass the following input variables:

counter --> the index to retrieve the next 5 objects from the list listOfRecs --> the list of objects to retrieve objects from You will be able to retrieve the following outputs:

totalNumRecs --> how many items are in the list provided; -1 if list is empty foundCount --> how many records were retrieved (0 to 5) since the list may not have 5 records to retrieve from the counter position; -1 if list is empty newCounter --> next position in the list after retrieving the next 5; will be the last position of the list if foundCount is < 5; -1 if list is empty percent --> gives the decimal percentage of the list you have perused; uses input counter / totalNumRecs; format is 0.10 for 10% firstRec --> first object at position counter; is null if foundCount = 0 or -1 secondRec --> second object at position counter + 1; is null if foundCount < 1 thirdRec --> third object at position counter + 2; is null if foundCount < 2 fourthRec --> fourth object at position counter + 3; is null if foundCount < 3 fifthRec --> fifth object at position counter + 4; is null if foundCount < 4

AggregateSOQLFlowLightningComponent Apex Action that allows a user to run an aggregate query and return a list of the results from one of the fields or expressions as a List of Strings

Add this apex action to a flow & pass the following input variables:

query --> the aggregate query to execute against the database fieldname --> the fieldname from the query to retrieve and put into a list of strings You will receive the following outputs:

List of Strings --> a list of strings that equates to the aggregate query's fieldname values Example:

query = "select category__c, count(Id) from assessment_question__c where assessment__c = '0AB234001234567' group by category__c order by category__c" fieldname = "category__c"

results of query =

{"ABC", 4},

{"BCD", 2},

{"CDE", 3},

{"FGH", 10}

List of Strings = { "ABC", "BCD", "CDE", "FGH" }

ctalbotSFDC avatar Oct 04 '21 17:10 ctalbotSFDC

@ctalbotSFDC can you expand your writeup a bit and add some example use cases? Can you show any images of these in use or would you be interested in a video that walks through them in use? Not a requirement but I'd like to make it easier for others to put these to use.

Also, I'm thinking that GetNext5Records might be a good fit for the CollectionProcessors category. That would imply that we should move it to here https://github.com/alexed1/LightningFlowComponents/tree/master/flow_action_components/CollectionProcessors/force-app/main/default/classes. @adwhite75 would you concur?

alexed1 avatar Oct 08 '21 15:10 alexed1

@alexed1 @adwhite75 I'd like to see it as part of the collection processors. Could it be updated first to be GetNextNRecords?

ericrsmith35 avatar Oct 08 '21 16:10 ericrsmith35

Because of Flow, the whole point of the action is to get the sequential record from a list as an individual item so you don't have to loop through the entire list to get individual variables. I chose 5 because that was a reasonable number, and so there are 5 output variables. I could up it to 10, but then it'll have 10 output variables. And I could add an input to say how many (up to 10) you want to put into separate variables.

I'm ok with moving to the other section (I'm not overly partial to where it goes) :)

I'll try to work on something more for the writeup on the getnext5records. Do you have enough for the aggregatesoql one?

@alexed1 @adwhite75 @ericrsmith35

ctalbotSFDC avatar Oct 08 '21 22:10 ctalbotSFDC

Circling back on this....I think these are both highly useful extensions. I think that I'd like you to call the first one 'GetNextFiveRecordsIndividually' and add it to the collection processors project, and I think that the second one should be called MakeAggregateQuery and added to this project I know a lot of time has passed, Christine, since you offered this contribution, and you may have moved on to other things, but I would like to publish it if you're still interested.

alexed1 avatar Jul 17 '22 02:07 alexed1