Discussions
- General Development
- Schema Development
- Apex Code Development
- Visualforce Development
- Formulas & Validation Rules
- Security
- Mobile
- Force.com Sites & Site.com
- Chatter Development
- Java Development
- .NET Development
- Perl, PHP, Python & Ruby
- Desktop Integration
- APIs and Integrations
- Visual Workflow
- Apple, Mac and OS X
- VB and Office Development
- AppExchange Directory & Packaging
- Salesforce Labs & Open Source Projects
- Other Salesforce Applications
- Jobs Board
- Force.com Discussion Boards
- :
- Developer Boards for Force.com and Database.com
- :
- Apex Code Development
- :
- Error in one of the Web Service method- System.Str...
turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
0
Error in one of the Web Service method- System.Str ingExcepti on :Invalid id
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
01-02-2013 02:26 PM
In the following method within a webservice, I am getting an error when trying to insert new lead and the error shows from salesforce webservice as following
System.StringException : Invalid Id
For the following class, it's the second red higlighted line.
Please let me know if anyone has any knowledge on how we might tackle this problem.
Thank you!
public static EWebAPIUtils.APILeadInsert insertLead(String companyName, String partnerName, String s treet, String city, String state, String zip, Stri ng country, String website, String phone, String f ax, Integer noOfEmployees, String sicCode, String primarySector, String industry, String primaryVert ical, String firstName, String lastName, String ti tle, String email, String primaryProduct, String p artnerSiteId, String partnerEmailAddress, Date exp ectedCloseDate, Decimal budget, String region, Dec imal annualRevenue, String campaignId)
{
Integer year = math.mod(date.today().year(),100);
String campName = 'NA_VAR_FY'+year;
System.debug('campName :'+campName);
try{
campaignId = [Select Id From Campaign where name= :campName].id;
}catch(Exception e)
{
System.debug('Record not found');
}
Savepoint sp;
Id ruleId;
EWebAPIUtils.APILeadInsert result = new EWebAPIUtils.APILeadInsert();
Lead newLead = new Lead();
newLead.Company = companyName;
newLead.Partner_Name__c = partnerName;
newLead.Street = street;
newLead.City = city;
newLead.State = state;
newLead.PostalCode = zip;
newLead.Country = country;
newLead.Website = website;
newLead.Phone = phone;
newLead.Fax = fax;
if(noOfEmployees != null)
{
newLead.NumberOfEmployees = noOfEmployees;
}
newLead.Primary_SIC_Code__c = sicCode;
newLead.Primary_Sector__c = primarySector;
newLead.Primary_Industry__c = industry;
newLead.Primary_Vertical__c = primaryVertical;
newLead.FirstName= firstName;
newLead.LastName= lastName;
newLead.Title = title;
newLead.Email = email;
newLead.Solution__c= primaryProduct;
newLead.Partner_Site_ID__c = partnerSiteId;
newLead.Partner_Email_Address__c = partnerEmailAddress;
newLead.Expected_Close_Date__c = expectedCloseDate;
if(budget != null)
{
newLead.Budget__c = budget;
}
newLead.Region__c = region;
if(annualRevenue != null)
{
newLead.AnnualRevenue = annualRevenue;
}
newLead.Lead_Type__c = 'Partner';
sp = Database.setSavepoint();
try{
//get the Id for the Standard Assignment Rule from Organization
ruleId = [Select Id From AssignmentRule where name = 'Universal Lead Assignment Rule'].i d;
}catch(Exception ex)
{
System.debug('Assignment Rule not found');
}
//Use DMLOptions to provide exta infomation during a transaction.
//Create DMLoptions object
Database.DMLOptions dmo = new Database.DMLOptions();
//AssignmentRuleHeader specifies the Assignment Rule to be used when the lead is created.
dmo.AssignmentRuleHeader.assignmentRuleId= ruleId;
//Sets the DMLOptions object for the sObject
newLead.setOptions(dmo);
try{
insert newLead;
CampaignMember objCampaignMember = newCampaignMember();
objCampaignMember.CampaignId = campaignId;
objCampaignMember.LeadId = newLead.Id;
insert objCampaignMember;
result.iReturnCode = EWebAPIUtils.STATUS_CREATED;
result.strMessage = EWebAPIUtils.LEAD_INSERTED_SUCCESSFULLY ;
EWebAPIUtils.APILeadInsert objAPILeadInsert= result.insertLead(newLead.id,result.iReturn Code,result.strMessage );
return objAPILeadInsert;
}catch(QueryException e)
{
//We reached here as there was some exception occured.
Database.rollback(sp);
result.iReturnCode = EWebAPIUtils.STATUS_ISE;
result.strMessage = EWebAPIUtils.LEAD_INSERT_FAILED ;
return result.insertLead(newLead.id,result.iReturnCode,result.strMessage);
}
}
0
Re: Error in one of the Web Service method- System.Str ingExcepti on :Invalid id
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
01-02-2013 11:11 PM
Hi
Salesforce is not case sensitive. you try change campignId to different name.

