the other values in SPListItem 'ponuda' like:
ponuda["година"]
ponuda["сектор"]
...
have values, just ponuda["ТИМ"] has not value.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
i have two lists. the event receiver have to assign value (its a group) from people/group field from one list to people/group field in another list. my code is
SPQuery upitponude = new SPQuery();
upitponude.Query = "<Where><Eq>" + "<FieldRef Name='ID' />" + "<Value Type='Text'>" + idponudesmestajZ + "</Value>" + "</Eq>" + "</Where>";
SPListItemCollection kolekcijaponudaizPonudeSmestajZbirno = PonudeSmestajZbirno.GetItems(upitponude);
foreach (SPListItem ponuda in kolekcijaponudaizPonudeSmestajZbirno)
{
SPGroupCollection group = properties.Web.Groups;
int brojgrupa = group.Count;
for (int i = 1; i <= brojgrupa; i++)
{
if (group[i].Name == ponuda["ТИМ"].ToString())
{
SPFieldUserValueCollection value = new SPFieldUserValueCollection();
value.Add(new SPFieldUserValue(properties.Web, group[i].ID, group[i].Name));
properties.ListItem["ТИМ"] = value;
}
}
value of ponuda["ТИМ"].ToString() every time is null. this field in list has value(the group).
what i do?
the other values in SPListItem 'ponuda' like:
ponuda["година"]
ponuda["сектор"]
...
have values, just ponuda["ТИМ"] has not value.
Hi @gogi100 ,
First we need to confirm the type of column "ID".It's "<Value Type='Number'>" as usual. If the type wrong,we will get Multiple groups and the group is FieldUserValue.
We can't get the value correctly.
Then we need to check multiple selections as "no" like following in list setting,or it will return a collection.This option can also affect the way we retrieve group value.
Finally we can use following code to get single group
SPFieldUserValue groups = (SPFieldUserValue)ponuda["ТИМ"];
if (group[i].Name == groups.LookupValue){
}
If an Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.