[rt-devel] Getting Custom Fields for a User
Kevin Falcone
falcone at bestpractical.com
Tue Apr 24 12:38:04 EDT 2012
On Sun, Apr 22, 2012 at 10:52:39PM +0100, Lee Wilson wrote:
> On 22/04/2012 04:53, Ruslan Zakirov wrote:
> >First of all every object has CustomFieldValues method that return the
> >same thing. So after getting name of a CF you can call it on
> >§session{CurrentUser}->UserObj.
> >
> >ObjectCustomFieldValues is just another collection you walk with Next
> >and while loop. If you know for sure that all fields are single value
> >then you can use FirstCustomFieldValue.
> >
>
> Excellent, thanks to your help think I've got there:
>
>
> % while ( my $CustomField = $CustomFields->Next) {
> <% loc($CustomField->Name) %>
> % my $cfValues = $session{CurrentUser}->UserObj->CustomFieldValues($CustomField->Name);
> <% $session{CurrentUser}->UserObj->FirstCustomFieldValue($CustomField->Name)
> %>
> <br />
> % }
> % }
>
> The above code shows how I got the first value but also found I
> could get it with:
>
> $session{CurrentUser}->UserObj->FirstCustomFieldValue($CustomField->Id)
>
> or through a loop (which may help with future tasks):
>
> % while ( my $cfValue = $cfValues->Next) {
> <%$cfValue->Content %>
> % }
>
> Your help is very much appreciated. Now, to figure out how to do a
> add a hidden custom field :-~
If you like FirstCustomFieldValue, you may also like
CustomFieldValuesAsString which is located right below it in the docs
for RT::Record
-kevin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <http://lists.bestpractical.com/pipermail/rt-devel/attachments/20120424/af71762d/attachment.pgp>
More information about the rt-devel
mailing list