You need to sign in to do that
Don't have an account?
Why this doesent work?
using System;
using System.Collections.Generic;
using System.Text;
using WSDL.com.salesforce.Enterprise;
namespace WSDL
{
class MainFunction
{
static void Main()
{
SforceService connection = new SforceService();
LoginResult sfLoginResult = connection.login("XXX, "XXX");
connection.Url = sfLoginResult.serverUrl;
connection.SessionHeaderValue = new SessionHeader();
connection.SessionHeaderValue.sessionId = sfLoginResult.sessionId;
Lead sfLead = new Lead();
sfLead.FirstName = "Mayer";
sfLead.LastName = "asdasd";
sfLead.Company = "asdas";
sfLead.Title = "asdas";
sfLead.Phone = "asdas";
sfLead.Email = "asdas";
sfLead.State = "asdas";
sfLead.LeadSource = "Web";
SaveResult[] sr = connection.create(new sObject[] { sfLead });
Console.ReadKey(true);
}
}
}
the returned SaveResult will indicate the new record's Id, or tell you what error happened that caused it to not create the record, so start by looking at that. Otherwise you'll have to describe how its not working.
Hello,
Is there any error you get while you run application? Can you please provide more details?
Regards,
Keyur Patel
Try adding something like this after SaveResult
SaveResult[] sr = connection.create(new sObject[] { sfLead });
// Check results.
for (int i = 0; i < sr.Length; i++)
{
if (sr[i].success)
{
Console.WriteLine("Successfully created Object: " + sr[i].id);
}
else
{
Console.WriteLine("Error: could not create sobject " + "for array element " + i + ".");
Console.WriteLine(" The error reported was: " + sr[i].errors[0].message + "\n");
}
}