+ Start a Discussion
Swapnil PatneSwapnil Patne 

API integration error

Hi,

 

We have an API built to pull our customer data from our community site. It gets details of people ID and Profile data. However, it seems the following error is preventing the API from working- 

 

 

 

24/04/2013 01:03 Future Failed First error: Argument 1 cannot be null 0 0 0 Patne, Swapnil 24/04/2013 01:03 YMMainGetPeopleIdsFuture2 707W0000003O1WN

 

24/04/2013 01:00 Future Failed First error: Argument 1 cannot be null 0 0 0 Patne, Swapnil 24/04/2013 01:00 YMMainGetPeopleIdsFuture 707W0000003O1MU

 

 

Can anyone help me understand what does the error mean and how to resolve this to get the API working. Someone informed me that the ApexMethod GetPeopleIdsFutue in YMMain it requires two parameters- and I need to add two parameters to-  Boolean pIsTest, String pWebsiteId.

 

To be honest I don't know how to do that and what parameters to add. I am an Admin and my expertise is not in development, so can someone help me with the steps to resolve this?

 

 

Here is the YM Main code

 

 
 

/*
Available methods:
1) GetPeopleIdsFuture() - gets a list of peaple IDs and creates YM Import Lines records.
2) GetProfileData(YM_Import_Line__c pYMImportLine) - gets the profile data for the each record.
3) UpdateRelations(Contact pContact) - gets sub members and updates relations.
*/
global class YMMain
{
/*
GetPeopleIdsFuture() - gets a list of peaple IDs and creates YM Import Lines records. Each YM Import
Line contains thr Member ID at this stage and will be updated during the next step. This method is
called at YMGetPeopleIdsSchedulerContext class and runs ...
*/
@future(callout=true)
public static void GetPeopleIdsFuture(Boolean pIsTest, String pWebsiteId)
{
YMWrapper pYMWrapper = new YMWrapper();
Id pYMImportHeaderId;
List<String> pPeopleIds = new List<String>();
List<YM_Import_Line__c> pYMImportLines = new List<YM_Import_Line__c>();
YM_Import_Header__c pYMImportHeader;

// get the latest YM Import Header record
pYMImportHeaderId =
[
SELECT Id
FROM YM_Import_Header__c
ORDER BY YMStartDate__c DESC
LIMIT 1
].Id;

// get a list of Members IDs
if(!pIsTest)
{
pYMWrapper.GetPeopleIDs(pWebsiteId);
}
else
{
pYMWrapper.pResult.pHasError = false;
}

if(pYMWrapper.pResult.pHasError)
{
// update import header status
pYMImportHeader = new YM_Import_Header__c
(
Id = pYMImportHeaderId,
YMGetPeopleIdsStatus__c = 'Error',
YMGetPeopleIdsError__c = pYMWrapper.pResult.pErrorCode + ': ' + pYMWrapper.pResult.pErrorDescription
);
update pYMImportHeader;

return;
}
else
{
// update import header status
pYMImportHeader = new YM_Import_Header__c
(
Id = pYMImportHeaderId,
YMGetPeopleIdsStatus__c = 'Completed'
);
update pYMImportHeader;

// insert YM Import Lines records
pPeopleIds = pYMWrapper.pPeopleIds;
for(String pPeopleId : pPeopleIds)
{
pYMImportLines.add(new YM_Import_Line__c(YMMemberID__c = pPeopleId, YMImportHeader__c = pYMImportHeaderId));
}
insert pYMImportLines;
}
}

@future(callout=true)
public static void GetPeopleIdsFuture2(Boolean pIsTest, String pWebsiteId)
{
YMWrapper pYMWrapper = new YMWrapper();
Id pYMImportHeaderId;
List<String> pPeopleIds = new List<String>();
List<YM_Import_Line__c> pYMImportLines = new List<YM_Import_Line__c>();
YM_Import_Header__c pYMImportHeader;

// get the latest YM Import Header record
pYMImportHeaderId =
[
SELECT Id
FROM YM_Import_Header__c
ORDER BY YMStartDate__c DESC
LIMIT 1
].Id;

// get a list of Members IDs
if(!pIsTest)
{
pYMWrapper.GetPeopleIDs(pWebsiteId);
}
else
{
pYMWrapper.pResult.pHasError = false;
}

if(pYMWrapper.pResult.pHasError)
{
// update import header status
pYMImportHeader = new YM_Import_Header__c
(
Id = pYMImportHeaderId,
YMGetPeopleIdsStatus__c = 'Error',
YMGetPeopleIdsError__c = pYMWrapper.pResult.pErrorCode + ': ' + pYMWrapper.pResult.pErrorDescription
);
update pYMImportHeader;

return;
}
else
{
// insert YM Import Lines records
pPeopleIds = pYMWrapper.pPeopleIds;
for(String pPeopleId : pPeopleIds)
{
pYMImportLines.add(new YM_Import_Line__c(YMMemberID__c = pPeopleId, YMImportHeader__c = pYMImportHeaderId));
}
insert pYMImportLines;
}
}

/*
GetProfileData(YM_Import_Line__c pYMImportLine) - loops through all YM Import Lines and gets the profile
data for the each record (Member ID). It checks the following conditions:
- Is there a contact with the same Member Id in Salesforce.com?
YES - update the contact, NO - go to the next step
- Is there a contact with the same Member Email in Salesforce.com?
YES - update the contact, NO - go to the next step
- Is there an account with the same Name in Salesforce.com?
YES - insert the contact, NO - go to the next step
- Is there a lead with the same Member Id in Salesforce.com?
YES - update the lead, NO - go to the next step
- Is there a lead with the same Member Email in Salesforce.com?
YES - update the lead, NO - go to the next step
- create a new lead

It takes about 10 minutes to process 700 records. This method is called at
YMGetProfileDataBatchableContext class and runs ...
*/
public static void GetProfileData(YM_Import_Line__c pYMImportLine, Boolean isTest)
{
YMWrapper pYMWrapper = new YMWrapper();
String pMemberId, pMemberEmail, pMemberCompany;
YMWrapper.Member pMember = new YMWrapper.Member();
YM_Import_Line__c pYMImportLineToUpdate;
List<Contact> pContactsById = new List<Contact>();
List<Contact> pContactsByEmail = new List<Contact>();
List<Account> pAccounts = new List<Account>();
List<Lead> pLeadsById = new List<Lead>();
List<Lead> pLeadsByEmail = new List<Lead>();

// get a profile data
System.debug('TEST = ' + pYMImportLine.YMMemberID__c);
if(!isTest)
{
pYMWrapper.GetProfileData(pYMImportLine.YMMemberID__c);
}
else
{
pYMWrapper.pResult.pHasError = false;
pYMWrapper.pMember.pMemberID = 'TEST-TEST-TEST';
pYMWrapper.pMember.pEmail = 'TEST@TEST.TEST';
pYMWrapper.pMember.pCompany = 'My Company';
}

if(pYMWrapper.pResult.pHasError)
{
// update import line status
pYMImportLineToUpdate = new YM_Import_Line__c
(
Id = pYMImportLine.Id,
YMStatus__c = 'Error',
YMError__c = pYMWrapper.pResult.pErrorCode + ': ' + pYMWrapper.pResult.pErrorDescription
);
update pYMImportLineToUpdate;

return;
}
else
{
pMemberId = pYMWrapper.pMember.pMemberID;
pMemberEmail = pYMWrapper.pMember.pEmail;
pMemberCompany = pYMWrapper.pMember.pCompany;
pMember = pYMWrapper.pMember;

// select an existing contact by Member Id
pContactsById =
[
SELECT Id
FROM Contact
WHERE Yourmembership_id__c =: pMemberId
];

// select an existing contact by Email
pContactsByEmail =
[
SELECT Id
FROM Contact
WHERE Email =: pMemberEmail
];

// select an existing account by Name
pAccounts =
[
SELECT Id
FROM Account
WHERE Name =: pMemberCompany
];

// select an existing lead by Member Id
pLeadsById =
[
SELECT Id
FROM Lead
WHERE Yourmembership_id__c =: pMemberId
AND isConverted = false
];

// select an existing lead by Email
pLeadsByEmail =
[
SELECT Id
FROM Lead
WHERE Email =: pMemberEmail
AND isConverted = false
];

// Is there a contact with the same Member Id in Salesforce.com?
if(pContactsById.size() != 0 && pMemberId != null)
{
// update the existing contact
UpdateContact(pContactsById[0].Id, pMember, pYMImportLine.Id);
}
// Is there a contact with the same Member Email in Salesforce.com?
else if(pContactsByEmail.size() != 0 && pMemberEmail != null)
{
// update the existing contact
UpdateContact(pContactsByEmail[0].Id, pMember, pYMImportLine.Id);
}
// Is there an account with the same Name in Salesforce.com?
else if(pContactsById.size() == 0 && pContactsByEmail.size() == 0 && pLeadsById.size() == 0 && pLeadsByEmail.size() ==0 && pAccounts.size() != 0)
{
// create a new contact
InsertContact(pAccounts[0].Id, pMember, pYMImportLine.Id);
}
else
{
// Apply almost the same logic for a lead

// Is there a lead with the same Member Id in Salesforce.com?
if(pLeadsById.size() != 0 && pMemberId != null)
{
// update the existing lead
UpdateLead(pLeadsById[0].Id, pMember, pYMImportLine.Id);
}
// Is there a lead with the same Member Email in Salesforce.com?
else if (pLeadsByEmail.size() != 0 && pMemberEmail != null)
{
// update the existing lead
UpdateLead(pLeadsByEmail[0].Id, pMember, pYMImportLine.Id);
}
else
{
// create a new lead
InsertLead(pMember, pYMImportLine.Id);
}
}
}
}

 

 

Thank you,

Swapnil