• Savi3
  • NEWBIE
  • 25 Points
  • Member since 2012

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

Hi,

 

   I need to develop a visualforce page to display the details of some users to which i am sending email (Mass Email).

Some of them are receiving those emails. So i have to display "sending failed for User1@yahoo.com,User2@gmail.com " .

I have requested for Email log files. For the one received , it doesn't contain any details other than headings.

 

Is there any  way to get the details of the user who received the mails or  who not.

 

Thanks,

sav3

  • August 07, 2012
  • Like
  • 0

Hi,

 

  AggregateResult[] Ar = [Select sum(Field name ) total from contact ];

Double sum = 0;

if (Ar.size()>o){

String str = ' ' + Ar[0].get(''total);

sum = Double.valueof(str);

}

Can somone tell me why this total is using with sum(Fieldname)?? Similarly for Avg(fieldname) aver??

 

Thank you,

Sav3.

  • July 13, 2012
  • Like
  • 0

Hi,

 

   Can we test salesforce visualforce pages for Android mobile applications other than using phones??

 

Thank You ,

Sav3

  • July 06, 2012
  • Like
  • 0

Hi,

 

 we know that developers working on mobile applications have a simulator to test their apps.And we need to test a visualforce page. Anybody has idea about how to test a salesforce VF page  other than using the phones themselves.

 

Thank you,

Savithri.

  • July 04, 2012
  • Like
  • 0

Hi ,

 

   In my visualforce page i have a table of records with checkbox to each of them. I want to send email to contacts of the selected records . I'm using a custom button for this.

Vf code for the button :- 

apex:commandButton value="Send Email" action="{!SEmail}"/>

But i'm having issue with this.

 

Public PageReference SEmail(){
    
    List<ID> MailCont = new List<Id>();
    String Temp ='tempName';
    Messaging.MassEmailMessage Email = new Messaging.MassEmailMessage();
    Email.setTemplateId([Select id from EmailTemplate where Name =:Temp].Id);
    System.debug('No of tdaw******************************************************' + tdaw.size());
    for(Integer j=0;j<tdaw.size();j++){
    System.debug('Value in toDelete***********************************' + tdaw[j].toDelete);
    if(tdaw[j].isSelected == True )
    {
     MailCont.add(tdaw[j].tar.contact__c);
     
    }
    }
     
    System.debug('Value in ids***********************************' + MailCont);
    Email.setTargetObjectIds(MailCont);
    Messaging.sendEmail(new Messaging.MassEmailMessage[] { Email });
    return null;
    }

 

While running i'm getting : SendEmail failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Missing target object ids (contact, lead or user): []

 

 

Anybody has idea??

Thank you.

Savi3.


  • June 19, 2012
  • Like
  • 0

Hi,

 

    I'm getting "Compile Error: unexpected token: ')' at line 19 column 22"  while using System.debug.

I need to get the email of the logged in user. For that i wrote this code:

ID usrid = UserInfo.getUserId();

List<User> cusr = [Select Email From User where id =: usrid ];

String uEmail = cusr[0].Email;
System.debug(uEmail); ---------------------- (Line 19)

 

Can somebody tell me why this is happening and its solution? Please..

 

Thank you,

Savi3.


  • May 30, 2012
  • Like
  • 0

Hi ,

 

   The campaign object has  two custom fields Lifetime_Value__c(Annual value) and Direct_Campaign_Sales__c.The issue facing is that there are a few campaigns that the Direct and Annual Value is not adding up and a few others that it looks incorrect.

And getting error like this:- "First error:Update failed first exception on row 200 with id 70180000000QFuAAo;first error: UNABLE_TO_LOCK_ROW,unable to obtain exclusive access to this record:[] " for campaignstaticsupdater() batch class and getting same error  for another row in campaignConvertedAnd Prospectsupdater() batch class (row0 with id 70180000000PYVGAA4 )

___________________________________________________________________________________________________

 

global class CampaignStatisticsUpdater implements Database.Batchable<sObject> {
  private List<Campaign> campaigns;
  public boolean testrun=false;
  public Id testcampaignid;
  
  private List<Campaign> loadCampaigns() {
    return [SELECT Id, StartDate, EndDate, Direct_Campaign_Sales__c, Lifetime_Value__c FROM Campaign order  by CreatedDate DESC];
  }
  
  global Database.QueryLocator start(Database.BatchableContext bc) {
    List<Campaign> campaigns = loadCampaigns();
    for(Campaign camp : campaigns) {
      camp.Direct_Campaign_Sales__c = 0;
      camp.Lifetime_Value__c = 0;
    }
    update campaigns;
    
    String query = 'SELECT Id, CampaignId, ContactId, Contact.AccountId, Account_Type_Stamp_Hidden__c FROM CampaignMember WHERE ContactId != null AND Contact.AccountId != null';
    if(testrun)
      return Database.getQueryLocator([SELECT Id, CampaignId, ContactId, Contact.AccountId, Account_Type_Stamp_Hidden__c FROM CampaignMember WHERE ContactId != null AND Contact.AccountId != null and CampaignId=:testcampaignid order by LastModifiedDate  ASC limit 100]);
    System.debug(System.LoggingLevel.INFO, query);
    Database.QueryLocator ql = Database.getQueryLocator(query);
    return ql;
  }
  
  global void execute(Database.BatchableContext bc, List<sObject> objs) {    
    Map<Id, Campaign> campMap = new Map<Id, Campaign>(loadCampaigns());
    List<CampaignMember> cms = (List<CampaignMember>) objs;
    
    // build the list of account ids
    Set<Id> acctIds = new Set<Id>();  
    for(CampaignMember cm : cms) {
      acctIds.add(cm.Contact.AccountId);
    }
    
    // load the campaign opportunities and map them by account
    Map<Id, List<Opportunity>> acctOppMap = new Map<Id, List<Opportunity>>();
    for(Opportunity o : [SELECT Id, Amount, CloseDate, StageName, AccountId, IsClosed, IsWon FROM Opportunity WHERE AccountId IN :acctIds AND Amount != null AND IsClosed = true AND IsWon = true]) {
      List<Opportunity> opps = acctOppMap.containsKey(o.AccountId) ? acctOppMap.get(o.AccountId) : new List<Opportunity>();
      opps.add(o);
      acctOppMap.put(o.AccountId, opps);
    }
    
    // update the statistics
    for(CampaignMember cm : cms) {
      Campaign camp = campMap.get(cm.CampaignId);
      if(acctOppMap.containsKey(cm.Contact.AccountId)) {
        for(Opportunity opp : acctOppMap.get(cm.Contact.AccountId)) {
          // update the statistics dealing with opportunities closed after the start of the campaign
          if(camp.StartDate != null &&camp.EndDate != null && opp.CloseDate != null && camp.StartDate <= opp.CloseDate) {
            if(opp.CloseDate <= camp.EndDate) {
              camp.Direct_Campaign_Sales__c += opp.Amount;
            }
            
            if(opp.CloseDate <= camp.EndDate.addYears(1)) {
              camp.Lifetime_Value__c += opp.Amount;
            }
          }
        }
      }
    }
    
    update campMap.values();
  }
  
  global void finish(Database.BatchableContext bc) {}
}_______________________________________________________________________________________________

global class CampaignConvertedAndProspectsUpdater implements Database.Batchable<sObject> {
  private List<Campaign> campaigns;
  
  private List<Campaign> loadCampaigns() {
    return [SELECT Id, StartDate, EndDate, Converted_Leads_and_Prospects__c FROM Campaign];
  }
  
  private List<Campaign> loadCampaigns(Set<Id> campIds) {
    return [SELECT Id, StartDate, EndDate, Converted_Leads_and_Prospects__c FROM Campaign WHERE Id IN :campIds];
  }
  
  global Database.QueryLocator start(Database.BatchableContext bc) {
    List<Campaign> campaigns = loadCampaigns();
    for(Campaign camp : campaigns) {
      camp.Converted_Leads_and_Prospects__c = 0;
    }
    update campaigns;
    
    String query = 'SELECT Id, Amount, Account_Created_Same_Day__c, AccountId, Account.IsPersonAccount, Account.PersonContactId, Conversion_Day_Campaign__c FROM Opportunity WHERE Account.IsPersonAccount = true AND Account_Created_Same_Day__c = 1 AND Conversion_Day_Campaign__c != NULL';
    System.debug(System.LoggingLevel.INFO, query);
    Database.QueryLocator ql = Database.getQueryLocator(query);
    return ql;
  }
  
  global void execute(Database.BatchableContext bc, List<sObject> objs) {
    List<Opportunity> opps = (List<Opportunity>) objs;
    Set<Id> campIds = new Set<Id>();
    for(Opportunity opp : opps) {
      if(opp.AccountId != null && opp.Account.IsPersonAccount && opp.Account_Created_Same_Day__c == 1 && opp.Conversion_Day_Campaign__c != null) {
        campIds.add(opp.Conversion_Day_Campaign__c);
      }
    }
    
    Map<Id, Campaign> campMap = new Map<Id, Campaign>(loadCampaigns(campIds));
    
    // iterate over all opps and update the conversion day campaing stat value
    for(Opportunity opp : opps) {
      if(opp.AccountId != null && opp.Account.IsPersonAccount && opp.Account_Created_Same_Day__c == 1 && opp.Conversion_Day_Campaign__c != null && campMap.containsKey(opp.Conversion_Day_Campaign__c)) {
        Campaign camp = campMap.get(opp.Conversion_Day_Campaign__c);
        Double curAmt = camp.Converted_Leads_and_Prospects__c == null ? 0 : camp.Converted_Leads_and_Prospects__c;
        camp.Converted_Leads_and_Prospects__c = curAmt + (opp.Amount == null ? 0 : opp.Amount);
      }
    }
    update campMap.values();
  }
  
  global void finish(Database.BatchableContext bc) {}
}

}________________________________________________________________________________________________

 

 

Any ideas would be of great help.....

 

Thank you.

sav3.

 

  • May 23, 2012
  • Like
  • 0

Hi ,

 

     I have a trigger which generates the standard field, Name of a custom object with  'a string + name of the corresponding Contact' before inserion/Updation.

My trigger:--

____________________________________________________________________________________________

trigger trgname on cusobj__c (before insert,before update) {
Set<ID> conid = new Set<ID>();
List<contact> lstContact = new List<contact>();
Map<ID,contact> Mapname = new Map<ID,contact>();
for( cusobj__c tar :Trigger.New)
{
conid.add(tar.Contact__c); // Storing all the contact ids for which the name needs to be used
}
system.debug('Inside the trigger to update the name');
//Getting all the contact records in a list to be used in the name field
lstContact = [select id,name,firstname,lastname from contact where id in : conid];

for(integer i =0; i <lstcontact.size(); i++)
{
Mapname.put(lstcontact[i].id,lstcontact[i]); // Putting the contact id and name in a map
}

for( cusobj__c tar :Trigger.New)
{
// tar.name = 'TD Rem - ' + mapname.get(tar.Contact__c).firstname +' ' + mapname.get(tar.Contact__c).lastname;
tar.name = 'TD Rem - ' + mapname.get(tar.Contact__c).name;
}

}

_____________________________________________________________________________________________

 

I do have a test class for this trigger . But getting  error 'Assertion Failed: Expected: 20, Actual: 0' 

 

My Testclass:-

____________________________________________________________________________________________

@isTest
Private class testTrgTrgname{
Static testMethod void methodname(){
Contact con = new Contact();
con.FirstName= 'fname';
con.LastName = 'lname';

insert con;
System.debug('value for contact name:' + con);
Contact con1 = new Contact();
con1.LastName = 'lname1';
insert con1;
//Insert test data

cusobj__c Tmapt = new cusobj__c();
Tmapt.Appointment_Created__c = True;
Tmapt.Target_date__c = System.today()+3;
Tmapt.Contact__c = con.id;

insert Tmapt;
System.debug('value for Tmapt name:' + Tmapt.Name);
System.debug('value for Tmapt :' + Tmapt);
List<cusobj__c> ltmd = new List<cusobj__c>();
ltmd =[Select Contact__c from cusobj__c where id =:Tmapt.id];
System.assertEquals(1,ltmd.Size());

System.assertEquals('TD Rem-fname lname', Tmapt.Name);
cusobj__c Tpt = new cusobj__c();
Tpt.Appointment_Created__c = True;
Tpt.Target_date__c = System.today()+ 5;
Tpt.Contact__c =con1.id;
insert Tpt;
System.assertEquals(Tpt.Name, con1.name);
Contact newcon = new Contact();
newcon.lastname = 'lnewcon';
insert newcon;
//cusobj__c Ltar =[Select Contact__c from cusobj__c where id := Tmapt.id];
//Tmapt.Cotnact__c = newcon.id;
//update Tmapt;

}
}

______________________________________________________________________________________________

  

 

Any idea?? Please help...

 

 

Thank You,

sav3

  • May 18, 2012
  • Like
  • 0

Hi,

 

    I have a custom object with a standard field, Name. Its  a required field. How can i make this field as unrequired??

Also can we remove this field from standard field??

 

 

Thank You,

sav3.

  • May 15, 2012
  • Like
  • 0

Hi,

 

 Can someone help me to query some fields of Opportunity along with contact fields.

Opportunity has a field Account and there are contacts for this account. I want to retrieve some fields of opportunity and fields of contacts with the accountId .

 

Please help..

  • March 21, 2012
  • Like
  • 0

 While running Force.com IDE ,i'm getting this message.

I got  installed eclipse 3.7 and Force.com IDE under my profiles in Pulse Explorer.

While running/lunching the Force.com IDE  ,i'm getting this window.

But i can run eclipse...

 

Please help....

 

  • March 06, 2012
  • Like
  • 0

Hi ,

 

   In my visualforce page i have a table of records with checkbox to each of them. I want to send email to contacts of the selected records . I'm using a custom button for this.

Vf code for the button :- 

apex:commandButton value="Send Email" action="{!SEmail}"/>

But i'm having issue with this.

 

Public PageReference SEmail(){
    
    List<ID> MailCont = new List<Id>();
    String Temp ='tempName';
    Messaging.MassEmailMessage Email = new Messaging.MassEmailMessage();
    Email.setTemplateId([Select id from EmailTemplate where Name =:Temp].Id);
    System.debug('No of tdaw******************************************************' + tdaw.size());
    for(Integer j=0;j<tdaw.size();j++){
    System.debug('Value in toDelete***********************************' + tdaw[j].toDelete);
    if(tdaw[j].isSelected == True )
    {
     MailCont.add(tdaw[j].tar.contact__c);
     
    }
    }
     
    System.debug('Value in ids***********************************' + MailCont);
    Email.setTargetObjectIds(MailCont);
    Messaging.sendEmail(new Messaging.MassEmailMessage[] { Email });
    return null;
    }

 

While running i'm getting : SendEmail failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Missing target object ids (contact, lead or user): []

 

 

Anybody has idea??

Thank you.

Savi3.


  • June 19, 2012
  • Like
  • 0

I have to update the record if it is already in the system. I have an Object named 'Account' and its field 'Account ID'. The condition for updating the record is that for 'Account' the key is 'Account ID'. My question is:

1 : How can i assign the 'Account ID' key to the object 'Account'. I have an idea that i have to use map function here but how to use it i do not know. My understadning was that it should be something like

Map<Account_ID__c,Account__c> map1 = new Map<Account_ID__c,Account__c>(); //ITS AN ERROR !

So whats the right way to do it.

2 : How does mapping helps me in updating record. I mean i am sure it can be done without mapping the values so how (show with code) does it makes easy to update while using the map.

 

Thanks !

Hi,

I have couple of objects, In which i have defined a few custom field and one field as a standard field.

First, i will try to explain the reason why i have defined one field as a standard field.

The couple of object which i have defined represents the record and in my app if the record is already in the system i have to update its values. For every object i have been given a key like for eg for 'Contact' object i have been given 'Contact Email ' as a key. So, i have made the contact email as the standard field while the contact name as the custome field.

 

So, my question is,

1 : that does it even matters that if the key is custom or standard field ?

2 : Why there is no API name for standard field. how can one access standard field from apex code without it having the API name?

Also last but not the least

3 : what is the significance of having a key, i mean if a field is key then in what way is it seperate from other field .

 

Thanks

 

Hi,

 

    I'm getting "Compile Error: unexpected token: ')' at line 19 column 22"  while using System.debug.

I need to get the email of the logged in user. For that i wrote this code:

ID usrid = UserInfo.getUserId();

List<User> cusr = [Select Email From User where id =: usrid ];

String uEmail = cusr[0].Email;
System.debug(uEmail); ---------------------- (Line 19)

 

Can somebody tell me why this is happening and its solution? Please..

 

Thank you,

Savi3.


  • May 30, 2012
  • Like
  • 0

Hi ,

 

     I have a trigger which generates the standard field, Name of a custom object with  'a string + name of the corresponding Contact' before inserion/Updation.

My trigger:--

____________________________________________________________________________________________

trigger trgname on cusobj__c (before insert,before update) {
Set<ID> conid = new Set<ID>();
List<contact> lstContact = new List<contact>();
Map<ID,contact> Mapname = new Map<ID,contact>();
for( cusobj__c tar :Trigger.New)
{
conid.add(tar.Contact__c); // Storing all the contact ids for which the name needs to be used
}
system.debug('Inside the trigger to update the name');
//Getting all the contact records in a list to be used in the name field
lstContact = [select id,name,firstname,lastname from contact where id in : conid];

for(integer i =0; i <lstcontact.size(); i++)
{
Mapname.put(lstcontact[i].id,lstcontact[i]); // Putting the contact id and name in a map
}

for( cusobj__c tar :Trigger.New)
{
// tar.name = 'TD Rem - ' + mapname.get(tar.Contact__c).firstname +' ' + mapname.get(tar.Contact__c).lastname;
tar.name = 'TD Rem - ' + mapname.get(tar.Contact__c).name;
}

}

_____________________________________________________________________________________________

 

I do have a test class for this trigger . But getting  error 'Assertion Failed: Expected: 20, Actual: 0' 

 

My Testclass:-

____________________________________________________________________________________________

@isTest
Private class testTrgTrgname{
Static testMethod void methodname(){
Contact con = new Contact();
con.FirstName= 'fname';
con.LastName = 'lname';

insert con;
System.debug('value for contact name:' + con);
Contact con1 = new Contact();
con1.LastName = 'lname1';
insert con1;
//Insert test data

cusobj__c Tmapt = new cusobj__c();
Tmapt.Appointment_Created__c = True;
Tmapt.Target_date__c = System.today()+3;
Tmapt.Contact__c = con.id;

insert Tmapt;
System.debug('value for Tmapt name:' + Tmapt.Name);
System.debug('value for Tmapt :' + Tmapt);
List<cusobj__c> ltmd = new List<cusobj__c>();
ltmd =[Select Contact__c from cusobj__c where id =:Tmapt.id];
System.assertEquals(1,ltmd.Size());

System.assertEquals('TD Rem-fname lname', Tmapt.Name);
cusobj__c Tpt = new cusobj__c();
Tpt.Appointment_Created__c = True;
Tpt.Target_date__c = System.today()+ 5;
Tpt.Contact__c =con1.id;
insert Tpt;
System.assertEquals(Tpt.Name, con1.name);
Contact newcon = new Contact();
newcon.lastname = 'lnewcon';
insert newcon;
//cusobj__c Ltar =[Select Contact__c from cusobj__c where id := Tmapt.id];
//Tmapt.Cotnact__c = newcon.id;
//update Tmapt;

}
}

______________________________________________________________________________________________

  

 

Any idea?? Please help...

 

 

Thank You,

sav3

  • May 18, 2012
  • Like
  • 0