• elcid2000
  • NEWBIE
  • 0 Points
  • Member since 2009

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies

Anyone know how I can add the following conditions to query data using Excel Connector?

 

   1. Created Date <= a given date

 

   2. Number/Amount >= a give Number/Amount

In my .net application I'm trying to attach a campaign to a new lead using the API. Creating new lead works fine when I'm not trying to pass a campaign to it. I'm trying to locate the campaign by id, load t into a campaign object, pass that campaign object to the lead and create lead. I do locate the campaign using the query but I may be missing a step. I get error: "Invalid foreign key relationship name Campaign".

 

Please help.

 

 

 The code


objSF.Url = l.serverUrl;
objSF.SessionHeaderValue = new SessionHeader();
objSF.SessionHeaderValue.sessionId = l.sessionId;
GetUserInfoResult userInfo = l.userInfo;

// Adding new lead to SalesForce.com //
sObject[] aLeads = new sObject[1];
Lead lead = new Lead();
lead.FirstName = FirstName.Length > 25 ? FirstName.Substring(0, 25) : FirstName;
lead.LastName = LastName.Length > 25 ? LastName.Substring(0, 25) : LastName;
lead.Company = CompanyName.Length > 50 ? CompanyName.Substring(0, 50) : CompanyName;
lead.Title = Position;
lead.State = StateAbbr;
lead.PostalCode = Zipcode;
lead.Phone = "NA";
lead.LeadSource = "Web";
if (CameFrom == "Demo") strLeadStatus = "New Lead";
lead.Status = strLeadStatus;
string strLeadSoureDetail = "Community";
if (CameFrom == "Demo") strLeadSoureDetail = "Online Demo";
lead.Lead_Source_Details__c = strLeadSoureDetail;
lead.Email = Email;
lead.Practice_Specialties__c = "Unknown";
lead.Num_Providers__c = 1;
objSF.Url = l.serverUrl;
objSF.SessionHeaderValue = new SessionHeader();
objSF.SessionHeaderValue.sessionId = l.sessionId;

// Adding campaign to the lead //
//Web - Community Campaign ID: 701400000009wgw
//Web - Online Demo Campaign IS: 701400000009kBS
string strCampID = "701400000009wgw";

if (CameFrom == "Demo") strCampID = "701400000009kBS";
QueryResult qr = new QueryResult();
objSF.QueryOptionsValue = new QueryOptions();
objSF.QueryOptionsValue.batchSize = 250;
objSF.QueryOptionsValue.batchSizeSpecified = true;
qr = objSF.query("select id, Name from Campaign where id='" + strCampID + "'");

if (qr.size > 0)
{
for (int i = 0; i < qr.records.Length; i++)
{
Campaign camp = (Campaign)qr.records[i];
lead.Campaign = camp;
}
}

// Community Section //
lead.First_name__c = FirstName.Length > 25 ? FirstName.Substring(0, 25) : FirstName;
lead.Last_Name__c = LastName.Length > 25 ? LastName.Substring(0, 25) : LastName;
lead.NGC_ProfileID__c = ProfileID.ToString();
lead.Username__c = UserName.Length > 50 ? UserName.Substring(0, 50) : UserName;
lead.Primary_Email__c = Email;
lead.Company_name__c = CompanyName.Length > 50 ? CompanyName.Substring(0, 50) : CompanyName;
lead.Industry__c = IndType.Length > 50 ? IndType.Substring(0, 50) : IndType;
if (PositionDesc != null)
{
lead.Position__c = PositionDesc.Length > 30 ? PositionDesc.Substring(0, 30) : PositionDesc;
}
lead.Created_Date__c = DateTime.Now;
aLeads[0] = lead;

SaveResult[] sr = objSF.create(aLeads);