Loading

Document based workflow approvers

In this post I'm going to share with you my experience with overriding workflow approvers and make them configurable on the document level.

Recently I've got the request from one of my client to build assets management system with Kentico CMS. One of the main features of that system is workflow. There are sections of the site, those have to be approved by different approvers, which are nothing special, so I suggested them to build a workflow per section and assign appropriate approvers to it. Customer kindly rejected my suggestion, as they were planning to maintain thousands (if not hundreds of thousands) pages within the site, so there were too many section. Also sections were too small - sometimes that was single document.

The best solution in this scenario was to allow customer to setup approvers on the document level. 

Add fields for approvers to a page type

First thing I had to do was adding appropriate fields to the page type. In my case there were around 10 page types, but luckily, all they inherit the same base page type. Inheritance with page types is as much useful as it is with regular C# classes, so do not hesitate to use it whenever applicable.

In order to accomplish this task, navigate Page Types application, find appropriate page type and open edit scree for it. Go to Fields tab and add new field. Use following setting for your field:

 


Data type: text

Size: 200 or any other reasonable number in your particular case

Form control: Uni selector

Object type: cms.user

Return column name: username

Selection mode: Multiple

 

Feel free to configure the rest of the fields according to your needs.

There is one good reason to use object code name or GUID instead of object ID: if you're running synchronization using content staging, you don't have to implement object ID translation. You can find more details about translation here.

Add another field with the same settings, except object type - set it to cms.role.

Those two fields allow you to add users or roles, those should approve document, on the Form tab of particular document.

Override workflow permissions

Next step is to authorize those users to perform an action on a document. This requires overriding of workflow security. So now we need to implement custom WorkflowManager class and override CheckStepPermissionsInternal:

 


[assembly: RegisterCustomManager(typeof(CustomWorkflowManager))]
public class CustomWorkflowManager : WorkflowManager
{
    protected override bool CheckStepPermissionsInternal(TreeNode node, UserInfo user, WorkflowActionEnum action)
    {
        if (action == WorkflowActionEnum.Approve)
        {
            // get users allowed to approve from the document
            var users = node.GetStringValue(<usersField>, "").Split(';').ToList();
            approvers.AddRange(UserInfoProvider.GetUsers().Where(u => users.Contains(u.UserID.ToString())));
            if (approvers.Contains(user))
            {
                return true;
            }    
            
            // get roles allowed to approve document
            var roles = document.GetStringValue(<rolesField>, "").Split(';').ToList();            
            foreach (string role in roles)
            {
                if (user.IsInRole(role, currentSiteName))
                {
                    return true;
                }
            }
        }

        return base.CheckStepPermissionsInternal(node, user, action);
    }
}

 

As you can see, document, user and workflow actions are available in this method and this is all what you need in order to figure out whether current user is in approvers list or not. In my code I'm reading appropriate fields of the document in order to get approving users and roles and checking whether current user is in one of those lists. Pay attention to the last line of the method: if user is not in those lists of approvers, I'm running default check, so I'm not screwing up default Kentico permission check. Be sure to add validation to this method in case you are going to reuse it - code above is not final and was implemented only in demo purposes.

Conclusion

To summarize this article I want to admit that we went through using Uni Selector control, mentioned foreign key translation while staging and overridden default Kentico WorkflowManager class. All this allowed us to override the way Kentico handles workflow and gave us possibility to configure approvers for workflow on document level, which enables us to reuse the same workflow with different sets of approvers.

PLease feel free to share your experience with the related topic or ask your questions if any.


Comments
cialis
Viagra, four for and one for Levitra, said spokeswoman Susan Cruzan.
2/21/2018 10:16:06 AM

https://www.stclairphysioclinic.com/
I see the article on your web very good and interesting ,, do not forget visit also my web
2/18/2018 6:22:29 AM

hotmail.com sign in
hotmail.com sign in Hello, want to know how to login into hotmail.com sign in and Hotmail login are you excited to read this article
2/1/2018 12:24:38 PM

wifikill for windows
Good and Awesome very informative thank you for sharing
1/27/2018 5:53:49 AM

Netflix Login
Netflix.com manages to attract millions of consumers who use it to stream online media. The reason is the on-demand access to one’s favorite movies, TV shows, music, etc. All one needs is an active internet connection on a device like a smartphone, tablet, laptop, desktop or smart TVs. Well,
1/25/2018 10:13:12 AM

tinymoviez
Thanks alot for your website............
1/21/2018 3:55:44 AM

tinymovies
Thanks alot for your website.....
<p><a href="http://tiny-movies.ir">دانلود فيلم </a></p>
<p><a href="http://tiny-movies.ir"> دانلود فيلم ايراني</a></p>
<p><a href="http://tiny-movies.ir">tinymovies</a></p>
<p><a href="http://tiny-movies.ir">tinymoviez </a></p>
<p><a href="http://tiny-movies.ir">تايني موويز</a></p>
1/21/2018 3:53:20 AM

Professor Hoopoe
Professor approves this post :)
1/4/2018 11:32:48 AM

gold rate today
Today Gold Rate, it only accounted for 4.5% of their revenues. Thus, Barrick and newmont’s free caash flow shows that it costs more to produce gold than it was shown in
1/4/2018 6:52:02 AM

videoder download
A couple of years back, at whatever point we used to be exhausted, TV and radios were the wellsprings of amusement
1/3/2018 7:00:48 AM

abcya game
abcya game Are you looking for the best Kids games from ABCYA? Then you are at the right place
12/29/2017 9:44:46 AM

192.168.1.254 login password
Don’t worry! Here we will be shedding light over the entire setup process of the dlink router set up. So here we go.
12/28/2017 11:08:54 AM

january 2018 Calendar Excel
you are looking for best designs for January 2018 Calendar USA in MS-Word, Excel, or PDF format, you have reached the right place; here we have provided you with calendars in several forms.
12/28/2017 8:06:54 AM

192.168.1.254 login password
192.168.1.254 is an IP address utilized by switches of specific models to distinguish themselves on the system.
12/28/2017 7:26:47 AM

recover yahoo mail password
Can’t enter your own particular Yahoo account because of a secret key blunder?
12/18/2017 10:33:56 AM

happy new year 2018 wallpapers
No more work and no more stresses in light of the fact that New Year 2018 is advancing toward enter our lives.
12/15/2017 6:13:52 AM

mobogenie pc
In addition bring down end Pc/Laptop because of similarity issues i.e Pc’s without realistic card or Laptop with 1gb smash can’t download and introduce bluestacks
12/11/2017 8:54:52 AM

Happy New Year 2018 sayings
gards . A man may learn wisdom even from a foe. by Aristophanes.
12/6/2017 10:58:39 AM

whatsapp plus download
The entire smartphone user knows that WhatsApp is a best messaging app which you ever get for your Smartphone.
11/30/2017 10:33:40 AM

happy new year 2018
Eve event that is arranged by the star programs in association with the New York five-star hotels, the music group, and popular nightclub NYC and all the globally popular stars are there in one event. For dance and fun, the environment is breath-taking
11/30/2017 7:32:47 AM

hair extensions london
while the bud on hair extensions london the side of the bud shape is also full of cute
11/10/2017 1:51:01 AM

aho
Nafi Er wigs ponytail, this is uk hair extensions a short hair after the popular, but also in human hair extensions the short hair behind a little hair, so that cheap hair extensions your hair will have a Variety of feeling, this depends on remy hair extensions your own hair color Is what to choose the appropriate hair color.
11/2/2017 1:30:45 AM

waqar mazhar
good post
10/31/2017 4:29:44 PM

jam topics
The Jam sessions vary depending on the recruiting companies and the sessions are organized before or after the written test to eliminate the number of the candidates
10/30/2017 9:53:15 AM

Vaginal Tightening Cream
After pregnancy, maximum of the ladies experience free vagina that sooner or later produces dull sex existence. To repair the vagina to its preceding tightness, maximum of the women choose the surgical procedures and other treatments.
10/24/2017 10:18:39 AM

download MegaBox HD
MegaBox HD apk is the latest one application to watch the movies and TV Shows on the smartphone and the Android devices.
10/20/2017 7:14:33 AM

WhatsApp For iPad Download 2017 Version
Whatsapp messenger is a very popular app actively used by over a billion people already. The application allows the users to send text and audio messages to a group of friends and family besides sending them to the individuals.
10/9/2017 4:53:01 AM

Best Android Vpn
Psiphon VPN is the most lovable and interesting VPN supplier available. Be that as it may, in spite of their amusing methodology, Psiphon VPN considers your security important.
10/5/2017 11:21:25 AM

8 ball pool cheats
8 Ball pool game is the most favorite game for almost all the game lovers.
9/13/2017 9:10:13 AM

Lucky Pature for android
Lucky Patcher Apk is a great App that can modify your installed Apps and games on your phone. If you want to change the behavior of your App and games by removing Adds and license, then Lucky Patcher can be a great option.
8/21/2017 5:08:36 AM

mobdro not working
This error will only come to your screen if your Android phone is less than 4.1 because Mobdro app only supports to those android phone more the 4.1 android version.
8/10/2017 8:53:05 AM

wifikill for pc
If you are having rooted Android device then you may be familiar with the app named as Wifikill, which will be allowing you to drop the connection of other wifi users.
7/25/2017 9:52:45 AM

darkwebsites.org/
Whenever you don’t have an idea about something, you would like to search in web browser i.e Google or any other browser
7/23/2017 5:32:23 AM

download psiphon
Internet has become the one stop solution for all our problems and needs. From news to entertainment, you can get it all on the internet. For every type of requirements, there’s an array of websites present. Social media websites are becoming popular at a tremendous rate. Y
7/19/2017 6:04:55 AM

download whatsapp plus
Download Whatsapp Plus Latest App / Apk for Android Phones No Root Needed.WhatsApp plus Apk download for non rooted android receivers
7/12/2017 9:45:56 AM

whatsapp for pc
These informing stages are outstanding to be proficient on your PCs, similar to this is the situation for WhatsApp for PC.
7/10/2017 11:57:25 AM

Car auto
It is best to concentrate on what you think you are better at , then outsource the rest. You get more benefits in the process
7/10/2017 5:58:47 AM

whatsapp plus download
Obviously you caught wind of WhatsApp Plus, I won't drag out you clarify, WhatsApp Plus is an adjusted form of WhatsApp have an excessive number of superb components, and non-existent in WhatsApp,
7/7/2017 4:35:37 AM

mobogenie pc
In this fast-paced world, it is necessary for you to keep up to date with the newest, fastest technological advancements.
7/5/2017 8:53:32 AM

mobogenie pc
In this fast-paced world, it is necessary for you to keep up to date with the newest, fastest technological advancements.
7/5/2017 8:53:31 AM

kingroot apk download
It seems to Root your device has become more important because when you take your phone out of the box, while there are plenty of settings you can adjust and you can only alter what the manufacturer allows you to do.
6/29/2017 10:03:32 AM

videoder apk download
Videoder App is a video downloading application that gets the videos to download in different pixels which include 1080, 720p, 480p, 360p, 240p, 144p, mp4 and mp3, more.
6/24/2017 9:32:38 AM

kopi rolex
asdaafasas
5/26/2017 8:35:17 AM

hot sale replica watches
Out of work, party, you may need a watch to reflect your temperament and vision, to show you different from the general taste and vision. Here to meet your needs. thank.
5/16/2017 1:59:34 AM

hot sale replica watches
Out of work, party, you may need a watch to reflect your temperament and vision, to show you different from the general taste and vision. Here to meet your needs. thank.
5/12/2017 8:34:38 AM

nike shoes
Great Article it its really informative and innovative keep us posted with new updates. its was

reallyvaluable. thanks a lot.
5/8/2017 8:42:06 AM

Joseph
Id forever want to be update on new articles on this internet site, bookmarked ! .
1/25/2017 9:14:37 AM

James
Hey very nice site!! Man .. Beautiful .. Amazing .. I will bookmark your blog and take the feeds alsoI am happy to find a lot of useful info here in the post, we need work out more techniques in this regard, thanks for sharing. . . . . .
12/2/2016 12:00:13 PM

Daniel
Enjoyed studying this, very good stuff, regards . A man may learn wisdom even from a foe. by Aristophanes.
10/26/2016 7:32:19 AM

David
Very neat article post.Much thanks again. Much obliged.
9/21/2016 5:17:24 PM

 Security code