Forum Discussion
The env. means you're looking to get data about a sub component of a page. Perhaps there is no context for the code to look?
Where are you using it? In a component?
PS Did you check this out? https://community.lithium.com/t5/Developer-Documentation/bd-p/dev-doc-portal?section=freemarker#l%3A%3A%7B%22p%22%3A%22%2Frefer%2FcontextObjects%22%7D
- keshavkelkar9 years agoAce
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} .
- jferrandis9 years agoExpert
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). - ClaudiusH9 years agoKhoros Alumni (Retired)
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.
- keshavkelkar9 years agoAce
ClaudiusH problem is solved I used "page.context.message.id" in place of "env.context.message.id". thanks for your inputs.