Forum Discussion
Hi Tim, the context objects provide "shallow" information for a number of reasons including performance. They typically include the identifying data needed to make subsequent REST calls to get complete attributes for an object. In your example you would use the id or login available in the context object and then make a subsequent REST call to the user service: /users/id/${user.id}.
This will return a "deep" set of attributes including the first and last name of the user. Look for:
<profile name="name_first" type="string">FIRST NAME HERE</profile>
<profile name="name_last" type="string">LAST NAME HERE</profile>
- SeanA12 years agoLithium Alumni (Retired)
The code will look something like this (i'm a rookie when it comes to freemarker so my guess is there's a more elegant way to do this but this works):
<#assign fullName=''/>
<#assign aUser=rest("/users/id/${user.id}").user/>
<#list aUser.profiles.profile as profileList>
<#if profileList.@name=='name_first'>
<#assign fullName=profileList/>
</#if>
<#if profileList.@name=='name_last'>
<#assign fullName=fullName + ' ' + profileList/>
</#if></#list>
- tnotte12 years agoAdvisor
Unfortunately, this did not work for me. However, we were very close! This is what did work in the end:
<#assign firstname = rest("/users/id/${user.id}/profiles/name/name_first").value/>
<#assign lastname = rest("/users/id/${user.id}/profiles/name/name_last").value/>
That assignment worked, so using this, I could return the string values:
<span>${firstname} ${lastname}</span>The results are just as I wanted. Looks so simple now! :robothappy: Thanks!