I am working on an event receiver inside my sharepoint server 2013. now inside the event receiver i use the following html code to build a link to the current item which cause the event receiver to fire, and send this link by email. now the current item for the event receiver can be a custom list item or a discussion board item:-
"<a href='" + properties.Web.Url + "/" + properties.ListItem.Url + "'>" + properties.ListItem["Title"] + "</a>"
now in-case of a Discussion board item the generated link will have the following href
, which will reference the item correctly :-
http://servername/managedpath/HR/project/Lists/NewsAnnouncements/test123
but in-case of a custom list item the href
will have the following url that end with _.000
:-
http://servername/managedpath/HR/project/Lists/Projects/156_.000
so now to fix this i have manually build the href
for the custom list item as follow (which will reference the DispForm.aspx
):-
"<a href='" + properties.Web.Url + "/Lists/Projects/DispForm.aspx?ID="+properties.ListItem.ID + "'>" + properties.ListItem["Title"] + "</a>
but my question is why properties.ListItem.Url
inside my original code did not work for the custom list item (the generated url will end with _.000
), while it worked well for discussion board item ? is it a problem inside my code or it is a problem/issue inside how sharepoint reference the custom list items?