Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checked in 2 components #930

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ctalbotSFDC
Copy link
Contributor

getNextFiveRecords & getAggregateSOQL

getNextFiveRecords & getAggregateSOQL
@ctalbotSFDC
Copy link
Contributor Author

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" }

@alexed1
Copy link
Owner

alexed1 commented Oct 8, 2021

@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?

@ericrsmith35
Copy link
Collaborator

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

@ctalbotSFDC
Copy link
Contributor Author

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

@alexed1
Copy link
Owner

alexed1 commented Jul 17, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants