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: 
ionatan
Roku Guru

Roku Firmware 8 - Issue with hasField function

I'm not sure if this is the right place to report an issue with Roku OS but I think I've found an issue with hasField function on Roku OS 8 https://sdkdocs.roku.com/display/sdkdoc/ifSGNodeField#ifSGNodeField-hasField(fieldNameasString)asBoo....
This function returns true for field name "channeltype" even if this field is not added and set yet.

Please see my code below:
contentNode = CreateObject("roSGNode","ContentNode")
if contentNode.hasField("channeltype") = true
    print "SET FIELD channeltype"
    contentNode.setField("channeltype", "test1")
else
    print "ADD AND SET channeltype"
    contentNode.addField("channeltype", "string", false)
    contentNode.setField("channeltype", "test1")
end if
? contentNode

Result:
SET FIELD channeltype
<Component: roSGNode> =
{
    change: <Component: roAssociativeArray>
    focusable: false
    focusedChild: <Component: roInvalid>
    id: ""
    CHANNELTYPE: invalid
}


If I run the code from above for other field name (channeltype1) the code works. Please see below:
contentNode = CreateObject("roSGNode","ContentNode")
if contentNode.hasField("channeltype1") = true
    print "SET FIELD channeltype1"
    contentNode.setField("channeltype1", "test1")
else
    print "ADD AND SET channeltype1"
    contentNode.addField("channeltype1", "string", false)
    contentNode.setField("channeltype1", "test1")
end if
? contentNode

Result:
ADD AND SET channeltype1

<Component: roSGNode> =
{
    change: <Component: roAssociativeArray>
    focusable: false
    focusedChild: <Component: roInvalid>
    id: ""
    channeltype1: "test1"
}


If I run addField and setField for "channeltype" field name the value is set properly.
Please see below:
contentNode = CreateObject("roSGNode","ContentNode")
print "ADD AND SET channeltype"
contentNode.addField("channeltype", "string", false)
contentNode.setField("channeltype", "test1")
? contentNode

Result:
ADD AND SET channeltype

<Component: roSGNode> =
{
    change: <Component: roAssociativeArray>
    focusable: false
    focusedChild: <Component: roInvalid>
    id: ""
    channeltype: "test1"
}
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.