Forum Discussion

keshavkelkar's avatar
8 years ago

FreeMarker template error

what is to be done if I gets this error saying 

The following has evaluated to null or missing:
==> env.context.message 

that i am missing  

env.context.message 

 Please let me know what can be done to fix this ?

5 Replies

  • keshavkelkar's avatar
    keshavkelkar
    Ace
    8 years ago

    PerBonomi   Can you please tell me the REST call to or alternative way to get ${env.context.message.id}  ?

     

    I am getting freemarker error when I try to access ${env.context.message.id}, so I need some alternative way such as REST call or any other so that I could get the same value  as I am getting by ${env.context.message.id} .

     

  • jferrandis's avatar
    jferrandis
    Expert
    8 years ago

    depndening of what you really whant to do in your component, you can use such kind of snippet :

    <#assign messagesQuery = rest("2.0","/search?q=" + "SELECT * FROM messages WHERE foo='bar' ORDER BY post_time DESC LIMIT 5"?url) />
    <#if messagesQuery.data.size gt 0>
    <#list messagesQuery.data.items as message>
    <#-- do some stuff -->
    ${message.foo} will print 'foo'
    </#list>
    </#if>

    See the message Table structure for more precision about query filters and sort options

    If you want more help you should explain precisely what you want to :
    - what is your component for?
    - where you want to use it? (which page).

     

     

  • ClaudiusH's avatar
    ClaudiusH
    Khoros Alumni (Retired)
    8 years ago

    Which page did you add your custom component to? e.g. a tag page probably wouldn't have the env.context.message object. Also keep in mind that the preview in studio will only have some of the context objects populated with the community studio context. So if you see that freemarker error there... that doesn't necessarily mean your component won't work on the actual page.

  • keshavkelkar's avatar
    keshavkelkar
    Ace
    8 years ago

    ClaudiusH problem is solved I used "page.context.message.id" in place of "env.context.message.id". thanks for your inputs.