none
Handling events in Sharepoint List RRS feed

  • Question

  • I have a SharePoint list which contains a lookup field with the data for the lookup field coming from another SharePoint list on the same site. The lookup field is populated with values suche as "Adam", "John", etc. I need to capture ItemAdded event of the first list in which I need to read the value of the lookup field and do some other processing based on the value. However, when I handle the ItemAdded event, the value that it reads is e.g. "2;#John" instead of reading just "John". However, it saves the value of the lookup field as just "John".  What do I need to do so that the event reads just "John" or how can I capture just "John? I don't understand where it is grabbing "2;#" from.

    Any help will be appreciated.

    Regards,

    tshah.
    Monday, July 28, 2008 1:58 PM

Answers

  • Hi TShah

    As I mentioned above, as per my understanding, when you read user information for SPListItem object it will always be in the

    UserID;#UserName format.

    I am not too sure if you can just get the UserName.


    Amit
    • Marked as answer by shaht Monday, July 28, 2008 5:55 PM
    Monday, July 28, 2008 5:26 PM

All replies

  • I believe its user's ID and username. You will get value in this format for splistitem.

    You can simply split the value and get name or get the substring of the value.
    Amit
    • Marked as answer by Michael Washam - MSFT Monday, July 28, 2008 3:07 PM
    • Unmarked as answer by shaht Monday, July 28, 2008 5:11 PM
    Monday, July 28, 2008 2:31 PM
  • Thanks for your reply Amit.

    I understand, I can always manipulate the string and get what I want out of it. However, what  I am trying to understand is why the event would capture something like "2:#John" and not just "John" and what i need to do so that the event would just return "John". After all, this what expected of the event to return.

    Regards,

    tshah.

    Monday, July 28, 2008 5:18 PM
  • Hi TShah

    As I mentioned above, as per my understanding, when you read user information for SPListItem object it will always be in the

    UserID;#UserName format.

    I am not too sure if you can just get the UserName.


    Amit
    • Marked as answer by shaht Monday, July 28, 2008 5:55 PM
    Monday, July 28, 2008 5:26 PM
  • Thanks again Amit .

    I was not aware of what you just mentioned above.

    Thanks for taking time to respond to my question.

    Regards,

    tshah.

    Monday, July 28, 2008 5:55 PM