Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
FormAPI Recursion Assistance
System
I need a generic FormAPI function to find all items that match a given pattern, where the pattern would be something like "/container/replicant[]/container/replicant[]/field' where there could be any number of containers or replicants. I think the attached code works if there are no nested replicants, but my brain is not up to the recusion today. If anyone has some spare cycles I would appreciate your assistance.
Find more posts tagged with
Comments
Migrateduser
woops, here's the attachment.
Adam Stoller
Just on a very quick glance - you have too many close-braces ('}') somewhere - the one that occurs just before the return statement at the end closes the function definition ...
--fish
Senior Consultant, Quotient Inc.
http://www.quotient-inc.com
Migrateduser
Yeah, that was just a cut-and-pasto, this code actually works for simple replicants but not nested replicants. Hopeing for help with the recursion...
hasel
Hi!
I did something like that:
function searchPattern(pattern) {
var rootItems = IWDatacapture.getRootItems();
for(var i=0; i<rootItems.length; i++) {
recursion(rootItems
, pattern);
}
}
function recursion(item, pattern) {
var childs = item.getChildren();
if(childs != null) {
for(var i=0; i<childs.length; i++) {
recursion(kinder
, pattern);
}
} else {
if(item.getName() == pattern) {
// do something
}
}
}
I hobe it works for you!
Hasel