stempb
Design Dabbler

Lookup current user in a multi-value field in a list on a Nintex Form?

I have a list of team members called Team Members.   The team members are in a multi-value field Members.   In a Nintex form, I want to be able to do a lookup the current user in the Team Members list using the Members field.   I need to know if the current users is in one of the Members fields in Team Members.

Is this possible?  If so how would it be done?  Everything I try with the lookup function returns #Value! .

0 Kudos
Reply
10 Replies
emha
Automation Master
Automation Master

Re: Lookup current user in a multi-value field in a list on a Nintex Form?

in general something like this should work

inArray(lookup('testlist','ID',99,'multiPP'),varUser)

BUT, there is a problem that people and group field returns user identifiers in sharepoint notation (ID;#display name) and CurrentUser is returned in AD notation (claim|domain\loginname).

so they are mutually incompatible for direct comparison and you will need some further code to convert currentUser identifier to compatible format

Reply
kapilkjoshi
Automation Master
Automation Master

Re: Lookup current user in a multi-value field in a list on a Nintex Form?

Did Marian's reply help ‌?

Reply
stempb
Design Dabbler

Re: Lookup current user in a multi-value field in a list on a Nintex Form?

No I don't see how that is going to work.   The sample has the lookup hard coded.   I need to use the user as a key and see what team they are on (if any).

0 Kudos
Reply
emha
Automation Master
Automation Master

Re: Lookup current user in a multi-value field in a list on a Nintex Form?

it was meant as an example how it could work, you should be able to adapt it to your needs

'testlist' => your 'Team Members' list

ID + 99 => identifies an item in 'Team Members' list which you want to get list of people from. you can identify the item of interest in 'Team member' list by other field. you haven't described structure of the list so I used an ID field.

'multiPP' => field with list of the users you want to get. again, change the field name according your setup.

lookup function will return you list of users as an Array. so you need next to use inArray inline function to identify whether (current) user appears there.

varUser => identifies an user you look for in the array/list. I used variable there to make it clear that you can not directly use CurrentUser reference, since it has to be converter from AD notation to sharepoint notation as I mentioned above.

is it clearer now?

Reply
stempb
Design Dabbler

Re: Lookup current user in a multi-value field in a list on a Nintex Form?

Sorry but I am not following you at all.   While I am new at Nintex, I have 30 years experience in software development.

As I have said, all I have is the current user as my key.   I have many Teams.  Teams can be added and removed at any time by the users.    I don't know the ID of the Team as they can change any time.   If I had only one team and knew the ID, this would be easy.

List Name:   Teams

Fields:

Name (Name of Team)

Leader (The person that is the leader of the team)

Members (members is the multi value field with all of the names.  This is the field I need to check if current user is a member)

Reply
emha
Automation Master
Automation Master

Re: Lookup current user in a multi-value field in a list on a Nintex Form?

so, using your naming and assuming you do query by team name the formula will look like:

inArray(lookup('Teams','Name','What_Team_Are_You_looking_For','Members'),varUser)

questionable still left 'current user' (varUser).

 if you have it in form of 'ID;#display name' you can use it directly in place of varUser.

if you get it from {Common:CurrentUser} reference resp. you have it in form 'claim|domain\loginname' , you will need to convert it first.

reg. how to convert it, it may depend on your sharepoint release and edition.

in worst case you will need to write a javascript function that will do the conversion and place function call in place of varUser. some ideas how to do conversion you can find eg. here http://sharepoint.stackexchange.com/a/161831 

Reply
stempb
Design Dabbler

Re: Lookup current user in a multi-value field in a list on a Nintex Form?

I don't have a team name.   All I have is the user id.  Don't know how many times I need to mention that,

Anyway, I figured this by using JavaScript and a CAML query.

<View><Query><Where><Contains><FieldRef Name='Members'/><Value Type='LookupMulti'><UserID/></Value></Contains></Where></Query></View>

0 Kudos
Reply
emha
Automation Master
Automation Master

Re: Lookup current user in a multi-value field in a list on a Nintex Form?

oh, I see.

I'm sorry, I understood your requirement in a wrong way. I thought you want to verify whether current user is listed among members for a given Team. so I assumed you need to identify the team first. therefore that lookup via team name or ID.

with a little trick I managed to achieve what you need without javascript coding within single calculated value control.

either of following should return you array of Team Names, which current user is member of.

lookup('Teams','Members\' LookupId=\'TRUE\'','<UserID />','Name',true,'LookupMulti')


lookup('Teams','Members\' LookupId=\'TRUE\'',_spPageContextInfo.userId,'Name',true,'LookupMulti')
0 Kudos
Reply
stempb
Design Dabbler

Re: Lookup current user in a multi-value field in a list on a Nintex Form?

I was not aware CAML syntax was valid in lookup.     That is very useful information.

There are 2 functions there.   Are they just 2 ways to do the same thing?

0 Kudos
Reply