locked
Using a member of a Group to start a workflow. RRS feed

  • Question

  • I know that when you assign a task to a group using a workflow, everyone within that group gets notified, but anyone can complete the task.
    What I want to do is have a task start when anyone that is a member of a group initiates the workflow automatically.
    Right now, I am using "If Created By equals (a person's username)" to start the workflow. The problem is I have to do that for 15 managers and that is making the workflow very long. Since the managers are part of the same group, I would like to have my start clause be something like "If Created By equals ManagerGroup". I want the workflow to recognise that the person creating the task is a member of the ManagerGroup. This would eliminate a lot of redundent steps.

    Any ideas would be greatly appreciated.
    Friday, December 11, 2009 2:48 PM

Answers

  • You need to verify the whther the current user is a member of the group,,,

    private bool IsMember(string GroupName)
    {
    bool isMember = false;
    SPSite site = new SPSite(SPContext.Current.Site.RootWeb.Url);
    if (site != null)
    {
    SPWeb web = site.OpenWeb();
    isMember = web.IsCurrentUserMemberOfGroup(web.Groups[GroupName].ID);
    web.Close();
    }
    site.Close();
    return isMember;
    }

     

     


    hope this helps... if required modify above spsite params to ur workflow context..
    • Edited by Mahesh Kommanuru Friday, December 11, 2009 9:51 PM formatting
    • Marked as answer by Lily Wu Friday, December 18, 2009 6:03 AM
    Friday, December 11, 2009 9:48 PM