Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Combine two lists into individual records?

Featured Replies

I need to create records from two lists of IDs. Every Line in $Types needs to create a record from first line in $Categories then another record for same $types and second line in Categories. After finishing first type, go to second and repeat. I can loop first list but get mixed up on how to loop second. I tried another loop but fail. Can someone give me script to create records from two lists like this?

Solved by LaRetta

Go to solution

I want to clear something up here: you have 2 lists - $Types and $Categories - lets say

type1

type2

type3

 

and

 

category1

category2

category3

 

And I didn't understand how you want your result to look like.

 

Something like this?

1st record: "type1 category1"

2nd record: "type2 category2"

3rd record: "type3 category3"

 
  • Author

I want

 

Record 1 Type 1 Category 1

Record 2 Type 1 Category 2

Record 3 Type 1 Category 3

Record 4 Type 2 Category 1

Record 5 Type 2 Category 2 ... etc

 

Thank you for considering my need.

You need to do a nested loop.

For each outer loop record, process the inner loop record set then proceed to the next outer loop record or variable.

 

Loop

  Do things with outer loop record

  Loop

    Do things with inner loop records

  End loop

  Go to next outer loop record, exit after last

End loop

  • Author

Hi Bruce, thank you for helping.  I have that much figured out.  But I cannot exit and it gets all mixed up.  I know I need to use variables and count.  I was hoping someone would help me a bit more on the counters for each of the loops and how that might work.

  • Solution

Hi David,

 

You might try this concept, assuming your multiline variables are named $types and $categories:

 

Loop
 Exit Loop If [ Let ( $countTypes = $countTypes + 1 ; $countTypes > ValueCount ( $types ) ) ]
  Loop
   Exit Loop If [ Let ( $countCategories = $countCategories + 1 ; $countCategories > ValueCount ( $categories ))]
   New Record/Request
   Set Field [ table::Types; GetValue ( $types ; $countTypes ) ]
   Set Field [ table::Categories; GetValue ( $categories ; $countCategories ) ]
 End Loop
 Set Variable [ $countCategories; Value:"" ]
End Loop
  • Author

Hi LaRetta,

 

That script was perfect.  I was missing the idea of resetting the inner loop's count when I exited the inner loop.  And my script was quite a bit longer.  I'm going to keep this one handy since it is pretty basic and will help me many times over.  Thank you very much.

Actually, it can be tweaked yet; my bad. :crazy2:

 

I was testing for the value count of the lists within each loop.  If instead you set a variable with number of lines of both types and categories before entering the loop and then just reference these variables where I have ValueCount ( $types) and ValueCount ( $categories) it will be more optimized.  You probably wouldn't even notice the difference unless you were looping at least 10,000 lines but I couldn't NOT mention it.

  • 3 months later...

assuming your multiline variables are named $types and $categories:

Loop

Exit Loop If [ Let ( $countTypes = $countTypes + 1 ; $countTypes > ValueCount ( $types ) ) ]

Loop

Exit Loop If [ Let ( $countCategories = $countCategories + 1 ; $countCategories > ValueCount ( $categories ))]

New Record/Request

Set Field [ table::Types; GetValue ( $types ; $countTypes ) ]

Set Field [ table::Categories; GetValue ( $categories ; $countCategories ) ]

End Loop

Set Variable [ $countCategories; Value:"" ]

End Loop

I have hunted for example of looping two checkboxes and creating multiple 'and' from all the combinations and here it is. Thank you.

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.