Kashif Nizam Qureshi


Leave a comment

SharePoint Workflow Not Starting

I created new List and a new worfklow. Workflow had only log activity and it worked on Item creation.

Then I started copying activities from my problematic workflow and in between it had same issue. I couldn’t get exactly which activity was had problem but it worked after several attemps of copy paste🙂

Another point to be noted, most of the time when I was publish the workflow. The check “Automatically run workflow on item creation” gets unchecked.


Leave a comment

Email Error / Issues in SharePoint and Project Server

Project Server Workflow Email:
I have clubbed together all the issue/errors related to workflow emails.

Workflow status was showing following error.

Retrying last request. Next attempt scheduled in less than one minute. Details of last request: HTTP InternalServerError to http://server/PWA/_vti_bin/client.svc/sp.utilities.utility.SendEmail Correlation Id: 8108ea7a-3466-4da4-a8ad-4a88f6a1ea20 Instance Id: a6cb140e-edba-4a64-ac6f-6df21fd8c14f

Retrying last request. Next attempt scheduled in less than one minute. Details of last request: HTTP InternalServerError to http: //epmtest/PWA/_vti_bin/client.svc/sp.utilities.utility.SendEmail Correlation Id: 244a2044-745c-752d-b569-595cf56c5c0d Instance Id: 134a1388-7cf3-4122-a07d-f8b524617df3

After few minutes….

RequestorId: 63ac78dc-888c-a459-0000-000000000000. Details: An unhandled exception occurred during the execution of the workflow instance. Exception details: System.ApplicationException: HTTP 500 {“Transfer-Encoding”:[“chunked”],”X-SharePointHealthScore”:[“4″],”SPClientServiceRequestDuration”:[“6″],”SPRequestGuid”:[“63ac78dc-888c-a459-8685-187110c0fbfe”],”request-id”:[“63ac78dc-888c-a459-8685-187110c0fbfe”],”X-FRAME-OPTIONS”:[“SAMEORIGIN”],”MicrosoftSharePointTeamServices”:[“15.0.0.4617″],”X-Content-Type-Options”:[“nosniff”],”X-MS-InvokeApp”:[“1; RequireReadOnly”],”Cache-Control”:[“max-age=0, private”],”Date”:[“Fri, 19 Dec 2014 18:56:24 GMT”],”Server”:[“Microsoft-IIS\/8.5″],”X-AspNet-Version”:[“4.0.30319″],”X-Powered-By”:[“ASP.NET”]} at Microsoft.Activities.Hosting.Runtime.Subroutine.SubroutineChild.Execute(CodeActivityContext context) at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager) at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)

Though, email was configured at PWA and Web application level but still had to be configured at farm level to solve this error.

Courtesy: http://ppmworks.com/project-server-workflow-send-email-action-was-not-working-correctly/


Leave a comment

Setting Up Email/SMTP Configuration for SharePoint and Project Server

Though it’s quite simple to configure emails on SP and PS, there are a couple of reasons I wanted to post about it.

First, we’ll see where we need to go and configure SMTP settings for emails.

Farm Level:
Central Administration -> System Settings -> Configure outgoing e-mail settings [Under E-Mail and Text Messages(SMS)]

Sharepoint 2010

Web Application Level:
Central Administration -> Application Management -> Manage web applications [Under Web Applications]

Select web application and click General Settings [Under Manage] and then select Outgoing E-email settings.

SMTPSettings

Project Server Instance Level:
Central Administration -> Application Management -> Manage service applications [Under Service Applications]-> Project Server Service Application

Select the PS instance and click Manage and then select Alerts and Reminders under Operational Policies.


Leave a comment

Redirecting User to Approval Edit Form Automatically

Add following html in a content editor of workflow task display form. This will redirect user to editable approval form.

 

<script src="/PWA/SiteAssets/RedirectToEditForm.js"></script>

the javascript file RedirectToEditForm.js should have the following code:

    var origUrl = window.location.toString();
    var editUrl = origUrl.replace(&amp;quot;DispForm&amp;quot;,&amp;quot;EditForm&amp;quot;);
    window.location = editUrl;


Leave a comment

Upload Document From PDP to Project Site


&lt;input id=&quot;inputFile&quot; type=&quot;file&quot;/&gt;&lt;input id=&quot;uploadDocumentButton&quot; onclick=&quot;uploadFile()&quot; type=&quot;Button&quot; value=&quot;Upload Document&quot;/&gt;&lt;script src=&quot;/PWA/SiteAssets/jquery.min.js&quot;&gt;&lt;/script&gt;&lt;script type=&quot;text/javascript&quot;&gt;
//Function attached to the html fileupload tag (&lt;input type=&quot;file&quot;&gt;)
function uploadFile(){
    if (document.getElementById(&quot;inputFile&quot;).files.length === 0) {
        alert('No file was selected');
        return;
    }
    var parts = document.getElementById(&quot;inputFile&quot;).value.split(&quot;\\&quot;);
    var ExtPart = document.getElementById(&quot;inputFile&quot;).value.split('.').pop();

//Limiting project name to 32 characters long,
//as this will increase the file upload ajax call.
        
    var filename = "NYUAD-PMO_" + PDP_projName.substring(0,32) + "_Project Charter-Template_v1_0." + ExtPart;

    //var filename = &quot;NYUAD-PMO_&quot; + PDP_projName + &quot;_Project Charter-Template_v1_0.&quot; + ExtPart;
    var file = document.getElementById(&quot;inputFile&quot;).files[0];
    var getUrl = &quot;http://sps2013/PWA/&quot; + PDP_projName;
  //If project name contains spaces, below method will replace it with %20 or any other special characters
    var getUrl = "http://dcwap-v225-pmo/pwa/" + encodeURIComponent(PDP_projName);
  
    
uploadFileSync(getUrl , &quot;Documents&quot;, filename, file);
}

//Upload file synchronously
function uploadFileSync(spWebUrl , library, filename, file)
{
        var reader = new FileReader();
    reader.onloadend = function(evt)
    {
      if (evt.target.readyState == FileReader.DONE)
      {
         var buffer = evt.target.result;
         // To upload files to root folder
         //var completeUrl = spWebUrl
         //  + &quot;/_api/web/lists/getByTitle('&quot;+  library + &quot;')&quot;
         //  + &quot;/RootFolder/Files/add(url='&quot;+ filename +&quot;',overwrite='true')?&quot;
         //  + &quot;@TargetLibrary='&quot;+ library +&quot;'&amp;@TargetFileName='&quot;+ filename +&quot;'&quot;;

         // To upload files to sub-folder
         var completeUrl = spWebUrl
           + &quot;/_api/web/lists/getByTitle('&quot;+  library + &quot;')&quot;
           + &quot;/RootFolder/Folders('Initiation%20Phase')/Folders('PCID')/Files/add(url='&quot;+ filename+&quot;',overwrite='true')?&quot;
           + &quot;@TargetLibrary='&quot;+ library +&quot;'&amp;@TargetFileName='&quot;+ filename +&quot;'&quot;;           

          $.ajax({
                url: completeUrl,
                type: &quot;POST&quot;,
                data: buffer,
                async: false,
                processData: false,
                headers: {
                    &quot;accept&quot;: &quot;application/json;odata=verbose&quot;,
                    &quot;X-RequestDigest&quot;: $(&quot;#__REQUESTDIGEST&quot;).val(),
                    &quot;content-length&quot;: buffer.byteLength
                },
                complete: function (data) {
                    alert('succes');
                },
                error: function (err) {
                     alert('failed');
                }
        });
      }
    };
    reader.readAsArrayBuffer(file);
}
&lt;/script&gt;


Leave a comment

Querying Projects Document from Site and Displaying them in PDP

<div id="LeftNavForMySite">
   <table width="400">
      <tbody>
         <tr>
            <td>File Name</td>
            <td> Last Modified</td>
         </tr>
         <tr>
            <td>
               <a href="/PWA/Application%20Project/Shared%20Documents/Initiation/general.css">general.css</a></td>
            <td>2016-07-03 21:23 </td>
         </tr>
      </tbody>
   </table>
</div>
<script type="text/javascript">
 
//We need to run our function only after sp.js file loads
ExecuteOrDelayUntilScriptLoaded(ViewItem, "sp.js");
 
 
function ViewItem()
{
 var projuid=  PDP_projUid;
 var url="/PWA/"+ PDP_projName;
   
var context = new SP.ClientContext(url);
  
var web = context.get_web();

var list = web.get_lists().getByTitle('Documents');
 
//CamlQuery()
//For querying Nth level within the library
//var query = SP.CamlQuery.createAllItemsQuery();

//For querying to current library or folder if defined below
var query = new SP.CamlQuery();

//Leading forward slash was the pain in the ass in the below line
//Folder structure starts with library name and follows folder names.
query.set_folderServerRelativeUrl('Shared%20Documents/Initiation');

allItems = list.getItems(query);
context.load(allItems, 'Include(Title, ContentType, File, Modified, FileSystemObjectType)');
context.executeQueryAsync(Function.createDelegate(this, this.success),   Function.createDelegate(this, this.failed));
}
 
function success()
{
 //alert('s');
 var table='<table width="400"><tr><td>File Name</td><td> Last Modified</td>';
 var modified="";
  var fileUrls = "";
  var ListEnumerator = this.allItems.getEnumerator();
   while(ListEnumerator.moveNext())
   {
// alert('d');
    var currentItem = ListEnumerator.get_current();
    
   //if(currentItem.get_fileSystemObjectType() == '1')
   //{
   //   alert(currentItem.get_item('Title'));
   
      
     var _contentType = currentItem.get_contentType();
     if(_contentType.get_name() != "Folder")
       {
        var File = currentItem.get_file();
        if(File != null)
          {
          //alert(currentItem.get_item('Modified'));
          modified=String.format("{0:yyyy}-{0:MM}-{0:dd} {0:HH}:{0:mm} ",new Date(currentItem.get_item('Modified')));
          fileUrls += File.get_serverRelativeUrl() + '\n';
           table=table+'<tr>';
            table=table+('<td><a href="'+fileUrls+'">'+File.get_name()+'</a></td><td>'+modified+'</td></tr>');
          }
       }
    //}
  }
  
         //Getting the empty div tag
         fieldNameElement=document.getElementById('LeftNavForMySite');
 
         //Assign the string formed to the div element's innerHTMl to display on page
         fieldNameElement.innerHTML=table+"</table>";
 }
 function failed(sender, args) {
  alert("failed. Message:" + args.get_message());
 }
  
</script> 
Follow

Get every new post delivered to your Inbox.