Pages

Thursday, 2 May 2019

SharePoint Rest api JSON Result return one day before date.


SharePoint Store the date& time Field as UTC format , when we retrive the datatime flied it will return as UTC format,

i use moment.JS to convert date & time , you can download from https://momentjs.com/

download the moment.js and add the reference Js or any file where your fetching this date.


<script type="text/javascript" src="/path to Jquery/jquery-1.12.2.min.js"></script>
<script type="text/javascript" src="/path to Momentjs//moment.js"></script>

var StartTime= (item.ProgramStartDate);
console.log("Date Before Conversion: " +StartTime );

 StartTime= moment(StartTime).format('DD-MM-YYYY');
console.log("Date Before Conversion: " + StartTime);

Result will be like below.

I use dd-mm-yyyy Format. there are many other formats are available in momentjs.



SharePoint Search Service error : Could not connect to the search administration Web service on server SPSWAPP01 because the web server is not running.

SharePoint Search is not working  .

Logged in to SharePoint server and open Central administration  -> Service applications -> Click on Search Service application :



You will notice there is an error : Could not connect to the search administration Web service on server SPSWAPP01  because the web server is not running.

Open command prompt as administration and run the below command.
net start spsearchhostcontroller

Restart the IIS and with cmd iisreset

open search service application from Console. and check the status.



Friday, 22 March 2019

SharePoint designer workflow error : Errors were found while compiling the workflow


During Publishing the Workflow using SharePoint designer getting an error.

(-1, -1) Type System.CodeDom.CodeBinaryOperatorExpression is not marked as authorized in the application configuration file.)
(0, 0) Activity 'ID807' validation failed: Property "Condition" has invalid value. Condition expression is invalid. The condition expression can not be null.)


this is happened due to security update in SharePoint.

" .NET security updates for CVE-2018-8421"

Solution


The solution is to explicitly add the necessary types to all web applications' web.config files.

For SharePoint 2013 and later versions

Open web.config and find a section :

  <System.Workflow.ComponentModel.WorkflowCompiler>
    <authorizedTypes>
      <targetFx version="v4.0">  

For SharePoint 2013 and later versions, add the following lines:
<authorizedType Assembly="System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" NameSpace="System.CodeDom" TypeName="CodeBinaryOperatorExpression" Authorized="True" />
<authorizedType Assembly="System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" NameSpace="System.CodeDom" TypeName="CodePrimitiveExpression" Authorized="True" />
<authorizedType Assembly="System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" NameSpace="System.CodeDom" TypeName="CodeMethodInvokeExpression" Authorized="True" />
<authorizedType Assembly="System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" NameSpace="System.CodeDom" TypeName="CodeMethodReferenceExpression" Authorized="True" />
<authorizedType Assembly="System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" NameSpace="System.CodeDom" TypeName="CodeFieldReferenceExpression" Authorized="True" />
<authorizedType Assembly="System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" NameSpace="System.CodeDom" TypeName="CodeThisReferenceExpression" Authorized="True" />
<authorizedType Assembly="System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" NameSpace="System.CodeDom" TypeName="CodePropertyReferenceExpression" Authorized="True" />

For SharePoint versions earlier than SharePoint 2013

For SharePoint versions earlier than 2013, add the following lines instead:
<authorizedType Assembly="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" NameSpace="System.CodeDom" TypeName="CodeBinaryOperatorExpression" Authorized="True" />
<authorizedType Assembly="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" NameSpace="System.CodeDom" TypeName="CodePrimitiveExpression" Authorized="True" />
<authorizedType Assembly="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" NameSpace="System.CodeDom" TypeName="CodeMethodInvokeExpression" Authorized="True" />
<authorizedType Assembly="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" NameSpace="System.CodeDom" TypeName="CodeMethodReferenceExpression" Authorized="True" />
<authorizedType Assembly="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" NameSpace="System.CodeDom" TypeName="CodeFieldReferenceExpression" Authorized="True" />
<authorizedType Assembly="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" NameSpace="System.CodeDom" TypeName="CodeThisReferenceExpression" Authorized="True" />
<authorizedType Assembly="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" NameSpace="System.CodeDom" TypeName="CodePropertyReferenceExpression" Authorized="True" />