Errors were found when compiling the workflow the workflow files were saved but cannot be run


We are getting the error “Errors were found when compiling the workflow the workflow files were saved but cannot be run “when we are trying to publish the workflow.
 In my scenario we restored the site from Dev to QA environment, once restore completed we are can able to see the work flows in SharePoint designer. I created a new item in the list but workflow did not triggered. We opened the designer and try to publish we are getting the below error. 


 In designer we identified that there is no associated list for this workflow, we have to give the current site List ID in the .WFconfig.xml file. To give this List ID we have to follow the below steps.
 Open the site in SP Designer
Click on “All Files”
Click on Workflows
In All Files expand the Workflows click on +
Again expand the particular workflow, there you can able to see the couple of files, open the .WFconfig.xml file in advanced mode there we can able to see the <Association ListID =”{previous list id}” , place the current site list id and save it.

Now you can able to see the workflow is Associated with list. We can able to Save and publish the Workflow without any issues.

Sending Approval Request Approval Failed in SharePoint 2013

For one of the site we given site owner email address in “Access request settings” , if anyone trying to access  the site who don’t have permissions they  will request for access to that site email will come to site owner.
 When site owner is trying to approve the request he was getting the error “Sending Approval Request Approval Failed” as per the below screen shot.


Solution:
Navigate to “permsetup.aspx” page in the same site, URL looks like
http://dotnetsharepoint.com/sites/sharepoint/documentsite/_layouts/15/permsetup.aspx

Select the radio button option “Use an existing group”
In owners Group select the current owners Group name available in the current site and click on Ok.
Now you can able to approve the requests.

Another site or list is still using this content type. If you would still like to delete it, please remove the content type from all sites and lists and then try again.

When we are trying to delete the content type we are getting the below error.
Another site or list is still using this content type. If you would still like to delete it, please remove the content type from all sites and lists and then try again.

In my case I already deleted the list, but still I am facing the same error message. The same list is available in the recycle bin, follow the same steps as per the below.

Resolution:
Delete from site recycle bin.
Delete from Site Collection > Site Settings > Site Collection Administration > Recycle Bin.
Delete from End User Recycle Bin Items.
Path: _layouts/15/AdminRecycleBin.aspx
Delete from "Deleted From End User Recycle Bin."
Path: layouts/15/AdminRecycleBin.aspx?View=2
Now you can able to delete the content type successfully.

New-SPConfigurationDatabase : The user does not exist or is not unique

When we are trying to install SharePoint 2016 using PowerShell we got the below error.
“New-SPConfigurationDatabase : The user does not exist or is not unique ” as per the below screen we face the issue.
Resolution: Make sure once you run this command in the PowerShell credential popup window will come.

New-SPConfigurationDatabase –DatabaseName SharePoint_Config –DatabaseServer DNSP2016 –AdministrationContentDatabaseName SharePoint_Content –Passphrase (ConvertTo-SecureString DotNetSharePoint2016–AsPlaintext –Force) –FarmCredentials (Get-Credential) -localserverrole SingleServerFarm

We have to enter MachineName\UserName  as per the above screen shot.

Monitoring disk space utilization using powershell

Monitoring disk space utilization is an important task in SharePoint to avoid the critical issues , we can implemented this using PowerShell to monitor the disk utilization , in this we did not kept any threshold conditions , we are generating only report in CSV format with list of all servers available  in our  environment.
We created a config file to add all servers that you want to know the disk space utilization.
Added the server names as per the below screen shot in the text file.


Please note: we are generating this only in CSV format, it is a plane text we cannot add any colors in our output file.

Add-PSSnapin microsoft.sharepoint.powershell
$resultsarray = @()
$computers = (Get-Content "d:\Allservers.txt")
$date = Get-Date -Format “dd-MM-yyyy”
foreach($computer in $computers)
{
if([string]::isnullorwhitespace($computer))
{
}
else
{
Write-Host $computer
 $drives = Get-WmiObject -ComputerName $computer Win32_LogicalDisk | Where-Object {$_.DriveType -eq 3}
 foreach($drive in $drives)
 {
  $contactObject = new-object PSObject
   $id = $drive.DeviceID
 $totalsize = [math]::round($drive.Size /1GB, 2)
 $freespace = [math]::round($drive.FreeSpace  / 1GB, 2)
 $usedspace= $totalsize-$freespace
 $freeprecent = [math]::round($freespace / $totalsize, 2) * 100
 $diskObject | add-member -membertype NoteProperty -name "Date" -Value $date
 $diskObject | add-member -membertype NoteProperty -name "Server Name" -Value $computer
 $diskObject | add-member -membertype NoteProperty -name "Drive" -Value $id
  $diskObject | add-member -membertype NoteProperty -name "Total GB" -Value  $totalsize     
   $diskObject | add-member -membertype NoteProperty -name "Used GB" -Value $usedspace   
 $diskObject | add-member -membertype NoteProperty -name "Free GB" -Value $freespace  
    $diskObject | add-member -membertype NoteProperty -name "% Free" -Value $freeprecent  
$resultsarray += $diskObject
}
}
}
$resultsarray| Export-csv -path "D:\diskreport_$date.csv" –notypeinformation

Delete SharePoint list items based on particular view using PowerShell


Send email to members of SharePoint Group using PowerShell

In this article we can see how to send email only from a particular group of people using power shell, it is very easy to user to remove/add new users whenever they want. In the below code we created a SharePoint Group with name “DotNetSharePoint”

add-pssnapin microsoft.sharepoint.powershell
$web = get-spweb -identity  "http://dotnetsharepoint.com/sites/SharePoint2013/BusinessUsers"
$groupss = $web.Groups.GetByName("DotNetSharePoint")
$emailgrouptoo =@()
foreach($user in $groupss.Users)
{
$sendemailto  =  $user.Email
$totalemail =  $sendemailto
  $emailgrouptoo+=$totalemail
 }
#You can also get this below information from Custom List also , in the article we are mainly showing how to send email to Owners Group Using PowerShell.
$smtpserver = "yourSMTP severname"
$emailfrm  =  "emailidfrom whom you have to send this email"
$Subject =  "We are sending email to Users"
$EmailBody  = "You type some information which you want to show in side the email body"
 send-mailmessage -smtpserver $smtpserver -from $emailfrm -to $emailgrouptoo  -subject $Subject -body $EmailBody

how to get the current item id for newly created item in SharePoint

In this article we can able to see how to get the current item id for newly created item, using REST API and JQuery.
 We are having a requirement to store the current item id in a Field, once we clicked on the custom save button.
We are having filed with name “RequestID” and couple of fields and having a custom button.
Call this function on “getNewRequestItemID” button click and use the below code.

<script type="text/javascript" src="/Dotnetsharepoint/SP2013/SiteAssets/jquery-1.11.0.min.js"></script>
<script type="text/javascript">
$(function () {
 var listname = "YOURLISTNAME";
  });

function getNewRequestItemID(listname){
var currentitemid=0;
var siteURL = _spPageContextInfo.webAbsoluteUrl;
 var url = siteURL + "/_api/web/lists/getbytitle('" + listname + "')/items?$select=ID&$OrderBy=ID desc&$top=1";
$.ajax({
 url: url,
 method: "GET",
 async: false,
 headers: { "Accept": "application/json; odata=verbose" },
 success: function (data) {
    if(data.d.results.length>0){
        currentitemid = data.d.results[0].ID;
  $("input[title = 'RequestID']").val(currentitemid);
    }  
 },
 error: function (data) {      
 }
});
}
 </script>
 get the current item id for newly created item in SharePoint using javascript

Microsoft Flow Features



Create automated workflows between your favorite apps and services to get notifications, synchronize files, collect data, and more.
Flow app in SharePoint Office 365
Services:   
Now Microsoft Flow supporting 90 services. SharePoint, OneDrive for Business, Dynamics 365, OneDrive, SQL Server..Reference: https://flow.microsoft.com/en-us/services/             
New Features:
 Search by service
Users will be able to see all the triggers from a service by simply selecting that service. Also, once a trigger is selected, the same process can be done to add an action, as can be seen in the following screenshots.




Switch Case
It is an important addition to the already available nested conditionals support, and it "will make it very easy to have parallel branches of conditional logic based on a single value".
You can find switch by selecting the More … option after selecting New Step and then choosing Add a Switch Case. Inside a Switch Case you will select a value from the trigger or a previous step to switch on.
Office 365 and Outlook.com services
Trigger when an email is flagged – for example, you can now automatically create a task in Todoist (or Wunderlist) whenever you flag an email in Outlook
Flag an email as an action – create filters to flag emails – for example, automatically flag emails that come from your manager
Move an email to another folder – you can also automatically move emails between folders
Connect to Local or Network File Systems and Stripe
Flow can now connect to your Local File System or a Network File System. You can log or copy files from your own local Windows desktop PC to the cloud. Likewise, if you have a team Network Share, you can connect to that from Microsoft Flow.
Finally added four other Premium services: 



You can now use Stripe from Microsoft Flow. Stripe allows private individuals and businesses to accept payments over the internet. You can track customers, orders, invoices  and more. 

 Microsoft Flow integrates with Informix and DB2 so you can connect to resources stored in IBM Informix or IBM DB2 databases. We support SELECT, INSERT, UPDATE, and DELETE operations.

     UserVoice is a product management and customer support tool that allows businesses to build a suggestions portal for their users to submit feature ideas, build a ticketing system for customer support and build articles knowledge base for users.






Delete SharePoint list items based on particular view using PowerShell

In this article you can able to see how to delete  SharePoint list items based on the particular view and also having another condition how have to delete items on every Monday, we created a couple of views what type of data have to delete based on item created date.
One view is used to delete SharePoint list items every day and another delete only on Monday.

Note:  by default list item limit is 30 items, we have to modify the view based on the requirement I change to 5000 so every day it will delete only 5000 items to delete.

add-pssnapin microsoft.sharepoint.powershell
$web = get-spweb -identity "http://dotnetsharepoint.com/sites/sharepoint/deleteitems"
$MainList = $web.lists["DeleteListItems"];
$today = (get-date).DayOfWeek
if($today -eq "Monday")
{
$view = $MainList.Views["DeleteMondaylistitems"];
}   
else
{
$view = $MainList.Views["DeleteEverydaylistitems"];
}
$items = $MainList.GetItems($view)
$totalcount = $items.Count
$j = 0;
for($i = $totalcount -1; $i -ge 0; $i--)
{
$deleteitem = $items[$i]
write-host $deleteitem.ID
$deleteitem.Delete()
}

How to add blank value to choice field in SharePoint

As per my requirement I want to show blank value in choice field, but SharePoint won’t take space as a valid option. So we can use ASCII code.
Method1: We can use Unicode character that does not print nothing. I tried with U+205F & it’s working as expected. To use this character please check the below steps.
1.    Navigate to Start -> run -> charmap
  

It will open Character Map Window.
Choose Font: Calibri, Drag down the cursor & select black check the code finally click copy the code

Paste the code in choice field and save.

Now check blank field. 

It’s working as expected.
Method 2: Use ASCII code 0129. It is empty character that SharePoint will accept as a valid option. It will appears empty on dropdown list. Hold down the ALT key and type the number 0129