Tuesday, July 14, 2015

SQL Quick Tip

Concatenating Text and INT

SELECT 'text' + CAST(ID AS VARCHAR(20)) 

Monday, May 18, 2015

REST operations in SharePoint 2013

REST operations are essential in any SharePoint development. This series explain available REST endpoints in SharePoint 2013. First article shows how we can made a REST call in both SharePoint Hosted and Provider Hosted app.

Executing a REST GET call from SharePoint Provider Hosted App

First you need to refer related JavaScript related.

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script type="text/javascript" src="#SPWeb/_layouts/15/MicrosoftAjax.js"></script>
<script type="text/javascript" src="#SPWeb/_layouts/1033/init.js"></script>
<script type="text/javascript" src="#SPWeb/_layouts/15/sp.core.js"></script>
<script type="text/javascript" src="#SPHost/_layouts/15/SP.RequestExecutor.js"></script>
<script type="text/javascript" src="#SPWeb/_layouts/15/sp.js"></script>


You need to replace the #SPWeb from Appweb Url and #SPHost from Host web Url. App Web Url and Host Web Url is available in Url.



You can find these parameters as QueryString and available in SPAppWebUrl, SPHostUrl.



You need to specify the AppWebUrlUrl in the method below. If you are good at jQuery you can change the method by introducing Deferred Object.






function getREST(url,success,fail){
 
  // specify your web app url here
  // EX- https://oapp.sharepoint.com/sites/AWM/ArtWorkManagement
  var AppWebUrlUrl = "";  
  var executor = new SP.RequestExecutor(AppWebUrlUrl);
 
  executor.executeAsync(
       {
           url: AppWebUrlUrl + url,
           method: "GET", 
           contentType: "application/json;odata=verbose",
           headers: { "Accept": "application/json; odata=verbose" },
           success: function (data) {
               if(success){success(data);} // call the function if done
           },
           error: function (data, errorCode, errorMessage) {
               if(fail){fail(data);} // call the function if done
           }
       }
);
}


Executing a REST GET call from SharePoint Hosted App



You need to specify the AppWebUrlUrl in the method below.






function getREST(url,success,fail){
 
  // specify your web app url here
  // EX- https://oapp.sharepoint.com/sites/AWM/ArtWorkManagement
  var AppWebUrlUrl = "";  
 
    $.ajax({
            method: "GET",
            url: AppWebUrlUrl + url,
            success: function (data) {
                if(success){success(data);} // call the function if done
 
            },
            error: function (data) {
                if(fail){fail(data);} // call the function if done
            }
        });
 }


Calling the Function






function done(data){
  // success
}
 
function error(){
    // Error
}
 
var restUrl = "" // Your URL goes here
getREST(restUrl,done,error);
 
 

Friday, April 24, 2015

Configure outgoing e-mail settings with Office 365 SMTP server in SharePoint Server 2013 – Part 4

First check the SMTP server is installed in the server. You can check that on Server Manger and Features section.

image_thumb9_thumb_thumb

If it is not installed first you need to install the SMTP in the server. SMTP server needs port 25 opens in the firewall in default.

After setting up the SMTP server you need to open the IIS Manger.

image_thumb12_thumb_thumb

before stating the SMTP Virtual server need to configure some properties. Right click the SMTP virtual Server and click on the Access Tab. Click on Relay.. button on the Relay restrictions.

image_thumb15_thumb_thumb

This section specified which server can use the SMTP for mail relay. So either you need to select Only the list below and add IP Addresses of all server which used to send the emails (ex:-WFE, APP) or let all servers to send emails by All except the list below and putting nothing on the list.

image_thumb19_thumb_thumb

Then Click on Authentication.. button on Access Control section and make the checkbox for Anonymous access.

image_thumb22_thumb_thumb

Then click ok and go to the Delivery Tab.

image_thumb[2]_thumb

Outbound Security section allows you to provide credential for receiving server. Since we are using local SMTP server you can make this as a Basic authentication and type your User name and Password and click the TLS encryption.

image_thumb[3]

Outbound Connection section you can change the default port using.

image_thumb[6]

Advanced.. section you need specify the Smart host for forwarding the email for Gmail SMTP server (smtp.gmail.com).

You can route all outgoing messages for remote domains through a smart host instead of sending them directly to the domain. This permits you to route messages over a connection that may be more direct or less costly than other routes. The smart host is similar to the route domain option for remote domains. The difference is that after a smart host is designated, all outgoing messages are routed to that server. With a route domain, only messages for the remote domain are routed to a specific server.

image_thumb[9]

You can find the Gmail SMTP server settings here.

Then start the SMTP virtual server.

image_thumb[19]_thumb

After that you can find the fully qualified name in General Tab and proceed with the Outbound SMTP settings as Part 1.

image_thumb[16]_thumb