- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2022 07:47 AM
I have a transform script where i am using multiple arrays but the final array is not printing the expected output.
When i check in logs i can see the same value is printing multiple times. i have a combination of for and if loop, i believe the reason may be i am using the wrong combination. How do we generally use combination of for if and else? A structure could be provided would be helpful. Thanks in advance!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2022 07:52 AM
Hello,
I believe you you are using it as below:-
for()
{
if()
//some line of code
}
else
{
//some line of code
}
}
because of which for every for loop if the if fails it iterates to else and hence the else maybe pushing multiple values in array.
You should consider using it as below:-
if()
{
for()
//some line of code
}
else
{
//some line of code
}
Please mark my answer as correct based on Impact.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2022 07:50 AM
Hi,
Combination of Loop is always a problem. There is no guidelines to this as the combination changes based on your expected data format and we cant control. I can suggest if you can share the script
Palani
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2022 07:52 AM
Hello,
I believe you you are using it as below:-
for()
{
if()
//some line of code
}
else
{
//some line of code
}
}
because of which for every for loop if the if fails it iterates to else and hence the else maybe pushing multiple values in array.
You should consider using it as below:-
if()
{
for()
//some line of code
}
else
{
//some line of code
}
Please mark my answer as correct based on Impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2022 08:20 AM
Thanks! This combination worked!