public class LeadTest : IAfterCalculation
public ActionableResponse AfterCalculation(CalculationRequest request, CalculationResponse response)
var name = request.Inputs.FirstOrDefault(x => x.Ref == "iName");
var mail = request.Inputs.FirstOrDefault(x => x.Ref == "iEmail");
BasicHttpBinding b = new BasicHttpBinding();
EndpointAddress ea = new EndpointAddress("https://login.salesforce.com/services/Soap/c/43.0");
b.Namespace = "sforce.Soap";
b.Security.Mode = BasicHttpSecurityMode.Transport;
SoapClient client = new SoapClient(b, ea);
string acctName = "[Enter your SForce developer user name]";
string acctPw = "[Enter your SForce developer password]";
loginResult = client.login(null, acctName, acctPw);
header = new sforce.SessionHeader();
header.sessionId = loginResult.sessionId;
EndpointAddress eaApiClient = new EndpointAddress(loginResult.serverUrl);
apiClient = new SoapClient(b, eaApiClient);
lead.FirstName = lead.LastName = name.Value[0][0].Value;
lead.Email = mail.Value[0][0].Value;
lead.Company = "Company Name";
lead.LeadSource = "Advertisement";
AssignmentRuleHeader arh = new AssignmentRuleHeader();
string query = "SELECT Id FROM AssignmentRule WHERE Name = " +
"'Mass Mail Campaign' AND SobjectType = 'Lead'";
LimitInfo[] limitArray = apiClient.query(
arh.useDefaultRule = true;
arh.assignmentRuleId = qr.records[0].Id;
foreach (SaveResult s in sr)
return new ActionableResponse