Expand my Community achievements bar.

SOLVED

setCustomUserField

Avatar

Level 3
I was trying to add the ability for a user to add a City name
to their profile in the CustomRoster example. I tried to set the
following cSession.userManager.setCustomUserField but I am sure I
called it wrong. I was setting the city name from a text input box
id=cityInput.



Then I was trying to display it in the mx:list by adding to
the line - return uDesc.displayName+", "+role+",
"+uDesc.customFields;



What is the correct procedure to set and then call?



Thanks
1 Accepted Solution

Avatar

Correct answer by
Former Community Member
And here's the event class that goes with it.

View solution in original post

6 Replies

Avatar

Former Community Member
Hi,



For adding a new field, you need to first register the custom
field by calling cSession.userManager.registerCustomUserField API
and then you should call setCustomUserField to set the value of
that field. Once this is done, you can then get the value from
uDesc.customFields[myfieldName]



Hope this helps.



Thanks

Hironmay Basu

Avatar

Level 3
thanks, but I cannot still get the syntax right. I am trying
to test it by changing the CustomRoster example slightly so when
the user role changes the new field is registered and set. I then
call by using return uDesc.displayName+", "+role+",
"+uDesc.customFields['testfield']; Could you please help with the
correct syntax.



Sorry for my ignorance.



Avatar

Former Community Member


Hi there,



Unfortunately, you've stumbled into an area of code that
isn't supported yet. This is our bad - we should have removed this
before this release, since it was pretty buggy, and we ran out of
time to get it done properly for public beta. For a little
guidance, if it's marked @private, it's probably not ready for
prime-time :). Sorry for the confusion - We'll definitely get this
fixed for the next beta drop.



So, back to the problem at hand, what I'd suggest for now is
to create a separate shared model, which is indexed by userID, and
is set to userDependentItems=true, meaning that details are
retracted as users leave the room. I'll post an example in a
minute.



nigel

Avatar

Former Community Member
Here's an example model class that can work for this purpose
:

Avatar

Correct answer by
Former Community Member
And here's the event class that goes with it.
The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----