Thanks Ishai, I will just give you my thoughts on this.
1.) It's custom activity to run inside SPD workflow 2.) I have tried using Elevated privleges and Impersonation but no luck, and even tried to use them both. I also added this activity in Impersonation step in SPD but it makes no difference. 3.) If I go to workflow and start it manually, then it does not give any permission error. 4.) Only when I workflow starts automatically it does not do anything. 5.) You are right problem is in CreateTerm method, I attached a debugger, and get permission error on "termSet.CreateTerm(projectName, 1033);" Error message is you do not have enough permissions to do this task. Code Below protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext) { SPSite contextSite = __Context.Site; string url = contextSite.Url; SPWeb contextWeb = __Context.Web; SPList contextList = contextWeb.Lists[new Guid(__ListId)]; SPListItem contextItem = contextList.GetItemById(__ListItem); SPFieldUserValue userValue = new SPFieldUserValue(contextWeb, contextItem["Created By"].ToString()); ; string title = contextItem["Title"].ToString(); using (SPSite siteCollection = new SPSite(url)) { using (SPWeb web = siteCollection.OpenWeb()) { SPUserToken userToken = web.AllUsers["Domain\\Admin_Account"].UserToken; using (SPSite newSite = new SPSite(contextWebUrl,userToken)) { using (SPWeb myWeb = newSite.OpenWeb()) { CreateTerm(siteCollection, title); } } } } return ActivityExecutionStatus.Closed; } protected static void CreateTerm(SPSite siteCollectionObject, string projectName) { TaxonomySession session = new TaxonomySession(siteCollectionObject); foreach (TermStore termStore in session.TermStores) { foreach (Group group in termStore.Groups) { if (group.Name == "Test group") { foreach (TermSet termSet in group.TermSets) { if (termSet.Name == "Projects") { bool doesThisTermExist = false; TermCollection terms = termSet.GetAllTerms(); foreach (Term term in terms) { if (term.Name == projectName) { doesThisTermExist = true; } } if (!doesThisTermExist) { termSet.CreateTerm(projectName, 1033); termStore.CommitAll(); } } } } } } } On Sat, Dec 17, 2011 at 11:38 AM, Ishai Sagi <is...@exd.com.au> wrote: > That code doesn’t really elevate privilages – either the token or the > “RunWithElevatedPrivileges” is redundant. I think the problem will be in > the “CreateTerm” function. If you share that with us we may see the cause > of the issue.**** > > ** ** > > ** ** > > **[image: Description: Description: Description: > C:\Users\Brian\Pictures\EXD Logos\Extelligent logo no text.jpg]***Ishai > Sagi* | Solutions Architect > 0488 789 786 | is...@exd.com.au | www.sharepoint-tips.com | > @ishaisagi<http://twitter.com/ishaisagi> > **** > > ** ** > > *From:* ozmoss-boun...@ozmoss.com [mailto:ozmoss-boun...@ozmoss.com] *On > Behalf Of *Ajay > *Sent:* Friday, 16 December 2011 5:49 PM > *To:* ozMOSS > *Subject:* Fwd: Custom Workflow Activity**** > > ** ** > > I have discovered it's permission issue when workflow starts automatically. > **** > > I have elevated priveleges and also opened the site using token of admin > account stil no luck.**** > > See my code below**** > > SPUser user = web.AllUsers["mydomain\\sharePoint_admin"]; **** > > SPUserToken token = user.UserToken; **** > > SPSecurity.RunWithElevatedPrivileges(delegate() **** > > {**** > > using (SPSite site = new SPSite(siteCollection.ID, token)) **** > > {**** > > CreateTerm(site, title);**** > > }**** > > });**** > > ** ** > > ---------- Forwarded message ---------- > From: *Ajay* <akhanna...@gmail.com> > Date: Fri, Dec 16, 2011 at 7:11 PM > Subject: Custom Workflow Activity > To: ozMOSS <ozmoss@ozmoss.com> > > **** > > Hi Guys,**** > > I have created a custom WF activity hooked up in SharePoint designer. > It creates a sub-site and some user groups.**** > > So far so good, then the requirement came to add the site name to the Term > Store.**** > > The workflow is configured to start on Item Added.**** > > On Automatic start, problem is the workflow just creates the sub-site, > does not create the term store entry and shows status as Cancelled. > When I manually start this workflow, than everything is fine, it creates > site, adds term store entry and shows Status as Completed. > I ran a debugger stepped through the code all works fine.**** > > What can be the reason for this.. is it permissions / identity issue when > it runs manually opposed to automatic workflow start.**** > > Cheers, > A**** > > ** ** > > _______________________________________________ > ozmoss mailing list > ozmoss@ozmoss.com > http://prdlxvm0001.codify.net/mailman/listinfo/ozmoss > >
<<image002.jpg>>
_______________________________________________ ozmoss mailing list ozmoss@ozmoss.com http://prdlxvm0001.codify.net/mailman/listinfo/ozmoss