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

Example of Creating Custom Field in Task

Can somebody post an example of how to create a custom field. I have a task that runs, gets data from server, parses the data. I would like to assign part of the parse to a custom field name but have been unsuccessful in creating the custom field. Just putting it in the interface doesn't seem to do it. I have created an extends of the Task and added the field but I am not sure how to tell the Task an extend exists. I have something like the following:
<component name = "programContentReader" extends = "Task" >
  <interface>
  <field id = "content" type = "node" />
 <field id = "myfield" type = "string" />
  </interface>
  <script type = "text/brightscript" >
    <![CDATA[
    sub init()
      m.top.functionName = "readcontent"
    end sub

Function readcontent() as object
content = CreateObject("roSGNode", "ContentNode")
Stuff going on here to parse

dataItem = content.CreateChild("ContentNode")
dataitem.myfield= whatever is in parse
m.topcontent=content
end function

Extend of Task
<component name="extendprogram" extends="ContentNode" >
<interface>
    <field id ="myfield" type="string" />
   </interface>
0 Kudos
2 REPLIES 2
EnTerr
Roku Guru

Re: Example of Creating Custom Field in Task

What you have posted is a jumble and makes no sense! 
No offense meant, it just seems you are not sure what you want to do - your code pokes in all directions.

Two things though - are you trying something that is in a beta version of the firmware?! If so, you are under NDA on it - ask in the beta forum!

And there is no need to pre-declare in interface, creating a custom filed is as easy as:
dataItem.addFields({myField: "some value here - string or array or dictionary"})
0 Kudos
btpoole
Channel Surfer

Re: Example of Creating Custom Field in Task

None taken what so ever.  I was using the SimpleMarkupList example as sort of a guide, but was making it harder than it needed to be. I think I was mixing in group as in the example when I didn't need to.  Thanks for pointing me in the right direction.
0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.