Arrays in back end

Hi everyone!

I am having problems understanding how to do certain array manipulations in a server action (i.e., the back-end side) and since I could not find a document or postings to guide me, any help you can provide here will be great!

Assume that in my server action API, I’ve done the following:

  1. Defined the variables TempArray and FinalArray as arrays using the “Core Actions > Set Value” step, set their Global Names and initialized them to null. For the sake of argument, let’s say that the structure of these arrays ismade of the text “ItemName” and the numeric “ItemAge”.

  2. Run a custom query against my database and obtained the array ResultSet. Assume that the query returned the fields “FullName” and “DateOfBirth”

  3. Used the step “Core Actions > Repeat” to cycle through the $values of ResultSet, and did some string and date operations on them to set the values of the variables RepeatName and RepeatAge:

My questions are:

A) ADD ONE ITEM TO THE END AN ARRAY
How do I add a new item to TempArray within an iteration of my repeat loop and use the resulting RepeatName and RepeatAge calculated in the current iteration to set the values of ItemName and ItemAge to the new item in my TempArray?

B) CREATE A “CLEAN” ARRAY AFTER THE REPEAT
How do I set the array FinalArray to contain a clean version with all the items that TempArray would have at the end of my repeat loop? Is it simply through a set value step or do I have to add a .split(’,’) to TempArray?

C) UPDATE AN ARRAY ITEM
Assume that after running the steps above, my FinalArray has 200 items. How to I update a specific item in it? To be more specific, What would be the syntax to do something like what’s below in a server action?:

FinalArray[14].ItemAge = “42”

D) MISCELLANEOUS

Many thanks and Happy Holidays and Happy New Year to all!
Alex

PS:

Community Page
Last updated: