views:

110

answers:

2

I am designing a system on SharePoint. There is a approval list for the items. The members can approve, reject and edit the items. One from approval list has to fill the "assigned to" field in the item while approving it. The user who is added to "assigned to" field should able to edit the content of the item after it is approved. So, how can I give the edit permission to the users after they are added assigned to field of a specific item?

The situation is:

approval list: A, B ,C (edit, view permission)

users: x,y,z .... (no permission, view after approval)

items: item1, item2, item3....

items are invisible. A approved the item1 and added X to "assigned to" field. It means This item is under X's responsibility. But X hasn't got edit permission. we can't give edit permission to X for every item. He should edit the items after he is written into the "assigned to" field.

How can I create this workflow in SharePoint? Please urgent help needed.

+1  A: 

Not 100% sure it is fully clear what you are trying to achieve, but...

From my understanding of your question, what you want to do is assign unique permissions to a list item based on a value in the assigned to field of that list item.

The way I would do this is to create an event handler for your items list that runs when the list item is updated/approved etc. It would:-

  1. Read the value in the assigned to field
  2. Break permission inheritance on the list item
  3. Assign the user in the assigned to field edit permissions to that item.
Paul Lucas
thank you for answer. the system:Workers (here Worker1) will go and create a form by filling specific parts.The form is invisible for other workers. One person from Group1 has to approve it (randomly or there is a time shift).Now the form is visible for all workers.Also in the form there is a "assigned to" field. The person from Group1 who did the approval (perhaps at the same time while he is doing approve operation) has to add a worker name(worker2) to assigned to field.Now Worker2 has edit right for only Workers1's form not for other forms.Can we do this with work flows without coding?
ephieste
Assume that Worker55 created a form and I approved it and assigned to Worker66. Now the form is visible for everyone because it is approved and also Worker66 has the edit right for Worker55' form (because assigned to: Worker55). I can delete Worker66 and write Worker77. Now Worker77 has edit permission for Worker55' form not Worker66. If I write Worker77 and Worker66 at the same time to "assigned to". Then both of them can edit Worker55' form.Do you get the situation?
ephieste
I created Group1 (approval list) via Versioning settings.
ephieste
Ok here is my summary. If a form is "approved", anyone can see it, but the only people that can edit the form are people in the assigned to field. Sound right?
Paul Lucas
yes you are right!
ephieste
+1  A: 

as Paul Lucas mentioned, you could do it using an ItemAdded and ItemUpdated event receiver and methods like these, with added exception handling

public override void ItemUpdated(SPItemEventProperties properties)
{
    base.ItemUpdated(properties);
    SPListItem item = properties.ListItem;
    SetRights(item, ((SPFieldUserValue)item["AssignedTo"]).User, SPRoleType.Reader);                     
}

private void SetRights(SPListItem item, SPPrincipal principal, SPRoleType role)
{
    SPRoleDefinition RoleDefinition = item.ParentList.ParentWeb.RoleDefinitions.GetByType(role);
    SPRoleAssignment RoleAssignment = new SPRoleAssignment(principal);
    RoleAssignment.RoleDefinitionBindings.Add(RoleDefinition);

    if (!item.HasUniqueRoleAssignments)
    {
        item.BreakRoleInheritance(true);
    }
    item.RoleAssignments.Add(RoleAssignment);
    item.SystemUpdate(false);
}
kerray
This is along the same lines that I was thinking. Based on the comments to my answer, this might need to be modified to take into account approval status (if approved then all users can read the item) and the fact that there may be more than one user in the assigned to field.
Paul Lucas
Thank you very much. Where and how can I use this code? Because I cannot reach the servers and/or use add-ons. I have to design the system via Share point designer. That's all I am allowed to do.
ephieste
well, then you're out of luck, because this would need to be in a dll class library, installed on the server - as is the case with almost anything in SP...
kerray
I tried to design it with Share Point Designer and I think I can do something with several work flows.
ephieste