Créer un site internet

Posts by fredericdietrich

Search Cannot Crawl Start Address

By On 21/05/2020

Sharepoint Search The Start Address Cannot Be Crawled

even read permissions are good, search cannot crawl, i triied a lot of things found on the net, no one succeded. then i only add a new web application, and start a full crawl. the crawl succeded on each start adress, i don't know why but it works :)

PSONFIG.exe Product Failed

By On 15/05/2020

PSCONFIG.exe Configuration of SharePoint Products failed. Configuration must be performed before you use SharePoint Products. A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible

An exception of type System.Data.SqlClient.SqlException was thrown. Additional exception information: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)

Check your connection string in HKEY_LOCAL_MACHINE > SOFTWARE > Microsoft > Shared Tools > Web Server Extensions > 16.0 > Secure > ConfigDB

Sharepoint Query Search By UTC Date

By On 09/12/2019

Sharepoint query search by date (UTC date type)
 
When your field is DateOnly => 12/12/2019, search service will store it like : 2019-12-11T23:00:00.0000000Z
 
In your regionnal settings, you can see -1
 
 
So in your query to retrieve you should substract one hour
 
                    
                        var aDate = new Date('2019-12-12);
                        var offset = new Date().getTimezoneOffset();
                        console.log("offset : " + offset);//in my case, offset is -60
                        console.dir(aDate);
                        aDate.setMinutes(aDate.getMinutes() + offset);
                        console.dir(aDate);
                        /_api/search/query='MnpDate:aDate.toISOString()';
                        // aDate : 2019-12-11T23:00:00.0000000Z
                    
                

Sharepoint REST set ShowInEditForm

By On 28/11/2019

With this script you can Show / hide your field in standard sharepoint forms
ShowInDisplayForm
ShowInEditForm
ShowInNewForm
 
var xhr = new XMLHttpRequest();
var url = _spPageContextInfo.webAbsoluteUrl;
if (url === "undefined {
console.log("_spPageContextInfo.webAbsoluteUrl undefined");
url = "http://siteUrl;
}
 
xhr.open('POST', url + "/_api/web/Lists(guid'bec2b6d5-3183-4bd7-87a5-0989610b2e25')/Fields(guid'341eeecb-e5ff-447c-9cd0-84c9f00c80c6')/setShowInEditForm(true)");
xhr.setRequestHeader("Accept", "application/json; odata=verbose");
xhr.setRequestHeader("X-RequestDigest", document.getElementById("__REQUESTDIGEST").value;
xhr.setRequestHeader("X-HTTP-Method", "MERGE");
xhr.setRequestHeader("If-Match", "*");
 
xhr.onload = function () {
if (xhr.status === 200) {
var kk = JSON.parse(xhr.responseText);
console.dir(kk);
}
else {
console.dir(xhr);
alert('Request failed. Returned status of ' + xhr.status);
}
};
xhr.send();
 
see script in mode text here

Sharepoint Query Using REST

By On 27/11/2019

Here is my page to develop my REST queries

if my query returns an object, it will display all properties of my obj, as in navigation console (console.dir(obj);)

if my query returns an array it will display all properties in input : "show properties'

 

complete code to add in a script editor webpart :see script

 

Querycontenttypesfieds

 

queries samples : 


/_api/web/lists(guid'0E12917B-80F9-4765-8612-22A9AB467123')/items?$select=AssignedTo,Title&$orderby=DueDate desc&$filter=RelaunchDate eq null and Status eq 'In Progress'


/_api/web/getlist('/sites/csc-dev/Lists/myLMist')/fields?$select=Group,InternalName,Title,TypeAsString,Hidden


/_api/web/getlist('/sites/csc-dev/Lists/vdfdfvf')/fields?$select=Group,InternalName,Title,TypeAsString,Hidden&$filter=Hidden eq false and TypeAsString ne 'Computed' and startswith(InternalName, '_') eq false&$orderby=TypeAsString


/_api/web/getlist('/sites/csc-dev/Lists/myLMist')/fields?$select=Group,InternalName,Title,TypeAsString,Hidden


/_api/web/lists(guid'0E12917B-80F9-4765-8612-22A9AB46784E')/items?$select=AssignedTo/EMail,Created,Author/EMail,Body,DueDate,,ID,IsGroup,Modified,Editor/EMail,StartDate,Status,stepName,TaskGroup/EMail,TaskIdentifier,TaskProcessed,TaskProcessedBy/Title,TaskProcessedBy/Id,TaskProcessedBy/EMail,Title,WFFormFieldStepType,WFInstance&$orderby=DueDate desc&$filter=RelaunchDate eq null and Status eq 'In Progress'&$expand=Author,Editor,AssignedTo,TaskProcessedBy,TaskGroup

USER

{
Title: string;
EMail: string;
Id: number;
}

CSOM powershell SSL TSL site

By On 23/11/2019

 

Exception calling "ExecuteQuery" with "0" argument(s): "The request was aborted: Could not create SSL/TLS secure channel." SOLVED

Exception lors de l'appel de ExecuteQuery" avec 0" argument(s): La demandea été abandonnée: Impossible de créer un canal sécurisé SSL/TLS." : résolu

How to connect to a SSL/ TSL sharepoint site with CSOM in powershell

Start to call a request with your certificate

 

 
$anUrl = https://mySharepoint

$CertificateThumbprint = "53836D3C35F949959D7E4038D5D39D7B"

$response = Invoke-WebRequest -Verbose -URI $anUrl -CertificateThumbprint $CertificateThumbprint -UseDefaultCredentials -SessionVariable websession -ErrorAction:Stop

 

 

# extract cookies from your response, and isolate wich one is authentication cookie
$cookies = $websession.Cookies.GetCookies($anUrl)
$global:cookieName3= "$($cookies[$i].name)".Trim();
$global:cookieVal3 = "$($cookies[$i].value)".Trim();

 

# get correct certificate in your store
$global:cert = Get-ChildItem -Path cert:\CurrentUser\My | ?{$_.Thumbprint -eq $CertificateThumbprint}
$context987 = New-Object Microsoft.SharePoint.Client.ClientContext($anUrl);
 
# set the security protocol
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 -bor ` [Net.SecurityProtocolType]::Tls11 -bor ` [Net.SecurityProtocolType]::Tls -bor ` [Net.SecurityProtocolType]::Ssl3

 

# add an ExecutingWebRequest event, which will be raised on each Execute query
$context987.add_ExecutingWebRequest({ })

 

# in this ExecutingWebRequest you should add the certificate to yoour request and add the authentification cookie

$request = $EventArgs.WebRequestExecutor.WebRequest

$request.ClientCertificates.Add($global:cert)
$request.CookieContainer = New-Object System.Net.CookieContainer
$c3 = New-Object System.Net.Cookie($global:cookieName3, $global:cookieVal3, "/", $global:cookieDomaine);
$request.CookieContainer.Add($c3);
$context987.Load($context987.web);
$context987.ExecuteQuery();
Write-Host "Title : $($web.Title)"

 

 

to list all your available certificate execute following script

[System.Security.Cryptography.X509Certificates.X509Store]$storeNew-Object System.Security.Cryptography.X509Certificates.X509Store([System.Security.Cryptography.X509Certificates.StoreName]::My, [System.Security.Cryptography.X509Certificates.StoreLocation]::CurrentUser) # LocalMachine
$store.Open([System.Security.Cryptography.X509Certificates.OpenFlags]::ReadOnly);
$store.Certificates | select Thumbprint, FriendlyName, Subject

Hide Sharepoint Top Nav

By On 30/10/2019

Add in your query string fdiedit=1 to show the top vanigation
<style>
#SearchBox{
display: none;
}
#gdocSearchBox {
display: block;
}
#s4-ribbonrow{
display: none;
}
#suiteBarTop{
display: none;
}
#SearchBox{
display: none;
}
 
#DeltaTopNavigation .root.ms-core-listMenu-root.static {
margin-top: 10px;
}
 
#s4-titlerow {
margin-top: 0px;
margin-bottom: 0px;
padding-top: 0px;
padding-bottom: 1px;
height: 20px;
}
.ms-breadcrumb-top{
display: flex;
}
</style>
 
<script type="text/javascript">
 
function showSpStandard() {//show top nav
jq("#suiteBarTop").show();
jq("#s4-ribbonrow").show();
jq("#SearchBox").show();
jq("#DeltaPageStatusBar").show();
jq("#s4-titlerow").show();
jq("#suiteBarTop").show();
jq(".root.ms-core-listMenu-root.static").show();
}
function getUrlVars() {//get query strings
var vars = {};
var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
vars[key] = value;
});
return vars;
}
 
function fdiShowEdit(){//if query string
var canEdit = getUrlVars()["fdiedit"];
if(canEdit == 1)
showSpStandard();
}
 
_spBodyOnLoadFunctionNames.push("fdiShowEdit");
</script>
You can put this script in a script editor webpart or in master page 

Sharepoint Rest Query List

By On 21/09/2019

Query sharepoint list with REST

 

use this end point to query your list http://test/sites/test/_api/Web/Lists/getbytitle('vvv')/items?$select=&$filter= Title eq 'entite du ga 1'

Example : http://test01/sites/test01/_api/Web/Lists/getbytitle('Aliste')/items?$select=Title,ID,Author/Title&$expand=Author&$filter= Title eq 'entite du toto 1'

to order by : &$orderby= Employee asc

to order by : &$orderby= Employee desc

to limit number of items returned : $top 5

to use paging : $skip 5

new paging mode add in your first query  &$skiptoken=Paged=TRUE in your response, you will receive next page query in odata.nextLink as below

Nextlink

/_api/Web/Lists/getbytitle(%27Initiatives%27)/items?%24skiptoken=Paged%3dTRUE%26p_ID%3d266&%24select=Title%2cID&%24orderby=ID+desc&p_ID=268&%24Top=3

 

expand lookup fields : $expand=city&$select=city/Id

 

viewfields : $select= Title, ID

filter : $filter=Title eq 'mon noeud' and ID ne 1

 

Numeric comparisons

  • Lt
  • Le
  • Gt
  • Ge
  • Eq
  • Ne
 

String comparisons

  • startsWith
  • substringof
  • Eq
  • Ne
 

Date and time functions

  • day()
  • month()
  • year()
  • hour()
  • minute()
  • second()

 

 

Querylist 1

 
 

html to query list

 

javascript to query list

 

css to query list

 

base html file

 

Full script to add in an Script Editor webpart

 

script without JQuery

Powershell Csom Paged Caml Query

By On 18/09/2019

 


$list = Get-PnPList -Identity $listTitle -ThrowExceptionIfListNotFound

$ctx = Get-PnPContext
$page = $null
$pageNumber = 0;
$rowLimit = 200
Do{
    $stringBuilder = New-Object System.Text.StringBuilder
 
    $stringBuilder.Append("<View Scope='RecursiveAll'>") | Out-Null
    $stringBuilder.Append("<Query><Where></Where>")| Out-Null
    $stringBuilder.Append("<OrderBy><FieldRef Name='ID' Ascending='TRUE' /></OrderBy>")| Out-Null
    $stringBuilder.Append("</Query>")| Out-Null
    $stringBuilder.Append("<ViewFields>")| Out-Null
    $stringBuilder.Append("<FieldRef Name='ID' />")| Out-Null
    $stringBuilder.Append("<FieldRef Name='Title' />")| Out-Null
    $stringBuilder.Append("</ViewFields>")| Out-Null
    $stringBuilder.Append("<RowLimit Paged='TRUE'>$($rowLimit)</RowLimit>")| Out-Null
    $stringBuilder.Append("</View>")| Out-Null
    
    $spqQuery = New-Object Microsoft.SharePoint.Client.CamlQuery
    $spqQuery.ViewXml = $stringBuilder.ToString();
    $spqQuery.ListItemCollectionPosition = $page


    $pageNumber ++;

    $spqQuery.ViewXml = $stringBuilder.ToString();
    $itemki=$list.GetItems($spqQuery); 
    $spqQuery.ListItemCollectionPosition = $itemki.ListItemCollectionPosition

    $ctx.Load($itemki)
    $ctx.ExecuteQuery();


    Write-Host "################## PAGE " $($page.PagingInfo) " #########################"
    Write-Host "processing query results. Recs: $($itemki.Count)"

    $Counter = 0;
    foreach($item in $itemki)
    {
        Write-Host "$($item["ID"]) title pageNumber '$($pageNumber)' : $($item["Title"])"
    }

    $page = $itemki.ListItemCollectionPosition
 }   
 Until($page -eq $null) 


 
get script

Add SPList With CSOM

By On 15/08/2019

function AddList()
{param($url0, $title)
 
$context0 = New-Object Microsoft.SharePoint.Client.ClientContext($url0);
 
$context0.AuthenticationMode = [Microsoft.SharePoint.Client.ClientAuthenticationMode]::FormsAuthentication
$credentials0 = New-Object Microsoft.SharePoint.Client.FormsAuthenticationLoginInfo("d03305", $mypsw);
$context0.FormsAuthenticationLoginInfo = $credentials0;
 
[Microsoft.SharePoint.Client.Web]$web0 = $context0.Web;
 
 
 
$context0.Load($web0)
$context0.Load($web0.ListTemplates)
$context0.ExecuteQuery()
 
$template = $web0.ListTemplates | Where-Object {$_.Name -eq "Fiche de conformité"}
$template.Name
 
#check if list exists
$list = $null;
try
{
$list = $web0.GetList("$($web0.ServerRelativeUrl.TrimEnd("/"))/$($title)");
$context0.Load($list);
$context0.ExecuteQuery();
}
catch
{
$list = $null;
}
if($list -eq $null)
{
Write-Host "list is null"
#creation de la liste
$ListInfo = New-Object Microsoft.SharePoint.Client.ListCreationInformation
$ListInfo.Title = $title
[System.Int32]$lstId = 100#$template.ListTemplateTypeKind;
$ListInfo.TemplateType = $lstId;
$List1 = $web0.Lists.Add($ListInfo);
<#
$List1.Description = "$($title) GED Corporate";
$List1.Update()
#>
$context0.ExecuteQuery()
 
}
else
{
Write-Host "list is not null"
}
 
$list.Title;
 
$context0.Dispose();
$context0 = $null;
}

CSOM ISSUE format-default

By On 21/02/2019

format-default : The collection has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested.

 
$col = $oWeb.AvailableFields | Where {$_.InternalName -eq "TestCategories"}
 
$context.Load($listDoc.Fields);
$context.Load($col);
$context.ExecuteQuery();
 
$null = $listDoc.Fields.Add($col);
 
if $col is null because the field "TestCategories" does not exist in $oWeb.AvailableFields you've got this message

Managed Navigation Issue

By On 31/01/2019

 

Impossible de se connecter à la banque de termes sur la navigation par méta données gérées

Managednavissue

Désolé... Nous n'avons pas pu créer l'ensemble de termes : Aucune connexion au service de métadonnées gérées par défaut n'a été spécifiée.

Settermstoreproperties

 

 

Sharepoint 2016 Register Javascript In Hive

By On 24/01/2019

To register javascript file in 16/layouts

 

you should write with 15, sharepoint will translate it in 16 : <script type="text/javascript" src="/_layouts/15/testFDI/jquery.min.js"></script>

PowerShell Csom load property Issue

By On 18/01/2019

Using  Microsoft.SharePoint.Client.dll  you can have issue after object loading

$file = $oWeb.GetFileByUrl($fileUrl);

$context.Load($file);

$context.ExecuteQuery()

$context.Load($file.ListItemAllFields)

$context.ExecuteQuery()

$file.ListItemAllFields #accessing to this property will thow exception below

format-default : The collection has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested.

 

so you have to store property in a variable like that

 

$ListItemAllFields = $file.ListItemAllFields

$context.Load($ListItemAllFields)

$context.ExecuteQuery()

 

 

 

Sharepoint Online Web Templates

By On 11/01/2019

Name Title Category Compatiblity Level
STS#3 Site d’équipe Collaboration 15
STS#0 Site d’équipe (expérience classique) Collaboration 15
BLOG#0 Blog Collaboration 15
BDR#0 Centre de documents Entreprise 15
DEV#0 Site de développeur Collaboration 15
OFFILE#1 Centre des enregistrements Entreprise 15
EHS#1 Site d’équipe - Configuration SharePoint Online Entreprise 15
SRCHCEN#0 Centre de recherche d’entreprise Entreprise 15
BLANKINTERNETCONTAINER#0 Portail de publication Publication 15
ENTERWIKI#0 Wiki d’entreprise Publication 15
PROJECTSITE#0 Site de projet Collaboration 15
COMMUNITY#0 Site communautaire Collaboration 15
COMMUNITYPORTAL#0 Portail communautaire Entreprise 15
SITEPAGEPUBLISHING#0 Site de communication Publication 15
SRCHCENTERLITE#0 Centre de recherche de base Entreprise 15

List templates

ID Template Name Description SP2016 SP2013 SP2010 SP2007
-1 InvalidType Not used. Yes Yes Yes Yes
0 NoListTemplate unspecified list type. Yes Yes Yes No
100 GenericList Custom list. Yes Yes Yes Yes
101 DocumentLibrary Document library. Yes Yes Yes Yes
102 Survey Survey. Yes Yes Yes Yes
103 Links Links. Yes Yes Yes Yes
104 Announcements Announcements. Yes Yes Yes Yes
105 Contacts Contacts. Yes Yes Yes Yes
106 Events Calendar. Yes Yes Yes Yes
107 Tasks Tasks. Yes Yes Yes Yes
108 DiscussionBoard Discussion board. Yes Yes Yes Yes
109 PictureLibrary Picture library.  Yes Yes Yes Yes
110 DataSources Data sources for a site. Yes Yes Yes Yes
111 WebTemplateCatalog Site template gallery.  Yes Yes Yes Yes
112 UserInformation User Information. Yes Yes Yes Yes
113 WebPartCatalog Web Part gallery. Yes Yes Yes Yes
114 ListTemplateCatalog List Template gallery. Yes Yes Yes Yes
115 XMLForm XML Form library. Yes Yes Yes Yes
116 MasterPageCatalog Master Page gallery. Yes Yes Yes Yes
117 NoCodeWorkflows No Code Workflows. Yes Yes Yes Yes
118 WorkflowProcess Custom Workflow Process. Yes Yes Yes Yes
119 WebPageLibrary Wiki Page Library. Yes Yes Yes Yes
120 CustomGrid Custom grid for a list. Yes Yes Yes Yes
121 SolutionCatalog Solutions. Yes Yes Yes No
122 NoCodePublic No Code Public Workflow. Yes Yes Yes No
123 ThemeCatalog Themes. Yes Yes Yes No
124 DesignCatalog DesignCatalog. Yes Yes No No
125 AppDataCatalog AppDataCatalog. Yes Yes No No
130 DataConnection
Library
Data connection library for sharing information about external data connections. Yes Yes Yes Yes
140 WorkflowHistory Workflow History. Yes Yes Yes Yes
150 GanttTasks Project Tasks. Yes Yes Yes Yes
151 HelpLibrary Help Library. Yes Yes No No
160 AccessRequest Access Request List. Yes Yes No No
171 TasksWithTimeline
AndHierarchy
Tasks with Timeline and Hierarchy. Yes Yes No No
175 MaintenanceLogs Maintenance Logs Library. Yes Yes No No
200 Meetings Meeting Series (Meeting). Yes Yes Yes Yes
201 Agenda Agenda (Meeting). Yes Yes Yes Yes
202 MeetingUser Attendees (Meeting). Yes Yes Yes Yes
204 Decision Decisions (Meeting). Yes Yes Yes Yes
207 MeetingObjective Objectives (Meeting). Yes Yes Yes Yes
210 TextBox Text Box (Meeting). Yes Yes Yes Yes
211 ThingsToBring Things To Bring (Meeting). Yes Yes Yes Yes
212 HomePageLibrary Workspace Pages (Meeting). Yes Yes Yes Yes
301 Posts Posts (Blog). Yes Yes Yes Yes
302 Comments Comments (Blog). Yes Yes Yes Yes
303 Categories Categories (Blog). Yes Yes Yes Yes
402 Facility Facility. Yes Yes Yes No
403 Whereabouts Whereabouts. Yes Yes Yes No
404 CallTrack Call Track. Yes Yes Yes No
405 Circulation Circulation. Yes Yes Yes No
420 Timecard Timecard. Yes Yes Yes No
421 Holidays Holidays. Yes Yes Yes No
499 IMEDic IME (Input Method Editor) Dictionary. Yes Yes Yes No
600 ExternalList External. Yes Yes Yes No
700 MySiteDocument
Library
MySiteDocumentLibrary. Yes Yes No No
1100 IssueTracking Issue tracking. Yes Yes Yes Yes
1200 AdminTasks Administrator Tasks. Yes Yes Yes Yes
1220 HealthRules Health Rules. Yes Yes Yes No
1221 HealthReports Health Reports.  Yes Yes Yes No
1230 DeveloperSiteDraft
Apps
Draft Apps library in Developer Site. Yes Yes No No
3100 AccessApp   Yes No No No
3101 AlchemyMobileForm   Yes No No No
3102 AlchemyApproval
Workflow
  Yes No No No
3300 SharingLinks   Yes No No No
    Total 64 60 52 38
In HTML

Css Add a Line Above

By On 05/12/2018

Add a line with css above an html element

 

salut Fred

html
 
 
css
 

When the text is too long and goes outside the div or span, add this : white-space: normal;

 

ul li in line



<ul style="display:inline; list-style: none;">
          <li  style="display:inline;"><div style="background-color: #FF0000;width: 8px;height: 8px;">&nbsp;</div></li>
          <li style="display:inline;">plop</li>
          <li style="display:inline;">plop</li>
          <li style="display:inline;">plop</li>
        </ul>
 display: inline; list-style: none;

SPField Set ShowInDisplayForm With Rest

By On 23/11/2018

function UpdateList(){
$.ajax({
url: _spPageContextInfo.webAbsoluteUrl + "/_api/Web/Lists/getbytitle('Pages')/Fields(guid'f941f8cf-65d5-4cdb-bc6b-6fab7ea92bc3')/setshowindisplayform(false)",
type: "POST",
contentType: "application/json;odata=verbose",
headers: {
"Accept": "application/json;odata=verbose",
"X-RequestDigest": $("#__REQUESTDIGEST").val(),
"X-HTTP-Method": "MERGE",
"If-Match": "*"
},
success: function (data) {
alert('Success');
window.location.href=window.location.href;
},
error: function (data) {
console.dir(data);
}
});
}
UpdateList();

Change Files Extentsions

By On 23/11/2018

#Retourne le chemin
function Get-ScriptDirectory
{
$Invocation = (Get-Variable MyInvocation -Scope 1).Value
Split-Path $Invocation.MyCommand.Path
}
$ScriptDirectory = Get-ScriptDirectory
"$($ScriptDirectory)\Powershell" | Push-Location
 
 
Dir *.ps1 | rename-item -newname { [io.path]::ChangeExtension($_.name, ".txt") }