Custom function for comparing list in document to list in page state

Good evening everyone.

First of, merry Christmas to everyone 😄

Here comes my question.

I have a custom function that I would like to use, to compare a list<string> in a document, to a list<string> in a page state, I would use this to filter search results on a page to specific strings.

The function works fine and can pass the result as I want, but I would like to pass a bool input to the function, so that the function only returns the value when the input is set, how would I go about implementing this?

I have placed the custom function below:

bool listComparisor(

List<String> documentItems,

List<String> searchItems,

) {

/// MODIFY CODE ONLY BELOW THIS LINE

// compare documentitems to searchitems for conditional visibility

// Compare documentItems to searchItems for conditional visibility

for (String item in searchItems) {

if (!documentItems.contains(item)) {

return false;

}

}

return true;


/// MODIFY CODE ONLY ABOVE THIS LINE

1
1 reply