I am working with code developed by a consultant who I no longer have access to.
Here's what's going on. I have a list that when a new item is added the event receiver creates a folder in a document library with 6 word documents in it. Each document has all the list item columns associated with it. The documents are populated with the columns from the list item. This worsk fine.
When the list item is updated the changes are made in the documents, i.e., list item columns are changed or blank columns have data added to them.
This work but only once. When the same item is updated a second time the changes are not carried to the document columns and because of that the documents aren't updated.
Any idea why it would only fire on 1 change? I'm at a loss.
The event receiver is using the itemupdating event:
public override void ItemUpdating(SPItemEventProperties properties)
{
SPUserToken sysToken = null;
string OLARuleDocuments = "";
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite current = properties.OpenSite())
{
sysToken = current.SystemAccount.UserToken;
}
});
string currUserDispName = properties.UserDisplayName;
using (SPSite site = new SPSite(properties.SiteId, sysToken))
{
SPContentType AdpotBriefingctype, AdpotLaunchctype, ProposalBriefingctype, ProposalLaunchctype, SubstantialChangeBriefingctype, SubstantialChangeLaunchctype;
OLARuleDocuments = GetAppSetting(site, "OLARuleDocuments");
if (OLARuleDocuments == "")
OLARuleDocuments = "OLARuleDocuments";
using (SPWeb web = site.OpenWeb())
{
SPList list = web.Lists[OLARuleDocuments];
AdpotBriefingctype = web.ContentTypes["AdoptionBriefingMemorandum"];
AdpotLaunchctype = web.ContentTypes["AdoptionLaunchMemorandum"];
ProposalBriefingctype = web.ContentTypes["ProposalBriefingMemorandum"];
ProposalLaunchctype = web.ContentTypes["ProposalLaunchMemorandum"];
SubstantialChangeBriefingctype = web.ContentTypes["SubstantialChangeBriefingMemorandum"];
SubstantialChangeLaunchctype = web.ContentTypes["SubstantialChangeLaunchMemorandum"];
//ProposalBriefingMemorandum
//ProposalLaunchMemorandum
//SubstantialChangeLaunchMemorandum
//SubstantialChangeBriefingMemorandum
UpdateFolderName(list, properties);
//Hashtable AdpotBriefproperties = GetAdoptBriefHashTableProperites(properties, AdpotBriefingctype);
string filename = properties.ListItem["Title"].ToString();
bool ruledoc = UpdateDocuments(filename, OLARuleDocuments, properties);
}
}
//using (SPSite site = new SPSite(properties.SiteId, sysToken))
//{
// using (SPWeb web = site.OpenWeb())
// {
// SPList list = web.Lists[OLARuleDocuments];
// UpdateFolderName(list, properties);
// }
//}
//using (SPSite uSite = new SPSite(properties.SiteId, properties.OriginatingUserToken))
//{
// OLARuleDocuments = GetAppSetting(uSite, "OLARuleDocuments");
// if (OLARuleDocuments == "")
// OLARuleDocuments = "OLARuleDocuments";
// using (SPWeb uWeb = uSite.OpenWeb())
// {
// string filename = properties.ListItem["Title"].ToString();
// bool ruledoc = UpdateDocuments(filename, OLARuleDocuments, properties);
// }
//}
}
/// <summary>
/// An item was updated
/// </summary>
public override void ItemUpdated(SPItemEventProperties properties)
{
//base.ItemUpdated(properties);
OLASetItemLevelPermission(properties);
}
/// <summary>
/// An item was added
/// </summary>