• civic
  • NEWBIE
  • 0 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 19
    Questions
  • 14
    Replies

I need to add community members of a community to the campaign members list.

I tried querying in my own way but i cound not execute successfully.

 

this was the error it was giving

 

Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Attempted to add a campaign member where either the member id 'null' or the campaign id 'null' is null.: []

 

I was not sure what is member id whether it is a contact id or community id or any other fields are missing..

 

I appreciate any help on this.

 

Thx 

  • November 04, 2011
  • Like
  • 0

I have the class with the following code..

My issue is now i need to write a method or an SOQL query which will retrieve all the the subscription members of an subscription and insert them into a campaign member list.

As i am having a hardtime doing this pls help me with the code.

I believe we need to replicate the setsubscription method from the following code, but  not sure how we can achieve this..

Please help me with the code for the method or query.

 

 

Publicl class xxx
{
/***** VARIABLE *****/
  private string cId;
  public string strFirstName{get;set;}
  public string strLastName{get;set;}
  public List<RecordSet> lstRSet = new List<RecordSet>();
  private List<RecordSet> lstRSetBackup;
  public Boolean chkStatus{get;set;}
  public Map<String,Boolean> checkOldSubscribeVal=new Map<String,Boolean>();
/*** END VARIABLE ***/

/***** PROPERTY *****/
      List<Id> setSubscription = new List<Id>();
    if(!lstSGS.isEmpty())
      for(Subscription_Group_Subscription__c sgs: lstSGS)
        setSubscription.add(sgs.Subscription__r.Id);
   
    List<Subscription_Member__c> lstSM = [SELECT s.Id, s.Subscription__c,s.Subscription_Unsubscribed_Date__c,s.Subscribed__c, s.Contact__c FROM Subscription_Member__c s WHERE s.Contact__c =: Apexpages.Currentpage().getParameters().get('cId') ];     
   
    if(!lstSGS.isEmpty())
    {
      if(!lstRSet.isEmpty())
        lstRSet.clear();
      for(Subscription_Group_Subscription__c sgs: lstSGS)
      {

          RecordSet rs = new RecordSet();
          rs.SubGroup = sgs.Subscription_Group__r.Name;
          rs.SubGroupId = sgs.Subscription_Group__r.Id;
          rs.SubType = sgs.Subscription__r.Subscription_Type__r.Name;
          rs.SubTypeId = sgs.Subscription__r.Subscription_Type__r.Id;
          rs.SubName = sgs.Subscription__r.Name;
          rs.SubId = sgs.Subscription__r.Id;
          for(Subscription_Member__c sm: lstSM)
          {
            if(sm.Subscription__c == sgs.Subscription__r.Id)
            {
              rs.Subscribed = sm.Subscribed__c;
              rs.subUnsubDate=sm.Subscription_Unsubscribed_Date__c;
              rs.SubMemId = sm.Id;
            }
          }
          lstRSet.add(rs);
      }
      lstRSetBackup = new List<RecordSet>();
      lstRSetBackup = lstRSet.clone();
      checkOldSubscribeVal=new Map<String,Boolean>();
      for(RecordSet rec:lstRSetBackup)
      {
        checkOldSubscribeVal.put(rec.SubId,rec.Subscribed);
      }
      return lstRSet;
    }
    return null;
    }
 
  public void SetSubscriptions(List<RecordSet> value)
  {
      lstRSet = value;
  }
/*** END PROPERTY ****/
  public string getSubscriptionGroupId(string contactId)
  {
     Contact con=[Select Id,Email,FirstName,LastName,Subscription_Group_Derived_Id__c from Contact Where Id=:contactID];
     return con.Subscription_Group_Derived_Id__c;
  }
 
  public PageReference setSubscribtion()
  {
    Map<String, Subscription_Member__c> mapChanges = new Map<String, Subscription_Member__c>();
    System.Debug('lstRSet'+lstRSet);
    /*for(RecordSet rs : lstRSet)
    {
        mapChanges.put(rs.SubId, rs.Subscribed);
        System.Debug('mapChangesIterator'+mapChanges);
    }*/
  
    List<Subscription_Member__c> lstRecInsert = new List<Subscription_Member__c>();
    List<Subscription_Member__c> lstRecUpdate = new List<Subscription_Member__c>();
    List<Subscription_Member__c> lstRec=[Select Id,Subscription__c,Subscribed__c,Subscription_Unsubscribed_Date__c,Contact__c,Composite_Key_ExternalId_SId_CId_OR_LId__c from Subscription_Member__c where Contact__c=:ApexPages.currentPage().getParameters().get('cId')];
    System.Debug('lstRec'+lstRec);
    Contact con=[Select Id,Email,FirstName,LastName from Contact Where Id=:ApexPages.currentPage().getParameters().get('cId') LIMIT 1];

        System.Debug('lstRecUpdate'+lstRecUpdate);
    System.Debug('lstRecInsert'+lstRecInsert);
    List<Contact> lstContact=new List<Contact>();
    Contact conRecord;
    if(ApexPages.currentPage().getParameters().get('cId')!=null)
    {
       conRecord=[Select Id,FirstName,Email,LastName,Privacy_Policy_Sent_Date__c,Privacy_Policy_Web_Ack_Date__c from Contact Where Id=:ApexPages.currentPage().getParameters().get('cId')];
    }
    if(!lstRecUpdate.isEmpty())
    {
        Database.SaveResult[] sr = Database.update(lstRecUpdate,false);
        for(Database.SaveResult srRec : sr)
        {
            if(srRec.isSuccess())
            {
              System.Debug('Entered');
              chkStatus=true;
              
            }
            else
            {
                   Database.Error err = srRec.getErrors()[0];
                   ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.ERROR,err.getMessage());
                   ApexPages.addMessage(msg);
                   return null;
              
            }
        }
    }
    if(!lstRecInsert.isEmpty())
    {
        Database.SaveResult[] sr = Database.Insert(lstRecInsert,false);
        for(Database.SaveResult srRec : sr)
        {
            if(srRec.isSuccess())
            {
               System.Debug('Entered2');
               chkStatus=true;
              
            }
            else
            {
                   Database.Error err = srRec.getErrors()[0];
                   ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.ERROR,err.getMessage());
                   ApexPages.addMessage(msg);
                   return null;
              
            }
        }
    }
    if(conRecord.Privacy_Policy_Sent_Date__c==null && conRecord.Privacy_Policy_Web_Ack_Date__c==null && chkStatus==true)
    {
            System.Debug('Entered3');
            Contact conData=new Contact(Id=conRecord.Id);
            conData.Privacy_Policy_Sent_Date__c=System.now();
            if(lstContact.size()==0)
            {
                lstContact.add(conData);
            }
            List<Privacy_policy_Email_Template__c> tempName = Privacy_policy_Email_Template__c.getall().values();
            for(EmailTemplate etemp : [select id from EmailTemplate where Name=:tempName[0].Name and isactive=TRUE ])
            {
                messaging.Singleemailmessage mail=new messaging.Singleemailmessage();
                mail.setSenderDisplayName(conRecord.FirstName +' '+conRecord.LastName);
                mail.setReplyTo(conRecord.Email);
                mail.setTargetObjectId(conRecord.Id);
                mail.setTemplateId(etemp.id);
                messaging.sendEmail(new messaging.Singleemailmessage[]{mail});
            }
    }

    System.Debug('lstContact'+lstContact);
    if(!lstContact.isEmpty())
    {
       update lstContact;
    }
    PageReference contPage = new PageReference('/'+ApexPages.currentPage().getParameters().get('cid'));
    return contPage;
   
  }//End Func Unsubscribe
  public PageReference cancelRecord()
  {
    PageReference contPage = new PageReference('/'+ApexPages.currentPage().getParameters().get('cid'));
    return contPage;
  }

/*** END FUNCTION ***/

/***** WRAPPER *****/
public class Recordset
 

 

  • November 03, 2011
  • Like
  • 0

Although i was able to get the customobject list of contacts,how can i insert those records to the campaign member list.

Pls send me the code..

 

Thx in advance

  • November 02, 2011
  • Like
  • 0

I have a trigger which will update the number of contacts on an account.

 

It is giving a problem when i am trying to update 800 records with dataloader out of which 600 got updated and gives me an exceptionlike this:

Apex script unhandled trigger exception by user/organization: 00xxx/00xxx

 contactCount: System.LimitException: Too many script statements: 200001

 

How do i solve this problem,is it a bulk trigger or do we need to change anything in the code. Pls send me the right code to handle this.

I appreciate any help on this

 

Here is the code of the trigger,
 

trigger contactCount on Contact (after insert, after update, after delete, after undelete) {

   Contact[] con;
    
    if (Trigger.isDelete) {
        con = Trigger.old;
    }
    else { 
        con = Trigger.new;
    }
    
    Set<ID> accIds = new Set<ID>();
    
    if (Trigger.isUpdate){
        for(Contact c: Trigger.old){
            if(c.AccountId != null) {
                accIds.add(c.AccountId);
            }
        }
    }
    
    for (Contact c : con) {
        accIds.add(c.AccountId);
    }
    
    Map<ID, Contact> conmap = new Map<ID, Contact>([select Id, AccountId from Contact where AccountId in :accIds And AccountId != null]);
    Map<ID, Account> accmap = new Map<ID, Account>([select Id, Number_of_Contacts__c from Account where Id in :accIds]);

    for (Account a : accmap.values()) {
        
        Set<ID> conIds = new Set<ID>();
        
        for (Contact c : conmap.values()) {
            if (c.AccountId == a.Id) {
                conIds.add(c.Id);
            }          
        }
        if (a.Number_of_Contacts__c != conIds.size()) {
            a.Number_of_Contacts__c = conIds.size();
        }      
    }   
    update accmap.values();
}

  • October 20, 2011
  • Like
  • 0

I  have a class name SMAPI which is a global class and SM which is a class.SM class returns some functionality of updating the records as per the checkboxes subscribed or unsubscribed and saves it in the salesforce.

As of now SMAPI class is used for talking with external system and SM class is used for visualforce page within salesforce.

I want to use just one class for both the external and internal requirements. In this case can i call the SM class within SMAPI class when we use for the external system.

Is this a good idea..

Any thoughts or help is appreciated.

 

Thanks

  • August 31, 2011
  • Like
  • 0

I have a class name SMAPI which is a global class and SM which is a class.SM class returns some functionality of updating the records as per the checkboxes subscribed or unsubscribed and saves it in the salesforce.

As of now SMAPI class is used for talking with external system and SM class is used for visualforce page within salesforce.

I want to use just one class for both the external and internal requirements. In this case can i call the SM class within SMAPI class when we use for the external system.

Is this a good idea..

Any thoughts or help is appreciated.

 

Thanks

  • August 31, 2011
  • Like
  • 0

I have a class name SMAPI which is a global class and SM which is a class.SM class returns some functionality of updating the records as per the checkboxes subscribed or unsubscribed and saves it in the salesforce.

As of now SMAPI class is used for talking with external system and SM class is used for visualforce page within salesforce.

I want to use just one class for both the external and internal requirements. In this case can i call the SM class within SMAPI class when we use for the external system.

Is this a good idea..

Any thoughts or help is appreciated.

 

Thanks

  • August 25, 2011
  • Like
  • 0

Hi,

 

I wanted to call a local class  from the global class and achieve the same set of functionality what it will return locally. so that i do not have to duplicate the code.

Is that a right idea..

Any thoughts appreciated..

  • August 23, 2011
  • Like
  • 0

I have a lookup field named xyz on contact object which has 3 text fields in it.

I want to make that field required before we create a new contact.

can anybody give me the validation rule for this scenario... Thx in advance  

  • August 18, 2011
  • Like
  • 0

Hi All,

 

Currently i have a  Trigger that removes line break in Mailing Address then copies cleaned values to custom text fields.

It works fine with a single record but when i want to update more records at a time with dataloader it doesn't work.

I think i need to bulkify it.. can anybody pls send me the code which should work in all scenarios....

Here is the code..

 

trigger contactRemoveLineBreakTrigger on Contact (before insert, before update) 
{
  List <String> addClean = new List<String>();
  
  for (Contact a: Trigger.new)
  {
    if(a.MailingStreet!=null)
    {
      for(String s: a.MailingStreet.split('\n',0))
      {
        addClean.add(s);
        system.debug('DEBUG: '+ addClean.size());
      }
      
      if(addClean.size()!=null)
      {
        if(addClean.size()==1)
        {
          a.Shipping_Street_1_Clean__c = addClean[0];
          a.Shipping_Street_2_Clean__c = '';
          a.Shipping_Street_3_Clean__c = '';
        }
        else if(addClean.size()==2)
        {
          a.Shipping_Street_1_Clean__c = addClean[0];
          a.Shipping_Street_2_Clean__c = addClean[1];
          a.Shipping_Street_3_Clean__c = '';
        }
        else if (addClean.size()>=3)
        {
          a.Shipping_Street_1_Clean__c = addClean[0];
          a.Shipping_Street_2_Clean__c = addClean[1];
          a.Shipping_Street_3_Clean__c = addClean[2];
        }
      }
    }
    else
    {
      a.Shipping_Street_1_Clean__c = '';
      a.Shipping_Street_2_Clean__c = '';
      a.Shipping_Street_3_Clean__c = '';
    }
  }
}

  • August 17, 2011
  • Like
  • 0

I have downloaded the eclipse ganymede3.4 version 30 days back and used it for one of the Apex triggers.

but now if i am trying to open it i am unable to see that.

When iam trying to download another foec.com explorer the eclipse IDE i can see in the workspace.

Not sure how to do it.  I am sure somebody should have faced this issue.

Any help Pls.

  • August 03, 2011
  • Like
  • 0

i have the following in the class

 

String getsubscriptionGroupId(string conId)

          String subGrpId = "hello";

          return subGrpId;

 

how do i call the same function in my VF Page.

i need the code.

  • July 27, 2011
  • Like
  • 0

I want to get subscriptiongroupId by passing the contactId by using function.

Any help on this appreciated.i will answer any questions u may have.

Thanks

  • July 26, 2011
  • Like
  • 0

I am trying to run the following code in system log.

gives me errors. Any idea

 

public String getGroupId(string conId)
{
       Map<Id,Subscription_Group_Subscription__c> subMap=new Map<Id,Subscription_Group_Subscription__c>();
       String grpId='';
       for(Subscription_Group_Subscription__c g : [select Id, Subscription__c, Subscription_Group__c from
Subscription_Group_Subscription__c where  Subscription__c=:subId])
       {
         subMap.put
(g.Subscription__c,g);
         System.Debug('subMap'+subMap);
       }
       for(Subscription_Member__c a : [select Id, Name, Subscription__c, Email__c, Contact__c, Subscribed__c, Subscription_Opt_Out_Date__c from  Subscription_Member__c where Contact__c=:conId
LIMIT 1])
       {
         grpId=subMap.get(a.Subscription__c).Subscription_Group__c ;
         System.Debug('grpId'+grpId);
       }       
       return grpId;
}

  • July 26, 2011
  • Like
  • 0

I have few custom objects subscriptions,subscripion members,subscriptiongroup subscription & subscription group.

I have created a force.com site. I want to create aVF page which will display  the existing subscriptions & the eligible subscriptions of a contact filtered by the associated subscription group.

can i create a function get subscriptiongroup.contactId =subscriptiongroupId

I need to write a SOQL query which will achieve these tasks.

Pls help and if u need more information let meknow.

Thanks in advance 

  • July 25, 2011
  • Like
  • 0

In PRODUCTION i need to edit the name all Accounts that being with "xx-" the edit will replace the leading "xx-" to "xxA-".

 Any help is appreciated

  • July 19, 2011
  • Like
  • 0

I have created a Force.com site and wrote a VF page using the contact standard object which will welcome the contactID  with first& last name.

what should i do to achieve the following tasks

If the contact ID is a member of the X Channel, show them the X Subscription Group.  It should list the Subscription based on Order within the SubscriptionGroup_Subscription associative table. Fyi, subscription and subscriptiongroup subscriptions are custom objects.

what should the code look like, any details are helpful.

Thanks

  • July 06, 2011
  • Like
  • 0

I created a VF page, when we copy that page link with the record id  we should get it worked without logging into the salesforce sandbox and should work across all browsers.

any help is appreciated.-Don

  • June 29, 2011
  • Like
  • 0

I need to add community members of a community to the campaign members list.

I tried querying in my own way but i cound not execute successfully.

 

this was the error it was giving

 

Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Attempted to add a campaign member where either the member id 'null' or the campaign id 'null' is null.: []

 

I was not sure what is member id whether it is a contact id or community id or any other fields are missing..

 

I appreciate any help on this.

 

Thx 

  • November 04, 2011
  • Like
  • 0

Hi All,

 

Currently i have a  Trigger that removes line break in Mailing Address then copies cleaned values to custom text fields.

It works fine with a single record but when i want to update more records at a time with dataloader it doesn't work.

I think i need to bulkify it.. can anybody pls send me the code which should work in all scenarios....

Here is the code..

 

trigger contactRemoveLineBreakTrigger on Contact (before insert, before update) 
{
  List <String> addClean = new List<String>();
  
  for (Contact a: Trigger.new)
  {
    if(a.MailingStreet!=null)
    {
      for(String s: a.MailingStreet.split('\n',0))
      {
        addClean.add(s);
        system.debug('DEBUG: '+ addClean.size());
      }
      
      if(addClean.size()!=null)
      {
        if(addClean.size()==1)
        {
          a.Shipping_Street_1_Clean__c = addClean[0];
          a.Shipping_Street_2_Clean__c = '';
          a.Shipping_Street_3_Clean__c = '';
        }
        else if(addClean.size()==2)
        {
          a.Shipping_Street_1_Clean__c = addClean[0];
          a.Shipping_Street_2_Clean__c = addClean[1];
          a.Shipping_Street_3_Clean__c = '';
        }
        else if (addClean.size()>=3)
        {
          a.Shipping_Street_1_Clean__c = addClean[0];
          a.Shipping_Street_2_Clean__c = addClean[1];
          a.Shipping_Street_3_Clean__c = addClean[2];
        }
      }
    }
    else
    {
      a.Shipping_Street_1_Clean__c = '';
      a.Shipping_Street_2_Clean__c = '';
      a.Shipping_Street_3_Clean__c = '';
    }
  }
}

  • August 17, 2011
  • Like
  • 0

In PRODUCTION i need to edit the name all Accounts that being with "xx-" the edit will replace the leading "xx-" to "xxA-".

 Any help is appreciated

  • July 19, 2011
  • Like
  • 0

I have created a Force.com site and wrote a VF page using the contact standard object which will welcome the contactID  with first& last name.

what should i do to achieve the following tasks

If the contact ID is a member of the X Channel, show them the X Subscription Group.  It should list the Subscription based on Order within the SubscriptionGroup_Subscription associative table. Fyi, subscription and subscriptiongroup subscriptions are custom objects.

what should the code look like, any details are helpful.

Thanks

  • July 06, 2011
  • Like
  • 0

I created a VF page, when we copy that page link with the record id  we should get it worked without logging into the salesforce sandbox and should work across all browsers.

any help is appreciated.-Don

  • June 29, 2011
  • Like
  • 0

Hi folks,

I am new to VF. I am trying to create a VF page very similar to add campaign members functionality where one can select multiple contacts and attach them to campaign in one step.

 

Here is my use case,

1- I have a custom object (myObject__c) and

2- I would like users to click a button on myObject page layout .

3- This button will show a list of account records based on a simple query, with a checkbox (similar to enhanced list)

4- User will select one or more displayed account records by clicking checkbox and will click done.

5- The selected account Ids will be saved in a custom object (RelatedAcct__c).

 

Can we create "add campaign members" like fucntionality using VF page ?

 

Thanks! 

  • December 17, 2009
  • Like
  • 0