Skip to main content

Posts

Showing posts from 2016

Angular JS with Salesforce Remote Actions

Using Angular JS with Remote Actions Nowadays Angular JS is a great front end framework to bind DOM objects easily and do many more things in the DOM. Here I'm going to describe how to use Angular with visual force and apex remote actions. So we can add angular code in the visual force page itself or we can add angular code to the static resource. As per the my understanding , If we use angular code in the visual force page itself it will break the single page application concept. Because when rendering a new visual force page we have to create one angular application for each visual force page. So in this post I'm going to use static resource to write angular code. And also I'm going to use welkin suite for as the IDE. Because from welkin suite we can modify the static resource bundle (But currently we cannot add js files for partial pages to static resource , only thing what we can do is modify the bundle , but it is great because we can compare the modifications what

Salesforce REST API III

After receiving the access token we will be able make requests and get data from salesforce via the rest api. When we making a request we need  to add Authorization header in each and every request that including the access token. If the access token is missing , invalid or expired we will get 401 Unauthorized error.Header value should be like below.There should be a space between OAuth and access token.                       Authorization  OAuth  access_token. Salesforce rest api has a service ( one of my favorite service ) to make queries through the request. So we will make a select query get all the accounts in salesforce. Sample service :   https://login.salesforce.com/services/data/v34.0/query?q='you query goes to here' Now I'm going to get all accounts in salesforce by using 'SELECT Id , Name FROM Account LIMIT 10' query. Here getting only 10 records because of the salesforce governor limit. therefore I need to send  below get request with the Au

Salesforce REST API - Part II

We have created a Connected App in Part I , so now we need to make requests through the rest api. So as I mentioned earlier we need grant_type , client_id , client_secret , username , password parameters to authenticate with the salesforce in order to call to the endpoint https://login.salesforce.com/services/oauth2/token. And that request should be a POST request. What will happen here is once we send that POST request with the parameters if it is a successful authentication it will return a access token.This access token is same as the session id. After that each and every request we need to attach the access token in the header. Behind the seen salesforce validate the access token and if it is validate it will returning the request data. if the validate fails salesforce returning 401 unauthorized error.  As you know session has expire time. As same as salesforce access token has expire time.You can change access token settings by clicking the Connected App's

Salesforce REST API

This post describe about the salesforce rest api and using salesforce rest api . Salesforce implements the OAuth to authenticate soap and rest calls with the client. So I will describe with the simple steps, how to create salesforce app that expose outside to authenticate and call rest methods. First you need to create a salesforce developer account if you don't have an developer account or sandbox account. If you don't have an developer account go with the following link and create an account. It's free.   https://developer.salesforce.com/signup . Once you create the developer account go to https://login.salesforce.com/ and login with your credentials.     Navigate to setup and type app and you will be able to find Apps section and click the link. So now you will be able to find Connected Apps section and click New. What we doing here is creating a connected app and that app will exposing to outside to authenticate and call rest api calls. So you can insert C