Trying to modify ProjectPolicy Properties server side is giving me an error :
List<ProjectPolicy> availPolicies = ProjectPolicy.GetProjectPolicies(web);
ProjectPolicy policy = availPolicies.FirstOrDefault();
policy = availPolicies.Where(p => p.Name == "XYZPolicyName").FirstOrDefault();
policy.EmailSubject = "SiteName Deletion Notice";
policy.SavePolicy();
Getting an error at SavePolicy(): "The collection cannot be
modified."
Same is working for client side one. What could be the problem in server side?
Below link for reference, it's working at client side. Reference
Is there any other way of achieving it? I want to change policy email while creating new site collection. I have creating site collection thing ready. Only thing is I need to update code with policy email content. Above code gives error as mentioned. Is there any other way I can achieve it.
[Edited and added error logs]
Microsoft.SharePoint.SPException
Message=The collection cannot be modified.
StackTrace:
at Microsoft.SharePoint.SPContentType.Update(Boolean updateChildren, Boolean ignoreSealedOrReadOnly, Boolean throwOnSealedOrReadOnly, IList`1 exceptions)
at Microsoft.Office.RecordsManagement.InformationPolicy.Policy.Update()
at Microsoft.Office.RecordsManagement.InformationPolicy.ProjectPolicy.Update()
at ExpirationPolicyEmail.Program.Main(String[] args) in f:\SharePoint Apps\ExpirationPolicyEmail\ExpirationPolicyEmail\Program.cs:line 81
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()