Thursday, 29 March 2018

Is it possible to create a modern SPFx web part as a control in Page Layout (Template)?

There are many question whether it is possible to create a modern SPFx web part as a control in Page Layout (Template).

Yes, there is a workaround which is far from ideal but works:

·                         Export your SPFx webpart from the browser (.webpart file).

·                         Upload the .webpart file to the webpart gallery.

·                         Open SharePoint designer

·                         Navigate to page layouts folder from your SharePoint designer

·                         Right click on your page layouts

·                         Open the page layouts (ie: .aspx) as preview in browser

·                         Manually edit the aspx file in browser by clicking on edit button or by navigating using the URL “?ToolPaneView=2&pagemode=edit”

·                         Add the required SPFx webpart from the “Add Webpart” section.

·                         Save the aspx and when you create a page using the page layout, your SPFx webpart should be there.

Note: Please ignore the error while saving the .aspx page from browser. Just refresh your page then webpart will get added automatically.

Here you go!

Your page layout is ready with SPFx webpart. 



SPFx Web part: Common Errors & Solutions while executing gulp serve
You might have challenges while executing the gulp serve command. The common errors and solutions are provided in this article
Error 1: Gulp is not recognized
Solution:
Please execute the below commands in your Node.js command prompt window to resolve the issue
u  npm install -g gulp
u  npm install --save-dev gulp

Error 2: Missing Node-SASS
Error - [sass] Error: Missing binding C:\XXX\YYYY/Documents\SPFx\Projects\documentcardexample-webpart\node_modules\node-sass\vendor\win32-x64-46\binding.node
Node Sass could not find a binding for your current environment: Windows 64-bit with Node.js 4.x
Found bindings for the following environments:
          Windows 32-bit with Node.js 4.x
Solution:
u  This usually happens because your environment has changed since running npm install.
u  Run npm rebuild node-sass to build the binding for your current environment.
Error 3: Cannot find Node Module
Cannot find module <Module_name>
Solution:
npm install <module_name> –save
Eg:
u  Npm install moment-timezone –save
u  Npm install @types/moment –save
u  Npm install @types/moment-timezone –save



Error 4: Cannot find module jquery
Solution:
 Try using npm to install the typings
u  npm install jquery –save
Error 5: Cannot find module react-slick/dist/react-slick
Solution:
Try using npm to install the typings
u  npm install react-slick


Thursday, 29 October 2015

Get string collection value from REST Api in sharepoint hosted app workflow and show in history



Use getDynamicValueProperty<DynamivValue>
"d/ToEmailUsersId/results"

Pass the result in foreach activity ,get Email and add it the to collection.

Populate Taxonomy Value into New Form.aspx from DispForm.aspx


 var webTaggingCtl = $get(""+internalName+"_$container");
 var taxCtlObj = new Microsoft.SharePoint.Taxonomy.ControlObject(webTaggingCtl);                taxCtlObj.enableControl(true);                                                                                                        taxCtlObj.setRawText(listItem.get_item(internalName).get_label()+"||"+listItem.get_item(internalName).get_termGuid());
 taxCtlObj.retrieveTerms();
            
internalName=Taxonomy Column Name;
listItem.get_item(internalName).get_label()- To get Taxonomy Label name from list
listItem.get_item(internalName).get_termGuid() -To get guid from list


Thursday, 15 October 2015

How to move list item attachment from one list to another list in SharePoint office 365 using REST API

Getting attachment from one list and post it in another list
var hostweburl;
var appweburl;
var FileName;
var serverrelativeurl;
// This code runs when the DOM is ready and creates a context object which is  
// needed to use the SharePoint object model
$(document).ready(function () {

    //Get the URI decoded URLs.  
    hostweburl =
        decodeURIComponent(
            getQueryStringParameter("SPHostUrl"));
    appweburl =
        decodeURIComponent(
            getQueryStringParameter("SPAppWebUrl"));
    // Resources are in URLs in the form:
    // web_url/_layouts/15/resource
 
    advancedSearch.getattachment();
    // Load the js file and continue to load the page with information about the list top level folders.
    // SP.RequestExecutor.js to make cross-domain requests

    // Load the js files and continue to the successHandler
   
});
var advancedSearch = {
    getattachment: function () {
        var filterQuery = appweburl + "/_api/SP.AppContextSite(@target)/web/lists/getByTitle('crosslist')/items?$select=AttachmentFiles,Title&$expand=AttachmentFiles&@target='" + hostweburl + "'";
        advancedSearch.getFieldDetails(filterQuery,
                       function (data) {


                           var jsonObject = JSON.parse(data.body);
                           var results = jsonObject.d.results;

                           $.each(results, function (index, items) {//looping all the items
                               //Get Admin web url
                               var attchments = items.AttachmentFiles;
                               $.each(attchments.results, function (indx, attch) {//looping all the attachments
                                   var FileName1 = attch.FileName;
                                   var serverrelativeurl1 = attch.ServerRelativeUrl;
                                   getFileContent(serverrelativeurl1, FileName1);
                               });
                           });
                         
                           console.log(FileName);
                           console.log(serverrelativeurl);
                     
                       });
    },
    getFieldDetails: function (url, successHandler, errorHandler) {
        var executor;
        // Initialize the RequestExecutor with the app web URL.
        executor = new SP.RequestExecutor(appweburl);
        executor.executeAsync({
            url: url,
            method: "GET",
            headers: {
                "Accept": "application/json; odata=verbose"
            },
            success: successHandler,          
            error: errorHandler
        });
    }
}

function getFileContent(serverrelativeurl,fileName)
{
    //var url=
    var executor;
    // Initialize the RequestExecutor with the app web URL.
    executor = new SP.RequestExecutor(appweburl);
    executor.executeAsync({
        url: appweburl + "/_api/SP.AppContextSite(@target)/web/GetFileByServerRelativeUrl('"+serverrelativeurl+"')/$value?@target='" + hostweburl + "'",
        method: "GET",
        binaryStringResponseBody: true,
        success:
         function (data) {
             var fileContent = data.body;
             alert(fileContent);
  // once we have the file perform the actual upload
            execCrossDomainRequest(fileContent, fileName);
         
            },
            error:  function (err) {
                alert("error: " + err);
            }
   });
}


// Function to prepare and issue the request to get
//  SharePoint data
function execCrossDomainRequest(strfileContent, strFileName) {
   
    var executor;
    // Initialize the RequestExecutor with the app web URL.
    executor = new SP.RequestExecutor(appweburl);
    executor.executeAsync(
    {
        url: appweburl + "/_api/SP.AppContextSite(@target)/web/lists/getbytitle('CustomList5')/items(2)/AttachmentFiles/add(FileName='" + strFileName + "')?@target='" + hostweburl + "'",
        method: "POST",
        processData: false,
        headers: {
            "Accept": "application/json; odata=verbose",
            "X-RequestDigest": $("#__REQUESTDIGEST").val()
        },
        contentType: "application/json;odata=verbose",
        binaryStringRequestBody: true,
        body: strfileContent,
        success: readContents,
        error: function (err) {
            alert('Oops! Document attached created fail.');
        }
    }
    );
}

function readContents(data) {
    alert(data.body.toString());
}
// Retrieve a query string value.  
// For production purposes you may want to use  
// a library to handle the query string.  
function getQueryStringParameter(paramToRetrieve) {
    var params =
        document.URL.split("?")[1].split("&");
    for (var i = 0; i < params.length; i = i + 1) {
        var singleParam = params[i].split("=");
        if (singleParam[0] == paramToRetrieve)
            return singleParam[1];
    }
}





Reference
http://techmikael.blogspot.in/2013/07/how-to-copy-files-between-sites-using.html

Monday, 15 April 2013

How to Change the link as a Image in sharepoint designer web part ?

1. We want to select the binded url in web part

2. Select the following image hyperlink option link

3. Then popup the following message




4.Select Yes and then choose the site location image and then edit the web part the following source code

  
<xsl:choose>
<xsl:when test="$desc=''">
<xsl:value-of select="$url" /></xsl:when>
<xsl:otherwise>
<a href="{$url}" ></a></xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
5.Then change the following way the above code

<xsl:choose>
<xsl:when test="$desc=''">
<xsl:value-of select="$url" /></xsl:when>
<xsl:otherwise>
<xsl:variable name="positeurl" select="substring-before($desc, '/Purchase%20Order')"/>
<xsl:variable name="positeimgurl" select="concat($positeurl, '/Style%20Library/Images/img-icon-discuss.png')"/>
<a href="{$url}" ><img alt="" src="{$positeimgurl}" border="0" /></a></xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>

6. Save & Close it.






Thursday, 22 November 2012

Reporting services configuration and create reports for list

Step 1: Configuring SQL Reporting Services – Web Service URL

Simply go to Reporting Services Configuration Manager and choose Web Service URL and populate the following needed information. The fields are named properly so I guess there is no need for further explanation. What this does is that it configures the IIS for you depending on what Virtual Directory names you had declared.

Step 2: Configuring SQL Reporting Services – Create a Report Database

Same here, fields need no further explanation except for one which is Native Mode and SharePoint Integrated mode which I will explain below.
Choose create a database or if you already have one choose an existing one. For this example, we will create a new one:

Connect to the database where you want your Report Data to be stored:

Give it a Name and a Report Server Mode.
With SharePoint Integrated Mode the report RDLs are stored on SharePoint and not in the Report Database. For this instance, we will use the SharePoint Integrated Mode:

Specify the credentials that the report server will use to connect to the database.

Review your configuration.

Then wait while it's configured.

Step 3: Configuring SQL Reporting Services – Create a Report Manager URL

What this does is that it configures the IIS for you depending on what Virtual Directory names you had declared.

That’s it. At this point, your report server is configured for SharePoint Integration 2010.

Step 4: SharePoint Integration Configuration – Reporting Services Integration

Simply go to SharePoint 2010 Central Administration, then General Application Settings, then choose Reporting Services Integration.

Now populate the fields using the Web Service URL you had configured a while ago on Step 2 of this guide.

Once done, you will see the Activation State message.

Step 5: SharePoint Integration Configuration – Add a Report Server to the Integration

Now add the report server by putting the Server Name and the Server instance.

At this point it's all done, all you have to do now is try it out.


 Afetr Reporting service configuration u need to do following steps
Start-->All Programs-->Microsoft SQL Server 2008 R2-->SQL Server Business Intelligence Studio
 The BIDS window shown in below


The next few steps show you how to build a Report that shows all the products from thesample database. 
  1. Open BIDS
  2. Create New project
  3. Select Report Server projet template (Fill in name etc.)

4.  Your Solution explorer should look like this

5. Right click Shared datasource and select “Add New Data Source”
6. Give it a name “Datasource” and choose Type as sharepoint list
7. Then give connection string as your server name, then  press ok
8. Right click Shared Datasets and select “Add New Data Sets”
9. Give Dataset name and click query designer to query your list

Click Query Designer
From here you can select columns which you need to show in reports
choose required Fields and give ok



Then Right Click On reports
You can see report wizard now..
STEP1: Give next
STEP2: Next
STEP3: Click Query Builder and choose list columns
STEP4: Then give next
STEP5: Choose Tabular and give next
STEP6: Add all your columns as a details give next
STEP7: Choose Color
STEP8: Finish
STEP9: Then your report will look like this

Click on report data in leftside and choose parameters if u want to filter reports.Here i filtered using status.if status is completed it will show completed reports so i dint choose any parametes ..just i filtered the details like this

After setting all things give ok
Final step:
You need to deploy this in your site for this we have to give 3 urls
SITE URL
2 LIBRARIES URL
-->REPORT CONNECTION-to show datasource
-->REPORTS-to show reports
GIVE THESE URL LIKE BELOW
TargetDataSourceFolder http://server/site/doclib
TargetReportFolder http://server/site/doclib
TargetServerURL http://server/

If you deployed successfully it will retrieve you to the corresponding document libaray and if u click on the reports it will show ur reports..Thats it..

Happy Reporting!!!!!!!!
Thanks:)