Pergunta

SP2016 event receiver: I have a requirement that on the itemAdded event I have to get the list item id and manipulate it and then keep it in another column.

So, on the itemAdded event, I am getting the item id eg. 34 then in same event I am making it like PR_US_34 then storing it in another column name as Request no. then send an email (.net) to the user's email with the new request no. but when I am reading the request no to send in the email, its throwing null exception.

public override void ItemAdded(SPItemEventProperties properties)
{
    base.ItemAdded(properties);
    var context = SPContext.GetContext(properties.Web);
    string requestId = Convert.ToString(properties.ListItem["ID"]);
    GenerateRequestNo(properties.ListItem["ProjectLocation"].ToString(), context); //Generate Request no with some business requirement. and storing in "RequestNo" column
    string custRequestNo = properties.ListItem["RequestNo"].ToString(); // throwing null exception
    NotifyRequester(custRequestNo); // email to users new customId
}

I have tried AfterProperties as well but no luck.

Foi útil?

Solução

Have GenerateRequestNo return the value that it generates and use that.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a sharepoint.stackexchange
scroll top