frardouin
Joined 8 years ago
Joined 8 years ago
As 2nd APi also returning the array so we must put it in list also. Here is the corrected version.
<#assign currentUserid = page.context.user???then(page.context.user.id, user.id) />
<#assign kudoedMessages = restadmin("2.0", "/search?q=" + ("SELECT * FROM kudos WHERE user.id = '${currentUserid}'")?url).data.items![] />
<#list kudoedMessages as kudoedMessage>
<#assign messages= rest("2.0","/search?q=" + "SELECT * FROM messages WHERE id='${kudoedMessage.message.id}'"?url).data.items![] />
<#list messages as message>
<p>${message.id}</p>
<p>${message.subject}</p>
<p>${message.post_time?date}</p>
<p>${message.author.login}</p>
</#list>
</#list>frardouin- This is a bit tricky, you will need to make a nested call for this.
1. The first call will fetch all the solved topics posted by an author
SELECT * FROM messages WHERE depth = 0 AND conversation.solved = true AND author.id = '<authorID>'
2. The second Call will fetch the accepted solution
SELECT * FROM messages WHERE is_solution = true and topic.id = '<topid id you will get from first call>'
Docoumentation: https://community.lithium.com/t5/Developer-Documentation/bd-p/dev-doc-portal?section=commv2&collection=messages#constraints-conversation.solved
Regarding the re-ordering, if you want to show all the activities together, you need to sort it manually, you can not fetch all the details using on call. e.g store all the query result into on variable and then sort it by post_time.
Hi,
If you are using the rest api call to fetch the listing of posts, then you can first find the author id and check the role using following v1 api, based on that you will be able to add the icon or class.
<#assign userRole = restadmin("/users/id/[authorID]/roles").roles.role />
<#assign rolesArray = [] /> <#-- user can have multiple roles -->
<#list userRole as role >
<#assign rolesArray = rolesArray + [role.name] />
</#list>
<#if rolesArray?seq_contains("Administrator")>
//your code
</#if>Let me know if this works for you.
Thanks,
Payal
Hi frardouin,
You can use the folllowing v2 query to get the current logged user info:
<#assign userInfo = rest("2.0", "/search?q=" + "Select * from users where id = '${user.id}'"?url).data.items />
<#list userInfo as getInfo>
<span>${getInfo.first_name}</span>
<span>${getInfo.last_name}</span>
<span>${getInfo.login}</span>
<span>${getInfo.avatar.profile}</span>
</#list>Let me know if it works for you.
Thanks,
I would not be possible to check the code in the studio for OOTB components. Here is the perfect documentation for how to override the core components.