Jan 24, 2009

Publish Major Versions & Declarative SharePoint Workflows

In general there are four start options for SharePoint workflows:

  • Start manual
  • Start when an item changed
  • Start when a new item is created
  • Start workflow to approve publishing a major version of an item

When you use Visual Studio workflows or the built-in MOSS Approval Workflow you have all options. But with declarative workflows like SharePoint Designer and Nintex Workflows you have only the first three options.

  • Start workflow to approve publishing a major version of an item

You can’t use declarative workflows to approve publishing a major version of an item. Lose that option can really hurts!

image

Take a look at the SharePoint object model

In the object model the DefaultContentApprovalWorkflowId property of the SPList contains the the id of the workflow association which should be started to publish a major version.

So we only need to find the association id of our declarative workflow and set the DefaultContentApprovalWorkflowId property – maybe with PowerShell?

Yes and No! This works until the association id will change. And it will change every time the workflow changes! Manual set the DefaultContentApprovalWorkflowId every time the workflow changes? Cumbersome!

The solution

Declarative workflows (xoml files) will be stores in a hidden document library. You can see the library in SharePoint Designer:

image 

Just let an event receiver do the work! Every time the workflow file changes get the new association id and set the DefaultContentApprovalWorkflowId of the target list.

PowerShell Implementation

Exemplarily I will show an implementation with PowerShell and PowerEventReceiver.

#workflow must be associated with the target list $workflowFileName = "Nintex Test.xoml"
$targetListTitle = "TestLib"

function ItemUpdated()
{

if($item.DisplayName -eq "$($workflowFileName).wfconfig")
{

$binFile = $item.File.OpenBinary() $wfConfig = [xml][System.Text.Encoding]::UTF8.GetString($binFile)

$baseId
= [Guid]$wfConfig.WorkflowConfig.Template.BaseID

$lib = $web.Lists[$targetListTitle]

$assoc = $lib.WorkflowAssociations.GetAssociationByBaseId($baseId)

$lib.DefaultApprovalWorkflowId = $assoc.Id $lib.Update()
}
}

image

  • Change $workflowFileName and $targetListTitle appropriately. The workflow should already be deployed on the target list. Manual start option must be activated for the workflow. You can find the file name of the workflow with help of SharePoint Designer or PowerShell.
  • Save the script and resave/republish the SPD/Nintex workflow.
  • Publish a major version of a document:

image

  • After entering a comment you’ll see the initiation form of your content approval workflow. In my case a beautiful Nintex Workflow, in other cases an ugly SharePoint Designer Workflow ;-)

image

  • Start

image

Now you can change the workflow without lose the content approval workflow.

29 comments:

John WHite said...

Hi

I'd love to use this, but the solution file is failing when I try to add it to my farm with "Object reference not set to an instance of an object".

Cheers

John White said...

Ignore the previous comment - I was being stupid. The account that I was using didn't have appropriate rights to SQL....

digital signature said...

A special thanks for this informative post. I definitely learned new stuff here I wasn't aware of !

iPhone 6 plus phone cases said...

In the past weeks, more and more rumors about iPhone 7 appeared all over the internet. This device is expected to be released in fall of this year, most likely sometime around September.

Xj Cheng said...

For added ascendancy over a time adjustment,a Microstella bend can be acclimated to replica watches acclimatize the antithesis caster on the central of the watch.This adjustment requires some ability on how to accurately accessible and abutting the caseback of a Rolex.Both methods are discussed below.A Rolex watch is a attribute of abundance to abounding people.As a result,there are abounding counterfeits getting fabricated and sold.Abounding humans are blind about the uses of the replica accoutrements afar from its accessible artful use.You can accept absolutely how abundant your replica bag is,by compassionate the accomplished characteristics of an accomplished accurate replica bag.A superior replica bag looks and feels like an accurate handbag.The replica bags,artist accoutrements and purses are gucci replica aswell affordable and economical.Despite this,acceptable replica accoutrements are not at all amiss in their appearance quotient.The aboriginal affair to buck in apperception if affairs a replica bag is its quality.There can be abounding stores,which try to advance in your duke bad superior replica accoutrements and absolve the auction on the base of the low amount of the bag.Don't you accept them!This is because accomplished superior defines chanel replica a acceptable replica bag and replica handbag.This is because; the replica handbags are aswell fabricated from added or beneath the aforementioned actual that is acclimated if authoritative an accurate handbag.So try and get your replica backpack from stores,which replica watches uk don't compromise,on the superior alone because of the low amount of such bags.

wei coco said...

A brace of affidavit cover accepting a new job in the gucci replica company, or architecture business communities in order to facilitate projects you ability be absorption on.The capital allotment of centralized networking is usually to plan with humans aboveboard so they advance assurance aloft you. It is a affiliation that will pay off in the best term. This agency that you can not act in a blitz to hermes replicaget some thing. The ambition is to understand who does what central the business and see how you bout for that mix. This centralized networking is able because you are accouterment the added affair with a affair and they are giving you something.Whatever the louis vuitton replica Purse alignment you are in, if you accept to pursue some affectionate of centralized networking, you accept to apperceive what you are searching to achieve.Remember that as you artifice the journey, accept the individuals to breitling replica contact, and the assignments you are accommodating to plan on. Even admitting it is a two-way partnership, you are in allegation of the accurate route you wish to take, so accept an agenda.There are abundant means of networking that can plan when activated to the adapted situation. Everything comes down to the ability of who you are aggravating to replica watches arrangement with and what you should accompany to the table. Business is absolutely a two way street and if organizations and individuals adjudge to affix with one another, it accept to be equally valuable.





Hug Day said...

happy hug day 2016
happy hug day 2016 Date SMS Messages Quotes
How Hug Day Is Celebrated
Happy hug day sms

dongdong said...

stephen curry shoes
canada goose jackets
michael kors outlet
michael kors uk
nike tn
babyliss flat iron
michael kors outlet
michael kors watches
coach outlet
polo ralph lauren outlet
michael kors outlet online
oakley sunglasses
reebok
nike air max
coach outlet online
coach outlet
burberry outlet
christian louboutin uk
reebok uk
michael kors outlet
coach factory outlet
christian louboutin uk
hermes belt
hollister co
versace
cartier glasses
pandora jewelry
fitflops shoes
louis vuitton outlet online
oakley store
valentino store
hollister sale
canada goose uk
coach outlet online
louis vuitton outlet
jordans shoes
coach outlet
kate spade outlet
toms shoes
armani exchange
20163.22wengdongdong

风骚达哥 said...

20160423 junda
air jordans
cheap oakley sunglasses
kate spade outlet
adidas stan smith
ray ban sunglasses
michael kors outlet
nike air max shoes
cheap omega watches
yeezy boost 350
michael kors outlet online
michael kors outlet online
nike free runs
air jordan uk
michael kors outlet online
pandora charms
ray ban outlet
calvin klein outlet
fitflops sale clearance
toms outlet
nike huarache white
sac longchamp
toms outlet
michael kors outlet clearance
bottega veneta outlet
armani watches
gucci handbags
nike blazer
oakley sunglasses
true religion jeans
cheap jordans
ray bans
hollister
bottega veneta handbags
jimmy choo outlet
oakley sunglasses
converse
prada outlet
reebok shoes
true religion
burberry outlet

Libin Huang said...

20160426libinferragamo outlet
pandora outlet
ferragamo shoes
nike air max
ferragamo shoes
hermes belt for sale
michael kors factory outlet
swarovski crystal
ferragamo shoes
michael kors outlet
louis vuitton handbags
louis vuitton handbags outlet
swarovski outlet
beats by dre
cazal outlet
mont blanc pens
longchamp solde
fitflops outlet
cartier sunglasses for men
michael kors outlet
louis vuitton outlet
swarovski crystal
cheap nfl jerseys
adidas outlet store
tory burch outlet
cheap oakley sunglasses
mulberry bags
rolex watches,rolex watches,swiss watches,watches for men,watches for women,omega watches,replica watches,rolex watches for sale,rolex replica,rolex watch,cartier watches,rolex submariner,fake rolex,rolex replica watches,replica rolex
oakley sunglasses
tory burch outlet
ray ban sunglasses
louis vuitton outlet
polo ralph lauren
michael kors uk
tiffany outlet

Yuanyuan Lin said...

7.14llllllyuan"timberland shoes"
"soccer jerseys wholesale"
"longchamp pliage"
"cheap oakley sunglasses"
"true religion jeans"
"louis vuitton pas cher"
"rolex orologi"
"christian louboutin shoes"
"michael kors clearance"
"cheap nba jerseys"
"oakley sunglasses wholesale"
"tory burch shoes"
"tory burch outlet"
"chicago blackhawks jerseys"
"longchamp outlet"
"omega watches"
"adidas trainers"
"cheap nike shoes"
"nike outlet store online"
"michael kors outlet clearance"
"michael kors uk"
"montblanc pens"
"michael kors canada"
"longchamp handbags"
"ray ban sunglasses"
"abercrombie and fitch"
"mcm outlet"
"puma shoes"
"ralph lauren uk"
"nike air max 90"
"rolex watches,rolex watches,swiss watches,watches for men,watches for women,omega watches,replica watches,rolex watches for sale,rolex replica,rolex watch,cartier watches,rolex submariner,fake rolex,rolex replica watches,replica rolex"
"mulberry outlet"
"air max 90"
"ferragamo outlet"
"christian louboutin outlet"
7.14

marko said...

Ci sono un gran numero di casa cresciuto pillole come out a disposizione in modo tale che il tentativo ognuno di loro potrebbe essere meticolosamente lungo e di essere un cattivo uso di denaro contante. curare l'impotenza a 20 anni

Fangyaya said...

louis vuitton handbags
tory burch shoes
adidas trainers
christian louboutin sneakers
nike roshe flyknit
louis vuitton handbags
toms wedges
concord 11
asics shoes for women
oakley outlet
coach outlet
adidas shoes
basketball shoes
michael kors outlet
michael kors outlet
christian louboutin outlet
michael kors outlet
jordan shoes
kate spade outlet
coach outlet online
coach outlet store
beats by dre
oakley vault
celine outlet
michael kors outlet online
ray ban sunglasses outlet
jordan concords
michael kors outlet online
gucci outlet online
christian louboutin sale
toms wedges
abercrombie clothing
michael kors outlet online
toms outlet
rolex watches
red bottom shoes
celine handbags
michael kors outlet online
abercrombie & fitch outlet
louis vuitton purses
20168.8chenjinyan

Justin said...

You are not ready to spare cost when you solidify both sorts of credits together. You are not permitted to claim enthusiasm as an expense conclusion on a private credit solidification. payday loans chicago

Justin said...

Government association considers their monetary circumstances and concoct a remarkable choice under thought. Thus, on the off chance that you are an understudy with terrible financials furthermore don't have a high review in the past stages, try not to be annoyed with that, somewhat, you ought to search for the extra insights about the credits and discover what offers and alternatives are accessible for you. Payday Loans

dada24 Xu said...

toms shoes outlet
ugg outlet
celine outlet store
red bottoms
moncler jackets
adidas nmd
longchamp bags
cheap jordans
ugg outlet
christian louboutin shoes
2016921caiyan

chenlina said...

chenlina20160923
gucci handbags
gucci outlet
ray ban sunglasses
toms shoes
clarisonic
kate spade
ugg boots
oakley sunglasses
ed hardy clothing
louis vuitton outlet

John said...

air force 1
birkenstock outlet
ugg sale
fitflops sale
michael kors outlet store
canada goose jackets
nike uk
converse all star
ralph lauren outlet online
coach outlet online
birkenstock outlet
abercrombie
polo ralph lauren outlet
adidas nmd r1
mcm outlet online
coach outlet online
timberland boots outlet
ed hardy store
true religion jeans outlet
nike cortez classic
timberland shoes
louis vuitton outlet online
birkenstock sale
louboutin outlet
michael kors handbags outlet
uggs sale
birkin handbags
rolex watches for sale
michael kors outlet store
vans outlet
polo ralph lauren outlet online
20161102yuanyuan

Outlet Wade said...

fitflop outlet
http://www.adidasnmdshoesoutlet.com
cheap ray bans
ray ban sunglasses
oakley sunglasses
ray ban outlet
cheap oakley sunglasses
Michael Kors Sunglasses
oakley outlet
http://www.sunglassshopinc.com
Lebron James Jerseys
Stephen Curry Jerseys
Kevin Durant Jerseys
Kyrie Irving Jerseys
Russell Westbrook Jerseys
Klay Thompson Jerseys
James Harden Jerseys
Derrick Rose Jerseys
Jimmy Butler Jerseys
Paul George Jerseys
Carmelo Anthony Jerseys
Chris Paul Jerseys
Golden State Warriors Jerseys
Kobe Bryant Jerseys
Ben Simmons Jerseys
Joel Embiid Jerseys

Meiqing Xu said...

pandora uk
true religion jeans
michael kors handbags
adidas nmd
true religion jeans
ugg australia
birkenstock shoes
michael kors canada
pandora bracelet
ray ban sunglasses
20161221caiyan

chenmeinv0 said...

christian louboutin
ray ban sunglasses
christian louboutin paris
air jordans
cheap rolex watches
pandora jewelry
adidas originals uk
chanel bags
coach outlet
ray ban wayfarer
hzx20170228

cara menggugurkan kandungan said...

This blog is so nice to me. I will continue to come here again and again. Visit my link as well. Good luck
http://www.jualobataborsiherbal.com/ obat aborsi
http://caramenggugurkankandungan.info/ cara menggugurkan kandungan
http://obataborsi59.com/ obat aborsi
http://obataborsi59.com/cara-menggugurkan-kandungan-dengan-cepat-dan-aman/ cara menggugurkan kandungan
http://obattelatdatangbulan.info/ obat telat datang bulan
http://klinikobataborsi.com/ jual obat aborsi
http://jualobatpenggugurkandungan.net/ obat penggugur kandungan
http://tandatandakehamilan.net/ tanda tanda kehamilan
http://tandatandakehamilan.net/cara-cepat-dan-selamat-menggugurkan-kandungan/ cara menggugurkan kandungan

Elite Delhi Escorts said...
This comment has been removed by the author.
Elite Delhi Escorts said...

Elite Delhi Escorts agency committed to providing clients with gorgeous Call Girls in Delhi and unforgettable experiences.

huali10 Cai said...

rolex watches for sale
louis vuitton
cheap jordans for sale
air max 90
longchamp outlet
nike outlet store online
tory burch outlet online
futbol baratas
cheap oakley sunglasses
michael kors outlet clearance
qqqqqing20170411

Unknown said...

cartier outlet
fitflops sale clearance
sac louis vuitton pas cher
longchamp outlet online
mulberry uk
thomas sabo charms
cheap oakley sunglasses
cheap nike shoes
ray-ban sunglasses
ralph lauren
chanyuan2017.05.08

dong dong23 said...

mbt clearance
pandora bracelet
reebok sneakers
oakley sunglasses discount
ray ban eyeglasses
michael kors tote bags
lebron 11 shoes
coach outlet store online
ralph lauren shirts
cheap jordan sneakers
2017.5.11chenlixiang

chenlina said...

ralph lauren uk
canada goose outlet store
coach outlet online
michael kors outlet online
adidas yeezy shoes
oakley sunglasses
michael kors outlet
mbt shoes clearance outlet
true religion outlet online
michael kors outlet
20170719wanglili

raybanoutlet001 said...

toms shoes
nike huarache
valentino outlet
ed hardy
michael kors handbags
fitflops
mont blanc outlet
atlanta falcons jerseys
nike air max 90
nike huarache