tag:blogger.com,1999:blog-7235227623336854018.comments2023-11-05T07:22:52.536-05:00SharePoint Code BlockCory Petershttp://www.blogger.com/profile/09266771165654103518noreply@blogger.comBlogger11125tag:blogger.com,1999:blog-7235227623336854018.post-47034855685702787912009-07-07T02:41:46.838-04:002009-07-07T02:41:46.838-04:00Ehm... Any ideas how to assign a constructed SPFie...Ehm... Any ideas how to assign a constructed SPFieldUserValueCollection object to a UserMulti field in PowerShell?<br /><br /> $item["Field"] = $uvc doesn't seem to work whether you call ToString or not. <br /><br />The assignment operator fails to understand the "999;#domain\username" syntax in this case. Complains that it cannot convert that string to SPFieldUserValue object.ACrushhttps://www.blogger.com/profile/14992512475257498004noreply@blogger.comtag:blogger.com,1999:blog-7235227623336854018.post-3038617885773634912009-04-23T05:00:00.000-04:002009-04-23T05:00:00.000-04:00This comment has been removed by the author.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-7235227623336854018.post-86686998973295111442009-04-23T04:59:00.000-04:002009-04-23T04:59:00.000-04:00Great post! Could you please show how to retrieve ...Great post! Could you please show how to retrieve a string value from a text Field? I tried to get it via field.GetFieldValue(string value), but what do I have to put in for string value?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-7235227623336854018.post-31383493734115182372009-02-19T10:02:00.000-05:002009-02-19T10:02:00.000-05:00Here is some code which you can adapt for your use...Here is some code which you can adapt for your use with UserMulti.<BR/><BR/>SPFieldUserValueCollection col = new SPFieldUserValueCollection();<BR/>string[] userarray = StringOfUsers.Split(',');<BR/>foreach (string username in userarray)<BR/>{<BR/> SPUser user = web.EnsureUser(username);<BR/> SPFieldUserValue uservalue = new SPFieldUserValue(web, user.ID, user.LoginName);<BR/> col.Add(uservalue);<BR/>}<BR/><BR/>item["UserMulti"] = col.ToString();Marlohttps://www.blogger.com/profile/06573253131340503510noreply@blogger.comtag:blogger.com,1999:blog-7235227623336854018.post-63714406796720010812009-01-28T13:31:00.000-05:002009-01-28T13:31:00.000-05:00hah, I just implemented a bunch of string split an...hah, I just implemented a bunch of string split and test for length stuff to parse out the value of a user field as an SPListItem instead of the strongly typed, and here I found that its as simple as casting it. Thanks! I can go back and fix my code now to do it the easy way. <BR/><BR/>--davedave.dolanhttps://www.blogger.com/profile/11106747831153647534noreply@blogger.comtag:blogger.com,1999:blog-7235227623336854018.post-9874465943539608382008-12-10T13:15:00.000-05:002008-12-10T13:15:00.000-05:00Also, what's "item" type? SPListItem?Also, what's "item" type? SPListItem?Olihttps://www.blogger.com/profile/13367421007414387503noreply@blogger.comtag:blogger.com,1999:blog-7235227623336854018.post-36891519192529054302008-12-10T12:06:00.000-05:002008-12-10T12:06:00.000-05:00You really did try this?item["FieldName"] = new SP...You really did try this?<BR/><BR/>item["FieldName"] = new SPFieldLookupValue("Title");<BR/><BR/>And you don't have the "Value does not fall within the expected range." error??<BR/>Somehow, it seems to only accept strings that are castable as Integer. Like this would work:<BR/><BR/>item["FieldName"] = new SPFieldLookupValue("12345");<BR/><BR/>After executing the code just above, i check the value of item["FieldName"].LookupID and its 12345. So it basically converts the string to an Integer and places it in LookupID.Olihttps://www.blogger.com/profile/13367421007414387503noreply@blogger.comtag:blogger.com,1999:blog-7235227623336854018.post-84373732233523951512008-10-23T07:01:00.000-04:002008-10-23T07:01:00.000-04:00I agree with Dimitrie.This is how you retrieve the...I agree with Dimitrie.<BR/><BR/>This is how you retrieve the possible choices from a multiple choice field:<BR/><BR/>SPFieldMultiChoice myChoiceField = new SPFieldMultiChoice(myItem.Fields, "myFieldnameString");<BR/><BR/> foreach (string choice in myChoiceField.Choices)<BR/> {<BR/> // do something with the value of the string choice here<BR/> }Anonymoushttps://www.blogger.com/profile/06425236265913122959noreply@blogger.comtag:blogger.com,1999:blog-7235227623336854018.post-10069141606058223542008-10-09T15:13:00.000-04:002008-10-09T15:13:00.000-04:00SPFieldMultiChoiceValue does not implement an iter...SPFieldMultiChoiceValue does not implement an iterator so you can not use a foreach loop to retrieve individual values.Unknownhttps://www.blogger.com/profile/01698663638194766871noreply@blogger.comtag:blogger.com,1999:blog-7235227623336854018.post-82504480897940490822008-09-17T12:21:00.000-04:002008-09-17T12:21:00.000-04:00Hi, thanks for the heads up on this matter.Followi...Hi, thanks for the heads up on this matter.<BR/><BR/>Following you method I'm getting this error "Value does not fall within the expected range" when I make this assignment:<BR/><BR/>listItem["ItemName"] = User;<BR/>//user is an SPUser obj<BR/><BR/>I filled the User variable with the steps that you provide and debugging it on VS2005 I can see that the value in it is correct. Something like {SPVM\bob}<BR/><BR/>Any help available?<BR/><BR/>Thanks,<BR/>RogerAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-7235227623336854018.post-26478929062351109942008-08-04T04:19:00.000-04:002008-08-04T04:19:00.000-04:00Hi this post is great!However, is it possible to p...Hi this post is great!<BR/>However, is it possible to post soemthing on SPFieldUserMulti. <BR/><BR/>I wish to extract all the users from a multiselect Person field and give them permissions in an event handler.<BR/><BR/>Any ideas??Thank youCsam0003https://www.blogger.com/profile/06035103510725767563noreply@blogger.com