Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
btpoole
Channel Surfer

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 2
EnTerr
Roku Guru

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
Channel Surfer

Re: Field "Created" -Well Maybe Not

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