Person or Group field restriction

Aug 14, 2009 at 8:04 PM

Is it possible to not allow the current user [ME] to be selected on a Lookup field?

Coordinator
Aug 18, 2009 at 1:26 PM

@theanykey, you want to dynamically hide the option to pick "yourself" from a dropdown?

We have the variable _spUserId, set by SP.  That gives us the site ID for the current user.  If your dropdown has something like 27#;AutoSponge for a value, then it's possible.

 

Aug 18, 2009 at 4:34 PM

On a “Person or Group” lookup box where someone would choose a name from Active Directory, if they choose themselves, I need a validation to occur that stops the submission until someone else is selected.

It sounds like I could add a jquery/spff script to the page that does something like:  IF form.name = _spUserID THEN (submit button locked and field highlighted) UNTIL form.name <> _spUserID (pseudo script of course here).  Does that sound possible with your tool?

From: AutoSponge [mailto:notifications@codeplex.com]
Sent: Tuesday, August 18, 2009 8:26 AM
To: Chris Golden
Subject: Re: Person or Group field restriction [spff:65738]

From: AutoSponge

@theanykey, you want to dynamically hide the option to pick "yourself" from a dropdown?

We have the variable _spUserId, set by SP. That gives us the site ID for the current user. If your dropdown has something like 27#;AutoSponge for a value, then it's possible.

Read the full discussion online.

To add a post to this discussion, reply to this email (spff@discussions.codeplex.com)

To start a new discussion for this project, email spff@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com

Coordinator
Aug 18, 2009 at 8:07 PM

@theanykey,

There's already a hook for custom validation, PreSaveAction.  You just have to write your function with that name and put it on the page.  SP submit will automatically stop submission if you return false (and allow submission if you return true).  I think that's your best option.  You can probably still make use of the _spUserId to match the selected value.  If you can't match the ID#, you will have to fetch the domain/name from the web service and I would suggest doing that on the page at document ready (don't wait for submit to try a web service).

 

Sep 9, 2009 at 7:51 PM
Edited Sep 9, 2009 at 7:51 PM

I have an issue on Person or Group field restriction. When trying to hide the drop downs the selection is hidden but the field title is present.

For example: exampleurl.com/Lists/Projects/NewForm.aspx?Product%20Mgr=_&Proj%20Sponsor=_

This will result in Product Manager etc being unable to be selected (the drop down is removed as expected), however the label "Product Mgr" etc will still be visible. It only occurs for Person or Group field types, all other hidden remove both the data entry field and the label.

Is this a deliberate limitation?

 P.S. Thanks for this code. Has helped enormously.