Friday, May 29, 2015

How To Create Work Flow for ContentType in sharepoint 2013

Hai we Know that For Sharepoint 2010 we have reusable work flows with witch we can create work flows for specific content types but this awesome feature is removed in sharepoint 2013

but i got a task to update id according to the content type

for example if i had 3 content types tendercreation,quote request , information request

when a user opt for tender creation he should have the id as T-1-2015


here T is for tender creation content type

1 is serial number

2015 is year


lest see how i created

and to create new column we sholud go to library->library settings->create column like this:


now i created a column called next for getting row number from default column [ID] and added fromula [ID]+1 but i got some problem i didnt get [ID] directly so i used work flow to assign [ID] to a columnt called nextid Like this

and now i created a calculated column as said above naming next like this
and created other column for getting year like this

so now i got my id almost but have to get the type according to content type here is the big task
in sharepoint 2013 they removed tar-getting to specific content type so i created a new column again called ttype and wrote a work flow like this to get the desired result
this work flow is not reusable work flow i created list workflow because in reusable work flow im not getting content typeid insted im only getting content type

and here you may notice that at the top of the work flow i created a Ctype workflow variable which is of string datatype because if i didnt create this while passing contenttype id im getting error :

Exception: RequestorId: 2d2c973d-36a2-a2e5-c3f3-5cd009206e97. Details: System.InvalidCastException: The value 'd/results(0)/ContentType' cannot be read as type 'String'. at Microsoft.Activities.GetDynamicValueProperty`1.CheckedRead(String propertyName, DynamicItem value) at Microsoft.Activities.GetDynamicValueProperty`1.Execute(CodeActivityContext context) at System.Activities.CodeActivity`1.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager) at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)


so by creating work flow variable and sending this contenttype to that will solve the problem
now i created another calculated column 


now my final output is like this


keep coding :)









No comments:

Post a Comment