Forum Discussion
VarunGrazitti I was just giving him idea if this way it help him.
- iftomkins10 years agoMaven
Thank you VarunGrazitti and bhupen ! I've made progress, but would love your advice, as I'm a bit stuck.
Lithium set up the fields, which is awesome. I'm now trying to set and retrieve values from the two custom profile fields:
profile.ideas_terms_accepted – Which is a checkbox
profile.ideas_terms_accepted_date - Which is date/time, and the value must be a signed decimal integer. It is interpreted as milliseconds since Jan 1, 1970. The value by default is displayed to include time.So far, this is my code to set and retrieve the value for profile.ideas_terms_accepted field:
<#assign response = restadmin("/users/id/${user.id}/profiles/name/ideas_terms_accepted/set?value=true")/>
<#assign terms_accepted = rest("/users/id/${user.id}/profiles/name/profile.ideas_terms_accepted").value>
alert('${user.id}');
alert('${terms_accepted}');It's not working. The ${user.id} is returning properly, but ${terms_accepted} is not returning a value. I tried both "true" and "checked" for the field value.
For the profile.ideas_terms_accepted_date field, I'm not sure how to generate a "signed decimal integer". I searched the community for that phrase and nothing came up.
Tips on settings and getting these values would be awesome!
- Alan
- JasonL10 years agoLithium Alumni (Retired)
hi iftomkins
not too sure about the exact context
but one thing noticed was your first REST call URL:
.../profiles/name/ideas_terms_accepted/...
and your 2nd REST call to retrieve URL was this:
.../profiles/name/profile.ideas_terms_accepted/...
should it be just .../profiles/ideas_terms_accepted/... (without the "profile.") in the 2nd REST call?
- iftomkins10 years agoMaven
Thanks JasonL . The profile.field format I had copied from another rest API call in our code, not sure why it worked there but not here. What did end up working is a combination of 1) your suggestion for formatting the URL, and 2) changing the 2nd call from rest() to restadmin().
Here's the working code:
<#assign response = restadmin("/users/id/${user.id}/profiles/name/ideas_terms_accepted/set?value=unchecked")/>
<#assign terms_accepted = restadmin("/users/id/${user.id}/profiles/name/ideas_terms_accepted").value>
alert('${user.id}');
alert('${terms_accepted}');Also, a note on checkbox fields, the values that work seem to be checked/unchecked, not true/false.
Related Content
- 11 months ago
- 10 days ago
- 11 months ago
- 11 months ago