Skip to main content

I am after ideas on the best way to achieve the following:

I have a document which goes through an approval process. When the document is approved, it is moved to a document library.
Depending on some values which are collected as part of the process, I want to query a database, and retrieve all of the groups/users that should have read permissions on the document, and then give these users read permissions on the document in the document library.

The bit that I am not sure how to achieve is actually setting the permissions on the document - I know this can be done from a user management activity by adding the user to the item, and then giving permissions, but how can I get it to do this for each of the records that is returned from the database?

Thanks in advance for any assistance on this!! 

Hi Arduk,


Unfortunately there is no easy way of doing this in the current version of K2 blackpearl (807 KB000370). You should however be able to do this with the relatively easy workaround below.


If  you are retrieving the users using a SmartBox SmartObject you could do the following :



  • Set the destination rule(Advanced Mode) of the activity where the UserManagement event is located to "Plan per slot (No Destinations)" and drag the "gUserName]" property into the "Select a List Field to determine how many slots should be created" Textbox
  • This will then create an instance of the Activity for each of the results returned by the GetList
  • Then you can use the "InstanceData" value of the "Activity Destination Instance" in the K2 Object Browser which will contain the UserName and can then be used in the UserManagement event as the user to assign the rights to

If the users are located in a custom SQL Database you could use the Dynamic SQL service to create a SmartObject returning the values and using it in the same way as described.


Hope this helps.


Kind Regards,


Gert


 


Hi Gert,

Thanks very much for getting back to me. Unfortunately I am not using smart objects, so I am not sure if your idea will work - I am using a code event to load the data into a repeating xml field set up as follows:
<issuedDocPermissions>
  <readers>
    <reader> (this node is repeating, and into this I am loading the group or username that should be given read access.

I thought your idea may work for this anyway, but I set it up as you described, dragging the <reader> field onto the "Select a list field to determine how many slots should be created" text box.
I was unable to drag the "InstanceData" field onto the text box where you assign rights to - it doesn't let me drop the field in there. I tried browsing, and selected "Destination Users", and was able to assign this OK.
The event never fires though - an error is thrown saying something along the lines of "There are multiple root nodes" (sorry - I accidentally deleted the error...). After getting this error, I tried dropping the "<readers>" xml field onto the "Select a list field to determine how many slots should be created" text box., instead of the "<reader>" node, but it doesn't let me drop this field in...

Any other ideas on how this can be achieved.

Thanks in advance


Hi Arduk,


I just found out that there is a know issue in 807 KB000370 where you are unable to drag K2 Context DataFields into some of the TextBoxes in the K2 Event Wizards. This will be fixed in the Next Major release of K2.


You should still be able to work past this issue by simply assigning the "InstanceData" value to a new Datafield and dragging the DataField into the Textbox where you assign the rights. Unfortunately you would need to assign this value in a server event using the sample code below :


K2.ProcessInstace.DataFieldss"InstanceData"].Value = K2.ActivityInstanceDestination.InstanceData;


Please let me know how this goes.


Regards,


Gert


I think that the issue that I am running into here is actually that you can't assign permissions to both sharepoint groups and AD groups using this method, and this was something that I was looking to do.

I have changed methods now, and am now using only AD groups. I am loading the AD groups into an XML process field, and for each node in the XML field, I am looping back over the user management event. This seems to be working, but it is frustrating that I can't use this to assign permissions to both AD groups and Sharepoint groups....

I'll just have to add this "feature" to my bag of tricks for next time I run into it...

Thanks very much for your help on this - I appreciate you taking the time to get back to me!

Reply