Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
Can't assign IWitem to an array element
System
Hey,
I am trying to assign a VFE field to an element of an array using the statement:
vfeFields
= IWDatacapture.getItem('/News-Articles/News/articleInfo');
However, this statement does not work properly, because when I try to do "alert(vfeFields
);", I just get an empty box.
I am not sure what's wrong here. Can you even assign an IWitem object to a simple array in js?
Thanks,
Ido
Find more posts tagged with
Comments
Migrateduser
I create arrays of items all the time.
My suspicion would be that you either have your accessor string wrong, or that javascript just isn't happy trying to spit the object out in an alert. Have you stepped through your code with a debugger to see what's going on? At the very least, make sure you have your browser set to warn you of all javascript errors.
If you are going to stick with confessional debugging, try to spit out the value or the type of the field instead.
alert(vfeFields
.getValue());
alert(vfeFields
.getType());
Johnny
You have to reference the specific item inside of your replicant.
var vfeFields = new Array();
var i;
var vfeItems;
vfeItems = IWDatacapture.getItem('/News-Articles/NewsTypeOne').getChildren();
for (i = 0; i < vfeItems.length; i++)
{
// can't remember off the top of my head if it's News/
/articleInfo or News
/articleInfo
vfeFields[vfeFields.length++] = IWDatacapture.getItem('/News-Articles/NewsTypeOne/[' + i + ']/articleInfo');
}
// replicant 2
vfeItems = IWDatacapture.getItem('/News-Articles/NewsTypeTwo').getChildren();
for (i = 0; i < vfeItems.length; i++)
{
// can't remember off the top of my head if it's News/
/articleInfo or News
/articleInfo
vfeFields[vfeFields.length++] = IWDatacapture.getItem('/News-Articles/NewsTypeTwo/[' + i + ']/articleInfo');
}
// replicant 3
vfeItems = IWDatacapture.getItem('/News-Articles/NewsTypeThree').getChildren();
for (i = 0; i < vfeItems.length; i++)
{
// can't remember off the top of my head if it's News/
/articleInfo or News
/articleInfo
vfeFields[vfeFields.length++] = IWDatacapture.getItem('/News-Articles/NewsTypeThree/[' + i + ']/articleInfo');
}
Not tested, but hey!
Migrateduser
I tried using the alert window with getValue, and getType, but that crashes because there is essentially nothing in array element. I did manage to get some output of the specific array element I am assigning the IWitem too, and it says there is null in there.
John, as far is iterating through the replicants, it is necessary when you have multiple replicants, but I only have one, so not iterations are necessary for this case.
It just seems like the assignment to a single array element is not working
jbonifaci
I would guess it has nothing to do with the array. Just swap vfeFields
with var itemObject. Then do alert(itemObject.getName()). I'm guessing this won't work either. As Johnny pointed out, the problem is likely in how you are referencing the item. Please attach your DCT if you want futher help.
~Jeff
Migrateduser
I managed to solve the issue I was having. Jeff and John, you guys were right, I was accessing the wrong element in the DCT. formAPI start counting from 1, i.e. news/type[1], is the first element and not news/type[0]. I tried accessing the 0 element, and that what caused the problem. So thanks for the advice.
I am faced with a similar problem right now, but this one involves an item and not a container. I have the following item definition in my code
Highlights
Private Bank Highlights Section
Highlight
<br> /><br> </item><br> </container><br><br>This container is contained within the root container named "homepage". So to access a replicant of the item I would do <br>IWDatacapture.getItem('homepage/Highlights/highlights<i>').<br><br>However that does not work. I try to access an item directly by setting i=1 (there is at least one replicant), however when I set i=1 the return of the getItem method is null for some reason. I don't know what's wrong here. Is there a difference in the way you access replicants of items as oppose to replicants of containers?<br>However that does not work. I try to access an item directly by setting i=1 (there is at least one replicant), however when I set i=1 the return of the getItem method is null for some reason. I don't know what's wrong here. Is there a difference in the way you access replicants of items as oppose to replicants of containers?