Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. Salesforce
  3. Question
Salesforce

Cannot implicitly convert type 'Salesforce.Common.Models.SuccessResponse' to 'string'

Asked by Robin Rose Aug 8, 2021 1.2K views 1 answer
Share

About this question

 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 to the code that keeps throwing an error.

Error CS0029 Cannot implicitly convert type

'Salesforce.Common.Models.SuccessResponse' to 'string'

UserAccounts D:Salesforce-ResearchUserAccountsViewProgram.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.


Is this correct?


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


Your answer

1 Answer

More Salesforce discussions

Learn & Explore

Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.

Latest Salesforce Blogs

Guides, tips and career advice on Salesforce from JanBask experts.