• jujuba
  • NEWBIE
  • 0 Points
  • Member since 2009

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

Hi all,

 

I am trying to eliminate duplicates while inserting the records in a custom object. Here is my scenario:

 

I have two custom objects "A" and "B". 

 

Object "A" is related to Campaign  and it is 1:M relationship and  object "B" is related to Object "A" as well as Contact. All are general lookup relationships. 

 

All my Campaign members are Contacts.

I need to add all the Campaign members associated to the campaign of "A" to Object "B" on click of a button on the detail page of the object "A".

 

But while adding the campaign members I should ensure that there are no duplicate entries in Object "B".

 

So  I have used the following logic in Visual Force Controller:

 

list<B> blist = [ select contactc from B where  Aid = A.id];

 

for(B bl: blist)

idlist.add(bl.contact__c)

 

list<campaignmember> cmp = [select Id,ContactId from A where CampaignId =:A.campId AND ContactId NOT IN :idList];

 

 

Above logic working fine for inserting 2000 records  with out any duplicates.But if the number goes beyond 2000 it's creating duplicates.

 

We can't have a flag on the Campaignmember's as we would be associating a campaign to multiple records of  "A".

 

Immediate response is highly appreciated.

 

 

 

 

 

  • January 21, 2010
  • Like
  • 0

hi i was just practicing SOQL queries and i wrote a test query in apex explorer

 

 

Select Id, Name, Industry,Company_Relationship__c From Account where Company_Relationship__c='Employee' and Lead_Created_Date__c=System.today()

 

 

and when i tried to execute i am getting an error can anyone tell me where my error is.

 

error: unexpected token 'system.today()'

We plan to implementapplication with force.com. Current System was implememted by Visula Basic6.

Current system is about 700,000char (350KS,1Step=20char) .So, we worry the limit of class charters.

Can you teach me best practice of calculation method  for Apex class characters.

Hi all,

 

I am trying to eliminate duplicates while inserting the records in a custom object. Here is my scenario:

 

I have two custom objects "A" and "B". 

 

Object "A" is related to Campaign  and it is 1:M relationship and  object "B" is related to Object "A" as well as Contact. All are general lookup relationships. 

 

All my Campaign members are Contacts.

I need to add all the Campaign members associated to the campaign of "A" to Object "B" on click of a button on the detail page of the object "A".

 

But while adding the campaign members I should ensure that there are no duplicate entries in Object "B".

 

So  I have used the following logic in Visual Force Controller:

 

list<B> blist = [ select contactc from B where  Aid = A.id];

 

for(B bl: blist)

idlist.add(bl.contact__c)

 

list<campaignmember> cmp = [select Id,ContactId from A where CampaignId =:A.campId AND ContactId NOT IN :idList];

 

 

Above logic working fine for inserting 2000 records  with out any duplicates.But if the number goes beyond 2000 it's creating duplicates.

 

We can't have a flag on the Campaignmember's as we would be associating a campaign to multiple records of  "A".

 

Immediate response is highly appreciated.

 

 

 

 

 

  • January 21, 2010
  • Like
  • 0
 Hi,
I'm getting "Non-selective query against large object type (more than 100000 rows)" error when executing the following query:

List<Lead> matchingLeads = [Select Id, Demo_Account__c, Email, Site_ID__c, Status, OwnerId, Date_Converted__c, LeadSource, Demo_Account_Status__c,MMB__c, Market_Update__c, Newsletter_Italy__c, FutureTechs__c

from Lead

where Status != 'Duplicate'

and Email != null

and Email IN :leadMap.KeySet()];

 


See printed the content of the leadMap.KeySet():

lead Map set: {asdsdf456frg@test.com}
lead Map set size: 1

Why is this failing though I filtered my query ?
How you can see the leadMap doesn't contain any null value and I can't make email to be a "externalID" because this is a standard field.

The strange thing is that we are doing successfully queries against large objects (ie: Contacts) all the time, so the exception is not always thrown. The same query above works sometimes with different leadMaps.

Any ideas? Please help!

  • October 02, 2009
  • Like
  • 0