Skip to main content

Hello,

I have a folder defined in a SharePoint 2010 Documnent Library with custom permissions. On this folder the group "Legal" has SP permissions "Contribute" and "Approve".
A workflow is launched when a new document is created in the document library. One a server event I would like to affect a datafield to the group who has permissions on the document's folder. (Legal in this case)

To summarize, here is the scenario :
- A document is created in a folder on a document library.
- The folder has specific permission
- A server event affect a datafield with the SP group from the folder permissions.
- Then, a task have the data field as destination user affected

How is it possible to get folder permissions from a Server Event and affect the group to a datafield ?

Thanks in advance for your help.

Hi,


I've just checked the K2 wizards and there is no method for obtaining permissions from SharePoint. You can set permissions but not retrieve the ones set by someone else in SharePoint.


One suggestion that I have is that you set the permissions on the folder using a K2 process and then save the usernames/groups you are assigning permissions to and use these users/groups later on in your process as destinations. I admit that might not be possible in your scenario.


It looks like you will need to write some code which connects to SharePoint (probably through a web service on SharePoint) to get a list of the permissions. I see that there is a web service that K2 installs on SharePoint which might do this. The web service is called K2SPPermissions.asmx and it has a GetPermissions() method. It should be possible to leverage this web service from your process to get the permissions and then store the returned collection as XML in a Process-level XML Field. I'm not sure how the support is on this web service so use at own risk. I also don't see any documentation, but it looks like it takes a SharePoint Object, ListID and ListItemID as input parameters.


Hope this helps!


Hi JohanL,


Thank you very much for your answer.


In fact I did a trick in another way, still using the K2SPServices webservices. In fact, I created a custom folder content type with a new column called Topic Owner. When creating this kind of folder, a workflow manage permissions to assign the new folder permissions to the topic owner. This works fine in my scenario. Then I used this code to get the topic owner from the metadata and finally store it in my data fields. This code bellow maybe helps to understand te trick.



XmlDocument



 



 



xml = new XmlDocument();


xml.LoadXml(K2.ProcessInstance.XmlFieldsd"WFIProcessField"].Value);

 



 



XmlNodeList nodes = xml.SelectNodes("/Items/Item");

 



 



if (nodes.Count > 0)

{



 



 



XmlNode xn = nodes.Item(0);

 



 



string listURL = xns"ListURL"].InnerText;

 



 



string folderURL = xnl"FolderURL"].InnerText;

 



 



string siteURL = xn>"SiteURL"].InnerText;

 



 



K2SPDocumentLibraries docs = new K2SPDocumentLibraries();

docs.Url =



 



new K2Uri(siteURL).FormatURI(true) + "_vti_bin/K2SPDocumentLibraries.ASMX";

 



 



ADCredentials directoryCredential = new ADCredentials();

docs.Credentials = directoryCredential.GetCredentials(docs.Url);



 



 



string topicFolderURL = siteURL + "/" + listURL + "/" + folderURL.Substring(0, folderURL.IndexOf('/'));

 



 



if (docs.FolderExist(topicFolderURL))

{



 



 



K2SPField/] folderFields = docs.GetFolderMetaData(listURL, folderURL, true);

 



 



foreach (K2SPField aField in folderFields)

{



 



 



if(aField.Title.Equals("Topic Owner"))

{



K2.ProcessInstance.DataFieldsK



 



"Topic Owner"].Value = "K2:" + aField.Value;

}


}


}


}



K2.ProcessInstance.DataFields>



 



"Topic Owner"].Value = "ERROR Topic Owner !";

 



 




I also tried using the K2SPPermission service, but it seems that the permissions getting from are for the connected account, which of course is the K2 Service Account. I tried changing the Credentials properties but without success. Moreover, I found that the GetPermission method is returning the SP permissions (read, write, approve, ...), but not the groups or users. Not helpfull for me.


Thanks again !


Reply