Skip to content

Consuming Salesforce API in Dot Net Applications

Consuming_Salesforce_API_in_.Net_Applications.jpg

Overview: Salesforce provides Customer Relationship Management (CRM) to help Companies serve their customers in an efficient way.

In real time, we may not work with all the data that was present in the salesforce and it is also tedious to follow all the connection process to the salesforce every time even for trivial things.

This can be avoided by automating the connection process to the salesforce through MVC.NET, and thus interacting with the relevant salesforce data.

Application Use case:

Our application creates Account information in salesforce and retrieves it from salesforce through MVC .Net application.

SalesforceAPI.cs

Implementation Steps:

    • Create an MVC Web application using Visual Studio.
    • Add a Web reference into it as shown like in the below video.
      https://www.pixentia.com/documents/blogs/2015/jul/salesforceblog/screen1/story.html
    •  Now it will generate .wsdl files into our project.
    • Add salesforce login details like username and password in configuration file to use them while login process.
    • Add helper files which will define all the salesforce integration logic for creating and retrieving information.
    • Refer .WSDL file to trace the field names related to the Account information.
    • Add the below logic for validating login information. 
    • Below logic creates a SforceService object and uses login method of it to validate the user login name and password.On successful login this method returns empty string else it will return the error message.

 errormessage.jpg

  •  Now add the below logic to save the Account information to the salesforce by using SOQL (Salesforce Object Query Language) query.
  • Below logic checks initially whether we logged in to the salesforce, if not it returns the control back to the user. Else it will create the account information by creating new object of Account class and passing necessary attributes to it.
  • Then by using salesforce object, it will create the account information in salesforce with the help of create method.
  • On successful Account information creation, it will return the Account ID.
accountid.jpg
  • We can view the Account information that we have created previously in the salesforce by using ‘query’ method of salesforce object, and by passing SOQL query as an argument to it.
  • Add the below code to retrieve the Account Information and store it in the Account list object

accountlistobject.jpg

http://www.pixentia.com/documents/blogs/2015/jul/salesforceblog/screen2/story.html

 

Phenomecloud is an enthusiastic family of individuals, fervent to make lives simpler through effective use of technology. Our mission is to implement solutions that drives business results. Know more insights from our thoughts and experience.

Contact us today or call 1-855-978-6816 to talk with us about your business needs.

Leave a Comment