Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 4262 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

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?

Posted

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"

 
Posted

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.

Posted

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

  • Like 1
Posted

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.

Posted

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
  • Like 2
Posted

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.

Posted

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...
Posted

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.

This topic is 4262 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

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