Creating a workflow task generates an "Invalid field name" error - sharepoint

I have a custom (code-based) workflow, deployed in WSS via features in a .wsp file. The workflow is configured with a custom task content type (ie, the Workflow element contains a TaskListContentTypeId attribute). This content type's declaration contains a FormUrls element pointing to a custom task edit page.
When the workflow attempts to create a task, the workflow throws this exception:
Invalid field name. {17ca3a22-fdfe-46eb-99b5-9646baed3f16
This is the ID of the FormURN site column. I thought FormURN is only used for InfoPath forms, not regular aspx forms...
Does anyone have any idea how to solve this, so I can create tasks in my workflow?

Are you using the CreateTaskWithContentTypeId activity in your workflow? If you are then you need to ensure that the content types have been added to the Workflow Tasks list. SharePoint will not add them automatically.
Oisin

It turns out that I was missing two things:
My custom content type neeeded to be
added to the workflow task list
I needed to add an empty FieldRefs element to my content type definition; without it, the content type wasn't inheriting any workflow task fields.

Related

SharePoint Online Designer 2013 workflow, terminated on autostart

In SharePoint Online, I have a SharePoint Designer 2013 List workflow. The workflow can be started manually without any problems (I am starting it on a custom Documentset content type called "ServiceOrder").
When I set the workflow to start automatically when a "ServiceOrder" content-type item is created. The workflow terminates instantly.
Details: The values provided for the root activity's arguments did not satisfy the root
activity's requirements: 'DynamicActivity': Expected an input parameter value of type
'System.String' for parameter named 'UniqueId'. Parameter name: rootArgumentValues
I have created another simple workflow just to check if's able to start automatically, and the new simple workflow does start automatically.
Finally I understood what the error was.
I have created a variable named "UniqueId", which represents the items UniqueId (Guid). I'm using this variable in a REST call to "GetFolderById".
After I changed that variable name to UniqueGUID, everything worked.
Seemed like a reserved variablename needed to initiate some Azure automation etc.

SharePoint 2013 TaxonomyFieldType in custom list has IsTermSetValid = False

I'm using Visual Studio 2012 to create a custom Site Column of type TaxonomyFieldType, a custom content type that uses it, and a custom list that uses the content type.
Everything appears to deploy fine. If I look at my custom site column it appears to reference the proper termset correctly. I can create a new list in the web UI that uses my custom content type just fine. However, my custom list created using the Visual Studio 2012 List template always shows my taxonomy field as disabled on the new form. Here are the other things I've witnessed about it:
In the web UI of SharePoint, if I go to the list properties and drill into my taxonomy site column I notice it shows that it isn't mapped to a termset. Keep in mind that if I do the same thing in Site Settings for my content type it appears correct. I can do the same thing for the web UI created custom list and everything is fine (editable in the new form and the field has the termset defined).
If I use powershell to dump out the info for the site column itself it has a valid termset.
If I use powershell to dump out the info for the field in the VS2012 created list it shows emtpy guid for the SspId, TermSetId, and TextField. It also shows IsTermSetValid = False.
If I use powershell to dump out the info for the field in the SharePoint web UI created list it shows the correct guid for the SspId, TermSetId, and TextField. It also shows IsTermSetValid = True.
Does anyone know why I seem to be having this behavior for the VS 2012 create custom list? Any help is appreciated.
Okay, so I'm going to answer my own question. Hopefully this will help someone else in the future.
My issue was that when creating a sample list for my content type (described in original question post), using the SharePoint UI, the needed Note field was getting added. Even if I had this right in my original TaxonomyFieldType declaration, I would have also ran into issues with my field values not showing up in the search refiners later on when I got to that part. Thankfully Ari Bakker has written a very detail explanation of what all you need to do in order to create your custom TaxonomyFieldType derived field, a custom content type to use it, a list definition, and a list instance. Just follow the details in the article: http://www.sharepointconfig.com/2011/03/the-complete-guide-to-provisioning-sharepoint-2010-managed-metadata-fields/

RenderingTemplate for ListForm Type

I created a custom RenderingTemplate "viewInventory" copy of ListForm
rendering template. It looks like below. Then I associated the
Rendering Template to a content type (this is list type content type)
EditFormTemplateName. But it seems the list is not even using this
controltemplate because I put a vogus name for editformtemplatename
and sharepoint did not complaint about it.
This exact scenario works for document renderingtemplate. Go figure.
Because you have set Inherits="True" in your content type definition, SharePoint ignores your XmlDocuments section when the solution is deployed, therefore your content type after deployment has no reference to your custom form templates.
Set Inherits to FALSE..
All I had to do is to associate "viewInventory" with both NewFormTemplateName and EditFormTemplateName of the content type through Sharepoint Manager 2007. (or you could do it feature attributes)

MOSS 2007 Content Types - farm wide application

We have an issue with rolling out content types with features. How does one roll them out to the SharePoint farm and update the database at the same time. Right now, we cannot figure it out. Is there something that has to be done custom?
By "update the database" I would assume that you mean your custom database, not any of the SharePoint databases?
Deign your database so that you will have some sort of mechanism to store the version. In its most simple form, a configuration table with a version row/column would be sufficient.
You can in the feature activated event, place code that checks the version of your database and, if necessary, performs any custom T-SQL scripts that updates your database.
Content types can be confusing to deploy. Once you deployed the content type by a feature and someone is using this content type (I.e a Sharepoint list, document, page layout etc) you CANNOT update the content type by redeploying the feature. This is by design. When a list adds a content type it makes a copy of the content type in the site collection.
There are two ways to solve this:
Update the content type in GUI and check "update all child content types"
Create a new feature "update content type x feature". Add a event handler to the feature activation and update the content type in the site collection by applying the contentType.update(true) method. To verify that all the child content types are updated create a SPQuery object with an beginswith parameter to the content type id.

SPWorkflowTaskProperties.ExtendedProperties aren’t populating the fields in my task

I am attempting to pass information from a task created within a workflow to its corresponding task form. Prior to the CreateTask activity, I create an SPWorkflowTaskProperties and fill it with the usual info (title, assigned-to, etc). I also add some elements to the ExtendedProperties property. However, those custom properties never make it into the Task.
I've tried setting the property key to:
the Guid of one of my task' content
type's fields;
the internal name of
one of my task' content type's
fields;
an unrelated name (in the
hopes of getting the info into the
task's properties instead of its
fields).
Nothing works. The task, once created, contains only the built-in field values I have set. None of values I explicitly added to the extended properties show up.
The (simplified) sequence of my activities is as follows:
PrepareTask. This is a custom
activity that contains the
SPWorkflowTaskProperties
CreateTask. The task properties are bound to the one in the PrepareTask activity.
OnTaskCreated. The task properties are bound to the one in the PrepareTask activity.
While (task not complete)
OnTaskChanged
I am using WSS 3.0 SP1 and an ASPX (NOT InfoPath) task form.
I still don't know why my original solution didn't work. But I have found a workaround. My sequence of activities is now:
CreateTask
OnTaskCreated
CopyTaskItems. This is a custom
activity that puts values into my
custom task's fields, then updates
the task.
While (task not complete)
OnTaskChanged
So I have to create the task, then immediately poke values into it and update.
I hope this will help some future reader of this question.
You should be using a ItemMetadata.xml document as a secondary datasource that contains the definition of the fields that you want to pass to your task form. Something like:
<z:row xmlns:z="#RowsetSchema"
ows_Instructions=""
ows_Body=""
ows_Comments=""
ows_ApprovalStatus=""
/>
The File name is important btw.
Notice the ows_ (as it used the webservices all fields in the list will be prefixed with ows.)
Then in you infopath form, set the default value of each control you want to display this information in. Hit the fx button and insert a field or group from the secondary datasource.
A good resource: http://weblog.vb-tech.com/nick/archive/2007/02/25/2207.aspx

Resources