No doubt that jQuery is one of the best things to use in web development.
But when using it in SharePoint it’s a little bit tricky.
SharePoint always puts this in front of your control id: ‘ctl00$PlaceHolderMain$’ depending on which placeholder you placed your control.
When you need to access a control in jQuery in SharePoint your have to write a jQuery filter which is thinking about performance not always the best way to go.

Filter example:

$(“[id$=control_id]”)This filter will look for al controls were the id ends with your control id.
Using this filter will work perfect although writing it again and again pff…

Using this function will save you some time:

function GetSharePointNotation(control) {
return“[id$='” + control + “‘]”;
}

 

Using the function:

$(GetSharePointNotation(“control id”)).show();

 

Have fun

 

 

 

 

 

When you install SharePoint on your server you have to add roles and features.
This poershell does it for you:

 

Add-WindowsFeature NET-WCF-HTTP-Activation45,NET-WCF-TCP-Activation45,NET-WCF-Pipe-Activation45
Add-WindowsFeature Net-Framework-Features,Web-Server,Web-WebServer,Web-Common-Http,
Web-Static-Content,Web-Default-Doc,Web-Dir-Browsing,Web-Http-Errors,Web-App-Dev,
Web-Asp-Net,Web-Net-Ext,Web-ISAPI-Ext,Web-ISAPI-Filter,Web-Health,
Web-Http-Logging,Web-Log-Libraries,Web-Request-Monitor,Web-Http-Tracing,Web-Security,
Web-Basic-Auth,Web-Windows-Auth,Web-Filtering,Web-Digest-Auth,Web-Performance,Web-Stat-Compression,
Web-Dyn-Compression,Web-Mgmt-Tools,Web-Mgmt-Console,Web-Mgmt-Compat,Web-Metabase,Application-Server,AS-Web-Support,
AS-TCP-Port-Sharing,AS-WAS-Support, AS-HTTP-Activation,AS-TCP-Activation,AS-Named-Pipes,AS-Net-Framework,WAS,
WAS-Process-Model,WAS-NET-Environment,WAS-Config-APIs,Web-Lgcy-Scripting,Windows-Identity-Foundation,Server-Media-Foundation,Xps-Viewer

 

Have fun

I have putted this in a feature receiver event.
The code is actually very straight forword.

 

[Guid(“9ea3c6f6-f6f2-45e2-9cee-2e95e3019a34”)]
public class MUACChangeEventReceiver : SPFeatureReceiver
{

SPList historyList = null;
SPList taskList = null;

public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
SPSite site = properties.Feature.Parent as SPSite;
SPWeb web = site.RootWeb;
SPList list = web.Lists[“Project site creation”];

TryGetHistoryList(web);
TryGetTaskList(web);

//Get workflow by name
//SPWorkflowTemplate workflowTemplate = web.WorkflowTemplates.GetTemplateByName(Resources.Workflow.WorkflowDisplayName, CultureInfo.CurrentCulture);

Guid workflowTemplateGuid = Resources.Workflow.WorkflowId;
SPWorkflowTemplate workflowTemplate = web.WorkflowTemplates[workflowTemplateGuid];

web.AllowUnsafeUpdates = true;

try
{
// Create workflow association
SPWorkflowAssociation workflowAssociation = SPWorkflowAssociation.CreateListAssociation(workflowTemplate, Resources.Workflow.WorkflowDisplayName, taskList, historyList);

// Set workflow parameters
workflowAssociation.AllowManual = false;
workflowAssociation.AutoStartCreate = true;
workflowAssociation.AutoStartChange = false;

// Add workflow association to my list
list.WorkflowAssociations.Add(workflowAssociation);

// Enable workflow
workflowAssociation.Enabled = true;
}
finally
{
web.AllowUnsafeUpdates = false;
}
}

private void TryGetHistoryList(SPWeb web)
{
try
{
historyList = web.Lists[“Workflow History”];
}
catch (ArgumentException exc)
{
// Create workflow history list
Guid listGuid = web.Lists.Add(“Workflow History”, “”, SPListTemplateType.WorkflowHistory);
historyList = web.Lists[listGuid];
historyList.Hidden = true;
historyList.Update();
}
}
private void TryGetTaskList(SPWeb web)
{
try
{
taskList = web.Lists[“Workflow Tasks”];
}
catch (ArgumentException exc)
{
// Create workflow tasks list
Guid listGuid = web.Lists.Add(“Workflow Tasks”, “”, SPListTemplateType.Tasks);
taskList = web.Lists[listGuid];
taskList.Hidden = true;
taskList.Update();
}
}
}

Most often you want your customsolution to be deployed to only a specific webapplication but SharePoint won’t allow it.

It’s actually very easy to fix this by tricking SharePoint.

2014-03-03_8-08-06.2png

In your package manifest you add a safe control:

<Solution xmlns=”http://schemas.microsoft.com/sharepoint/”&gt;
<Assemblies>
<Assembly Location=”dll_name_of_your_solution.dll” DeploymentTarget=”GlobalAssemblyCache”>
<SafeControls>
             <SafeControl Assembly=”dll_name_of_your_solution,Version=1.0.0.0,Culture=neutral, PublicKeyToken=****************” Namespace=”namespace_of_your_solution” TypeName=”*” />
</SafeControls>
</Assembly>
</Assemblies></Solution>

2014-03-03_8-07-02

If you acces the value of a multiline field there will be HTML tags included, so… the way to get only the text is like this…

SPFieldMultiLineText field = (SPFieldMultiLineText)item.Fields[“FieldName”];
string text = field.GetFieldValueAsText(item[“FieldName”]);

I wrote an exstension method for this:

var text = item.RetrieveMultiLineValue(“fieldname”);

Method:

public static string RetrieveMultiLineValue(this SPListItem item, string fieldname)
{
string text = String.Empty;

if (item[fieldname] != null)
{
SPFieldMultiLineText field = (SPFieldMultiLineText)item.Fields[fieldname];
text = field.GetFieldValueAsText(item[fieldname]);
}

return text;
}

Voila, hope it helps, comments are welcome…