Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Search instead for 
Did you mean: 
btpoole
Level 7

Field "Created" -Well Maybe Not

I have seen others post about this problem and have run into it also but with help was able to work thru, except now. I am using the following code to create a child of a contentnode, add a field, assign a value. When executed, the code says the field is created but really it's not.

                         content = CreateObject("roSGNode", "ContentNode")
                          dataItem = content.CreateChild("ContentNode")
                          dataItem.addfield("zip", "string", false)
                          ?"HAS FIELD "dataItem.hasfield("zip")
                         dataItem.zip=zipc
                          m.top.content=content
                          ?content
                         ?dataitem.zip

Have also tried
                                                   content = CreateObject("roSGNode", "ContentNode")
                                                  dataItem = content.CreateChild("ContentNode")
                                                  dataItem.addfields({"zip" : zipc})
                                                 ?"HAS FIELD "dataItem.hasfield("zip")
                                                 ?content
                                                  ?dataitem.zip

I basically coped the second code from another part of my app that works fine. The print of dataitem.zip displays correctly but the print of the content doesn't show the field as being added. What else could be done?
0 Kudos
2 Replies
EnTerr
Level 8

Re: Field "Created" -Well Maybe Not

You are looking in the wrong place - print DataItem and you will see it.

That printing DataItem's parent Content does not print its children nodes is unsurprising. It only prints the fields. But ask for the 1st child and you'll see it:
Brightscript Debugger> ? content.getChild(0)   ' = dataItem `
<Component: roSGNode> =
{
   metadata: <Component: roContentMetadata>
   change: <Component: roAssociativeArray>
   focusable: false
   focusedChild: <Component: roInvalid>
   id: ""
   zip: "zipC"
}
0 Kudos
btpoole
Level 7

Re: Field "Created" -Well Maybe Not

Thanks EnTerr, once again you have the answer.
0 Kudos