1

I'm attempting to use this Simple console example on github as suggested in this answer here. sorry for coming here so much, I just need to make progress.

There is a link of the code that keep throwing an error.

Error CS0029 Cannot implicitly convert type
'Salesforce.Common.Models.SuccessResponse' to 'string'
UserAccounts D:\Salesforce-Research\UserAccounts\View\Program.cs 108

enter image description here

I've compared that line with similar lines in the code:

Console.WriteLine("Creating a parent record (Account)");
dynamic a = new ExpandoObject();
a.Name = "Account from .Net Toolkit";
a.Id = await client.CreateAsync("Account", a);

I've fiddled with the line, trying all different sorts of formats, including parsing the result or parts of it to Account or string (yes I'm desperate). I've checked that it is expecting a string (well it is as Account Id is a string).

I can only assume the code is correct.

  1. Is it correct?
  2. If it is correct what am I supposed to do?

thanks.


edit

I've decided to go with this:

var account = new Account { Name = "Test Account" };
// account.Id = await client.CreateAsync(Account.SObjectTypeName, account);
var success1 = await client.CreateAsync(Account.SObjectTypeName, account);

if(account.Id == null)
{
    Console.WriteLine(success1.Errors.ToString() + "Failed to create test record.");
    return;
}

AND IT DOESN'T WORK

2
  • what is the result of your last code example? What doesn't work? Commented Oct 15, 2015 at 7:12
  • it gives me an empty [] on the errors, so when I put tostring on the variable, it gives it's type.. Salesforce.commons.models.successresponse
    – user25387
    Commented Oct 15, 2015 at 7:24

1 Answer 1

4

CreateAsync method returns SuccessResponse. It has three properties: string Id, object Error, and string Success. So, this should work:

var response = await client.CreateAsync("Account", a);
string Id = response.Id;

Your example code worked in the past, but when you take a look at THIS COMMIT, you'll see that - thanks to wadewegner - the return type of CreateAsync is no longer string but the SuccessResponse.

1
  • This helped me, thank you @Bart . For some other people like me, there are 3 instances in the program.cs file. Need to change them all. Works just well in VS2013. Commented Aug 17, 2016 at 17:25

You must log in to answer this question.