another technical blog...technically

Wednesday, April 10, 2013

About SharePoint:FormField and custom column

Yesterday, i had to face SharePoint again.
I created a custom type note field in which i inject custom HTML code (generated by code behind):

 
 

and a custom edit form (for the related custom content type) in which i want to show this field.
 

When i run the form, i noticed the field was blank...
What i've done to solve the problem?
This was driving me mad, i solved just setting the No value to the Append Changed to Existing Text option of the custom field.
The wanted
VoilĂ , smooth and clean!

Tuesday, April 2, 2013

Workflow task SPUser field

Working with workflow, i had this problem: i created a User type custom field to map who is the user who started the workflow.
I know there is a builtin field which does this work, but i need to create a custom one. So i tried to set the value with this code:
this.taskProperties.ExtendedProperties["RequestedBy"] = this.WorkflowProperties.OriginatorUser;
The result was an exception. I tried to create an SPUserFieldValue in order to set the extended property using this object. Since i receive another exception i looked into the ULS logger and i found this:

System.InvalidOperationException: The platform does not know how to deserialize an object of type Microsoft.SharePoint.SPFieldUserValue. The platform can deserialize primitive types such as strings, integers, and GUIDs; other SPPersistedObjects or SPAutoserializingObjects; or collections of any of the above. Consider redesigning your objects to store values in one of these supported formats, or contact your software vendor for support.
The code below solved the problem
this.taskProperties.ExtendedProperties["RequestedBy"] = this.WorkflowProperties.Originator;
Morality is: don't try stupid things and also refer to primitive types.
Share:

Me, myself and I

My Photo
I'm just another IT guy sharing his knowledge with all of you out there.
Wanna know more?