Assignment Not Working?

My app has the following function:

Function Opendetailsscreen_one_time_purchase()
    print "detailsscreen_one_time_purchase"
    
    print "m.gridScreen.focusedContent:"
    print m.gridScreen.focusedContent  '<==PRINTS AS EXPECTED
    
    print "m.detailsscreen_one_time_purchase.content:"
    print m.detailsscreen_one_time_purchase.content '<==PRINTS 'invalid'
    
    'show DetailsScreen Node with description, Video Player
    m.detailsscreen_one_time_purchase.content = m.gridScreen.focusedContent
    
    print "m.detailsscreen_one_time_purchase.content:"
    print m.detailsscreen_one_time_purchase.content [size=85][font=monospace]'<==PRINTS 'invalid'[/font][/size]
    
    ShowScreen(m.detailsscreen_one_time_purchase)
End Function

Here is the print output:

m.gridScreen.focusedContent:

m.gridScreen.focusedContent is valid. It’s assigned to m.detailsscreen_one_time_purchase.content. Why is m.detailsscreen_one_time_purchase.content invalid after the assignment?

Thanks very much in advance to all for any info!

what kind of object is “m.detailsscreen_one_time_purchase” ?
My guess is it does not have a field “content” and you’d need to add that field one way or the other.

detailsscreen_one_time_purchase is a <Component: roSGNode>. You are quite right – it doesn’t have field ‘content’. In looking at other Brightscript code, it seemed like you create a variable by assigning a value to it. I’m a Brightscript newbie. What is the correct way to add the field content to a <Component: roSGNode>?

https://sdkdocs.roku.com/display/sdkdoc/ifSGNodeField#ifSGNodeField-addField(fieldNameasString,typeasString,alwayNotifyasBoolean)asBoolean

addField(fieldName as String, type as String, alwayNotify as Boolean) as Boolean

So I think you can do this as soon as m.detailsscreen_one_time_purchase gets created:

m.detailsscreen_one_time_purchase.addField("content","Node",true)

then it will have content field available, via m.top.content from internally and via m.detailsscreen_one_time_purchase.content externally.
hope it helps,
Joe

PS: many pre-defined components have a “content” field built in (rowlist is one example) so perhaps you’d rather consider changing the type of your node to one that has content already. Also take a look at generic “contentNode” as that comes with a bunch of pre-defined fields you can use (although afaik “content” is not one) - generally “content” fields are made up of a Node with a bunch of child contentNodes.

Thanks very much for this great info, @joetesta !