Thursday 17 May 2018

O365 - Nintex Workflow + SharePoint Create Folder + Call HTTP web service + REST API

Working with folders by using REST
You can retrieve a folder inside a document library when you know its URL
The following example shows how to create a folder.
url: http://site url/_api/web/folders
method: POST
body: { '__metadata': { 'type': 'SP.Folder' }, 'ServerRelativeUrl': '/document library relative url/folder name'}
Headers:
    Authorization: "Bearer " + accessToken
    X-RequestDigest: form digest value
    accept: "application/json;odata=verbose"
    content-type: "application/json;odata=verbose"
    content-length:length of post body


For Nintex - Call HTTP web service + REST API

Address: site_URL_api/web/getfolderserverrelativeurl('Share%Document')/folders/add(NewFolder')
Request Type : HTTP Post
Request Headers: "accept: "application/json;odata=verbose"
    content-type: "application/json;odata=verbose""




O365 - Call HTTP Web Service failed - Unauthorized "Access denied"

When using the "Call HTTP Web Service" action - Receive the following error:
 Unauthorized - {"error":{"code":"-2147024891, System.UnauthorizedAccessException","message": 
{"lang":"en-US","value":"Access denied. You do not have permission to perform this action or access this resource."}}}

Register Workflow App ID  into destination location with Full Control.

Please follow the below steps to resolve the issue:


Friday 11 May 2018

Nintex Forms JS Events


Event Type
How to add a handler to this event
Filler Before Ready
  1. NWF.FormFiller.Events.RegisterBeforeReady(function ()
{ // your custom code goes here });
Filler After Ready
  1. NWF.FormFiller.Events.RegisterAfterReady(function ()
{ // your custom code goes here });
Repeater Row Adding
  1. NWF.FormFiller.Events.RegisterRepeaterRowAdding (function ()
{ // your custom code goes here });
Repeater Row Added
  1. NWF.FormFiller.Events.RegisterRepeaterRowAdded (function ()
{ // your custom code goes here });
Repeater Row Deleting
  1. NWF.FormFiller.Events.RegisterRepeaterRowDeleting (function ()
{ // your custom code goes here });
Repeater Row Deleted
  1. NWF.FormFiller.Events.RegisterRepeaterRowDeleted (function ()
{ // your custom code goes here });
Control Resizing
  1. NWF.FormFiller.Events.RegisterControlProcessing (function ()
{ // your custom code goes here });
Control Resized
  1. NWF.FormFiller.Events.RegisterControlProcessed (function ()
{ // your custom code goes here });

Thursday 10 May 2018

SharePint Workflow Status Code


Workflow Status Codes

Number
Member name
Description
0
NotStarted
The workflow has not started.
1
FailedOnStart
Indicates that the workflow encountered an error when it started.
2
InProgress
Workflow is currently in progress.
3
ErrorOccurred
An error occurred during the execution of the workflow.
4
StoppedByUser
Workflow execution was halted by a specified user.
5
Completed
The workflow is completed.
6
FailedOnStartRetrying
Indicates that the workflow is being retried after it failed to start.
7
ErrorOccurredRetrying
Indicates that the workflow is being retried after an initial failure.
8
ViewQueryOverflow
This member is reserved for internal use and is not intended to be used directly from your code.
15
Max
This member is reserved for internal use and is not intended to be used directly from your code.

 Workflow History List Event Types

Number
Event Type
Description
0
None
There is no specific event type for this workflow event.
1
WorkflowStarted
The workflow event concerns the workflow instance being initiated.
2
WorkflowCompleted
The workflow event concerns the workflow instance being completed.
3
WorkflowCancelled
The workflow event concerns the workflow instance being cancelled.
4
WorkflowDeleted
The workflow event concerns the workflow instance being deleted.
5
TaskCreated
The workflow event concerns a workflow task being created.
6
TaskCompleted
The workflow event concerns a workflow task being marked as complete.
7
TaskModified
The workflow event concerns a workflow task being modified.
8
TaskRolledBack
The workflow event concerns changes to a workflow task being rolled back.
9
TaskDeleted
The workflow event concerns a workflow task being deleted.
10
WorkflowError
The workflow event concerns the workflow instance generating an error.
11
WorkflowComment
The workflow event concerns a comment being written for the workflow instance.

Sharepoint Recycle Bin

SharePoint web application using PowerShell:
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
$WebApp=Get-SPWebApplication "http://test.com"
foreach ($SPSite in $webApp.Sites)
{
   foreach($SPWeb in $SPSite.AllWebs)
   {
             $SPWeb.RecycleBin.MoveAllToSecondStage();
              write-host "End-User Recycle Bin Items Deleted for:"
              write-host $SPWeb.title ":" $SPWeb.URL "`n"
              $SPWeb.Dispose()
    }
             $SPSite.RecycleBin.DeleteAll();
             $SPSite.Dispose()
             write-host "Administrator Recycle bin Items Deleted for:" $SPSite.RootWeb.title "`n"
}




SharePoint Site Collection using PowerShell:


$Site = Get-SPSite "https://test.com/sites/test"
$Site.AllWebs | Foreach-object { $_.RecycleBin.MoveAllToSecondStage() }
$Site.RecycleBin.DeleteAll();


Restore based on Object Type (such as List, Web, ListItem, etc):


Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
$SiteURL="http://test.com"
$site = Get-SPSite $SiteURL
$RecycleBin = $site.RecycleBin
$DeletedItems = $RecycleBin | Where{ $_.ItemType -eq "List"}
if($DeletedItems)
{
 Foreach($Item in $DeletedItems)
 {
  $Item.Restore()
  Write-Host "'$($Item.Title)' Restored from Recycle Bin!" -f DarkGreen
 }
}


Restore all items from SharePoint Recycle bin:


Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
$SiteURL="http://test.com/sites/test"
$Site = Get-SPSite $SiteURL
$DeletedItems = $Site.RecycleBin
if($DeletedItems)
{
 foreach($Item in $DeletedItems)
 {
  $Site.RecycleBin.restore($Item.ID)
  Write-Host "Item restored:"$Item.Title
 }
}

SharePoint Configuration Cache

Finding SharePoint Config Cache


$connectionString = "Data Source=SharePoint; Initial Catalog=Config;Integrated Security=True; Enlist=False; Connect Timeout=15"
$query = "Select Id, Properties from Objects with (nolock)"
$command = New-Object System.Data.SqlClient.SqlCommand($query)
$connection = New-Object System.Data.SqlClient.SqlConnection($connectionString)
$command.Connection = $connection
try
{
      $connection.Open()
      $reader = $command.ExecuteReader()
      while ($reader.Read())
      {
            Write-Host "Processing object " $reader.GetGuid(0)
            $xml = $reader.GetString(1)
            $xmlDoc = New-Object System.Xml.XmlDocument
            $stringReader = New-Object System.IO.StringReader($xml)
            $xmlReader = New-Object System.Xml.XmlTextReader($stringReader)
            $xmlDoc.Load($xmlReader)
            $xmlReader.Close();
      }
}
finally
{
      if ($connection -ne $null)
      {
            $connection.Close()
      }
     
}


Clearing SharePoint Configuration Cache
1. Stop the SharePoint Timer service on each of the servers within the SharePoint farm.
    - Click Start, go to Administrative Tools, and then click Services.
    - Right-click SharePoint Timer, and then click Stop.
    - Close the Services console.
2. On the server hosting Central Administration, click Start, click Run, type explorer, and then press ENTER.
3. In Windows Explorer, locate and then double-click the following folder: %SystemDrive%\ProgramData\Microsoft\SharePoint\Config\GUID
Note: The %SystemDrive% variable relates to the drive on which Windows is installed. By default, Windows is installed on drive C. The GUID placeholder specifies the GUID folder. There may be more than one of these. See Additional Information for steps to view hidden folders.
4. Back up the Cache.ini file. (Make a copy of it. DO NOT DELETE THIS FILE, Only the XML files in the next step)
5. Delete all the XML configuration files in the GUID folder (DO NOTE DELETE THE FOLDER).
Note: When emptying the configuration cache in the GUID folder, do NOT delete the GUID folder and the Cache.ini file that is located in the GUID folder.
6. Double-click the Cache.ini file.
7. On the Edit menu, click Select All.
8. On the Edit menu, click Delete.
9. Type 1, and then click Save on the File menu. (The only text in the config.ini file should be the number 1.)
10. On the File menu, click Exit.
11. Clear the SharePoint Configuration Cache:
     - Click Start, point to Administrative Tools, and then click Services.
     - Right-click SharePoint Timer, and then click Start.
     - Close the Services console.
12. Make sure that the Cache.ini file in the GUID folder now contains its previous value. For example, make sure that the value of the Cache.ini file is not 1.
13. Check in the GUID folder to make sure that the xml files are repopulating. This may take a bit of time.

Parser Enabled for Document Property + SharePoint 2013


Property promotion refers to the process of extracting values from properties of a document and writing those values to corresponding columns on the list or document library where the document is stored. Property demotion is the same process in reverse. Values are read from list columns and written to document properties.
Document promotion is used to pull the document metadata from Word 2013 documents when uploading the document to the SharePoint document library and set those metadata values to the corresponding field.


Disable Document Property Promotion using PowerShell
$web = Get-SPWeb "http://test/sites/test_1/"
$web.ParserEnabled = $false
$web.Update()
$web.Dispose()

Enable Document Property Promotion using PowerShell
$web = Get-SPWeb "http://test/sites/test_1/"
$web.ParserEnabled = $True
$web.Update()
$web.Dispose()