Question

I am using ItemUpdating Event for recording changes in List Item.

  item["RequestType"].ToString().ToUpper() !=properties.AfterProperties["RequestType"].ToString().ToUpper()

RequestType field is lookup field and it holding values as drop down.

Ex: RequestType field containing two option values. i.e. Application and Desktop.

item["RequestType"].ToString() shows "1;#Apllication" and in Item Updating i didn't change any thing but

properties.AfterProperties["RequestType"].ToString() showing "1" value.

What is the problem in my code.

Please suggest me about this error.

I am using SharePoint 2010.

Was it helpful?

Solution

Instead of try to fetch the lookFieldValue from afterproperties, fetch the LookupID from current lookupfield value and compare it with afterproperties.

The reason why we are not able to fetch the lookfieldValue from afterproperties is the afterproperties only return the lookupID, whereas we require the string of the format lookupID#lookUpValue to fetch the lookupfieldValue.

var prevLookup = new SPFieldLookupValue(item["RequestType"].ToString());
prevLookup.LookupId.ToString()!=properties.AfterProperties["RequestType"].ToString()
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top