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
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

mobdro for ios
In our everyday life, we love to get entertained in the middle of our work by watching movies, TV shows, and some sports, so that we can lower our stress a little bit.
10/9/2017 9:03:55 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

Custom Essay Writing Servies
Great article. Thanks for this. This is one of the example of an delighted articles.
10/7/2017 3:28:08 PM

vidmate iphone
Vidmate is one of the trendiest streamer and downloading app through which you can either stream any videos, movies or TV shows online
10/6/2017 6:36:00 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

uktvnow tv
NICE CONTENT................<a href="https://uktvnowapks.com/">uktvnow tv</a>
9/30/2017 4:28:19 AM

itube iphone
iTube was discharged with the name Playtube and offered some restricted components. At that point the designers every minute of every day Apps Ltd.
9/25/2017 9:21:03 AM

tubemate iphone
One the main problem that most of the people are facing is that for downloading YouTube videos we just can’t download YouTube videos without any downloader.
9/21/2017 11:55:49 AM

csdfdsf
PANDORA bracelet can be their own combination, the bracelet on the chain and the chain is used to separate the chain,<a href="http://www.pandoramagic.co.uk/">rose gold</a> and then string together. You can first visit the official website model <a href="http://www.pandoracharmscheap.co.uk/category/pandora-gold-and-silver-jewelry/">pandora limited edition charms 2017</a> and then to the store to buy, decorated with gold, silver, glass, enamel and other materials of different shapes,bracelets have gold, silver, fabric, <a href="http://www.cheappandorastore.co.uk/">pandora blue flower charm </a>leather and other materials can choose.
9/14/2017 7:07: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

TEATV
NICE POST..........<a href="https://teatvappdownload.com/">teatv</a>
8/31/2017 2:54:21 AM

download Fildo
good offline setting: Tap the major menu button, after that toggle Fildo Music App chance that you currently recognize how to download nice.
<a href="https://fildoappdownload.com/">download Fildo</a>
8/29/2017 3:54:40 PM

aptoide apk latest version
cross check the system demands for your Android device and aptoide apk and after install and download apk
<a href="http://aptoideappdownload.com/2016/06/aptoide-apk-download-for-android-and-pc.html">aptoide apk latest version</a>
8/29/2017 6:26:42 AM

Fildo APK Download
good out information below as well as go to download and install Fildo App Prior to March, the markets were extra siloed Android nice.
<a href="https://fildoappdownload.com/">Fildo APK Download</a>
8/29/2017 6:25:43 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

seo companies melbourne
A clever fusion of industrial and European style, ISEO, a boutique apartment block situated on Lygon Street, provides a nod to Melbourne's.
8/11/2017 12:19:22 PM

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

Mobogenie iphone
With the advent of smartphones and internet, downloads have shot up like crazy. Whether you are a preferred iOS user, or an Android user, or even a Windows user, the app market for every platform is expanding their bases day by day.
8/5/2017 10:17:08 AM

csdfdsf
<a href=http://www.rblunettessoleil.fr/>ray ban round </a>
7/27/2017 1:42:27 PM

csdfdsf
PANDORA bracelet can be their own combination, the bracelet on the chain and the[url=http://www.bjcharms.co.uk]gold bird [/url] chain is used to separate the chain, and then string together. You can first visit the official website model  and then to the store to buy[url=http://www.onlinepandorasale.co.uk/category/pandora-disney-series-of-jewelry]pandora mickey earrings[/url], decorated with gold, silver, glass, enamel and other materials of different shapes,bracelets have gold, silver, fabric, [url=http://www.cheapjewelryonline.co.uk/category/Authentic pandora charm discount for sale]cheap Alphabet & Number Charms [/url]leather and other materials can choose.
7/27/2017 1:41:10 PM

Financial Modelling Online
Thousands of teenagers across the UK will have school lessons in mindfulness in an experiment designed to see if it can protect against mental illness.
7/27/2017 6:27:24 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

Seo training Hyderabad
Learn professional digital marketing course/training in Hyderabad and upgrade your career by taking SEO/SMM/SEM/Adwords certification training
7/21/2017 11:45:38 AM

Accounts Training Online
All courses are delivered only by top trainers, training institutes and professionals with decades of teaching experience, helping thousands of learners advance their career.
7/19/2017 7:25:37 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

Essay typer
I enjoyed reading your posts. Thanks for constructing useful/quality pieces
7/8/2017 9:53:07 PM

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

cheap pandora
Great Article it its really informative and innovative keep us posted with new updates. its was reallyvaluable. thanks a lot.<a href="http://www.buycharms.cn/">Cheap Pandora Sale</a> very good.
6/12/2017 9:02:07 AM

replica watch
[url=http://www.replicasrelojes.cn/]Replicas De Relojes[/url]
6/2/2017 3:27:30 AM

kopi rolex
Det finns ett brett utbud av [url=http://www.kopiurevip.com/]kopi rolex[/url]
5/31/2017 3:11:58 AM

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

kopi rolex
Det finns ett brett utbud av [url=http://www.kopiurevip.com/]kopi rolex[/url]
<a href="http://www.kopiurevip.com/">kopi rolex</a>
5/26/2017 2:32:18 AM

online
RSS puns feeds cialis pills for sale and intrusive sucidial thoughts.
5/22/2017 1:04:32 PM

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

hot sale replica watches
Both cheap and gorgeous fine imitation watches;<a href="http://www.uamoevent.com/">imitatie rolex horloges</a> filling your success style!
5/8/2017 7:20:27 AM

nike air max
Ultra-cool Nike running shoes[url=http://www.homesgb.co.uk/]air max 1[/url]
Have this running shoes you can go to the peak of life
Your fate is destined to need such a running shoes
5/8/2017 3:30:38 AM

nike air max
Ultra-cool Nike running shoes<a href="http://www.homesgb.co.uk/">air max 1</a>
Have this running shoes you can go to the peak of life
Your fate is destined to need such a running shoes
5/8/2017 3:27:33 AM

nike air max
Ultra-cool Nike running shoes[url=http://www.homesgb.co.uk/]nike air max 1[/url]
Have this running shoes you can go to the peak of life
Your fate is destined to need such a running shoes
5/6/2017 8:18:57 AM

nike air max
Ultra-cool Nike running shoes<a href="http://www.homesgb.co.uk/">nike air force 1</a>
Have this running shoes you can go to the peak of life
Your fate is destined to need such a running shoes
5/6/2017 8:17:09 AM

essaychief.com
Actually my current assignment have some important questions related to overriding workflow and now i got the answers of these questions with the help of this article. I would like to say Thanks for this impressive effort which done by the author of this article. I'm happy to come this site to have good piece of information.
5/2/2017 1:35:17 PM

Pharmg839
Very nice site! <a href="http://ypxoiea.com/ovyvorv/1.html">cheap viagra</a>
3/22/2017 4:21:11 PM

Pharma575
Hello! edkfbak interesting edkfbak site! I'm really like it! Very, very edkfbak good!
3/22/2017 4:20:49 PM

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