0

There's an image of investment declaration form.

Investment declaration form

This module is in web application project, where an employee can declare his yearly investment and finally save it. After saving the document page my database table looks like this.

Investment table

Every component is saved as a new record in the database for a particular employee.

My question is can I implement this module in the mobile app through web API? If yes then please explain to me how?

0

Yes you can create Multiple records using 1 single API call. Its called as salesforce composite API.

Eg: to create multiple Investments in 1 api call, you send the JSON list like

{
  "compositeRequest" : [
  {
    "method" : "POST",
    "url" : "/services/data/v38.0/sobjects/InvestMent__C",
    "referenceId" : "investMent1",
    "body" : { "EmployeeId" : "22" }
  },{
    "method" : "POST",
    "url" : "/services/data/v38.0/sobjects/InvestMent__C",
    "referenceId" : "investMent2",
    "body" : {
      "EmployeeId" : 23",

    }
  }] 
}

Endpoint : instance endpoint/services/data/API version/composite/

https://developer.salesforce.com/blogs/tech-pubs/2017/01/simplify-your-api-code-with-new-composite-resources.html

  • The Declared Investment is of one employee only, Only the records are inserted multiple times in the same table. you can check the database image. Anyway my question is how will i catch this request? I mean how will controller look like? I am not at all aware about salesforce – Tausif Khan Oct 15 '18 at 11:11
  • Also do i need to add anything to implement salesforce? I mean i am currently using c# MVC, and for testing i am using fiddler. I am sending the multiple data through Body i.e POST request but i am getting a null value on my controller. I am really stuck with this module – Tausif Khan Oct 15 '18 at 11:22
  • Its hard to get what you mean? There is no custom MVC controller behind in Salesforce, You can design that yourself. Can you edit the question to clarify what you exactly want? – Pranay Jaiswal Oct 15 '18 at 11:27
  • I mean to say i am already working on this project which is in c# MVC, Now i came across this Investment declaration module. So is there anyway to achieve this by c# MVC? To be honest i don't know what salesforce is or how it is used? – Tausif Khan Oct 15 '18 at 11:43
  • If you are seeking about C# MVC then i Belive this is not the right platform, we can guide about SF or SF endpoints to fetch or upsert data. – Pranay Jaiswal Oct 15 '18 at 11:48
0

I have created a DotNet Standard library to call Salesforce API.

https://github.com/ste80/DotNetForce

https://nuget.org/packages/DotNetForce

https://nuget.org/packages/DotNetForce.Schema

System.Net.ServicePointManager.DefaultConnectionLimit = int.MaxValue;
System.Net.ServicePointManager.Expect100Continue = true;
System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;
var client = await DNFClient.LoginAsync(new Uri("https://www.salesforce.com"), "YOUR_CLIENT_ID", "YOUR_CLIENT_SECRET", "YOUR_USER_NAME", "YOUR_PASSWORD");
var invMent = Schema.Of(s => s.InvestMent__C);
var records = new List<JObject>();
foreach (var item in dbSource)
{
    list.Add(Schema.Wrap(new JObject())
        .Set(invMent.EmployeeId, "22")
        .Unwrap(invMent));
}
var result = await Client.Composite.CreateAsync(records).ConfigureAwait(false);
DNF.ThrowIfError(result);

The above command will create all "records" in Salesforce (1000 records for 1 API call)

Let me know if you need help on this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.