• HARI KRISHNA
  • NEWBIE
  • 25 Points
  • Member since 2014


  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 9
    Questions
  • 22
    Replies
I have one small question related to salesforce that is I have list view on contact object which is showing 400 contacts, when I click mass email link which is available under contact tab showing 394 contacts for same kind of view.

Note : All contacts have email Id and not checked email opt out option. Please let me know the reason behind this. 
Is it possible to schedule multiple users with their own data? 
Hi Friends,

Please check the screen shots:
Check the Query here:-

User-added image

Check the result here:

Problem on Database.Query method
Hi all,
Can anyone guide me in this regard.I have a requirment that need to restrict user to specific system.If he trying to login with other system it has to deny.
Can anyone help me out how to integrate salesforce with Google Adwords so that i can populate Keyword information in to salesforce Object.Give me step by step procedure. 
------------------Help me for Bulkifying this Trigger-----------------------------Invoice have look up relationship with Account...
trigger InvAmountUpdate on Invoice__c (After Update)
{
    for(Invoice__c inv:Trigger.New)
    {
        Account acc=new Account();
        acc=[Select id,Account_Balance__c From Account Where id =:inv.Account__c];
        
        if(acc.Account_Balance__c==null)
            acc.Account_Balance__c=0;  
   
        Invoice__c  invOld=Trigger.oldMap.get(inv.id);
        if(inv.Invoice_Amount__c!=invOld.Invoice_Amount__c)
            acc.Account_Balance__c=acc.Account_Balance__c-invOld.Invoice_Amount__c+inv.Invoice_Amount__c;
   
    update acc;
    }
}
User-added image
--------------------This is the Class--------------
public class task1 {
    public string Obj{get;set;}
    public integer Year{get;set;}   
    public boolean Abool{set;get;}
    public boolean Bbool{set;get;}
    public boolean Cbool{set;get;}
    public boolean Dbool{set;get;}            
    public list<account> acclist{set;get;}
    public list<contact> conlist{set;get;}
    public list<opportunity> opplist{set;get;}
    public list<lead> Lelist{set;get;}             
    
    public task1()
    {
        Abool=false;
        Bbool=false;
        Cbool=false;
        Dbool=false;                        
        acclist=new list<account>();
        conlist=new list<contact>();
        opplist=new list<opportunity>();
        Lelist=new list<lead>();                        
    }
    public void getData()
    {
    if(Obj.equals('None')&&Year==0)
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.FATAL,'Please ensure to select Object and Year'));
         else
        if(Obj.equals('Account'))
        {
            acclist=[select id,name,phone from Account WHERE CALENDAR_YEAR(CreatedDate) =: Year];
            Abool=true;
        }else
        if(Obj.equals('Contact'))
        {
            conlist=[select id,name,phone from contact WHERE CALENDAR_YEAR(CreatedDate) =: Year];
            Bbool=true;
        }else
        if(Obj.equals('Opportunity'))
        {
            opplist=[select id,name,amount from Opportunity WHERE CALENDAR_YEAR(CreatedDate) =: Year];
            Cbool=true;
        }else
        {
         Lelist=[select id,name,phone from Lead WHERE CALENDAR_YEAR(CreatedDate) =: Year];   
        Dbool=true;
        }        
    }
}
---------------------This is the Test Class which is able to cover only 63%-------------------Help me to resolve the issue-----------------
@isTest
public class  Task1_TC
{
    static testMethod void testMthd()
    {
        task1 t=new task1();
        string Obj='Opportunity';
        Account a=new Account(name='xxx');
         Lead l=new Lead(lastname='yyy');
         Contact c=new Contact(lastname='kkk');
         Opportunity o=new opportunity(name='OOO');
         integer Year=2014;
         boolean Abool=false;
         boolean Bbool=false;
         boolean Cbool=false;
         boolean Dbool=false;
         list<account> acclist=new list<account>();
         acclist.add(a);
         list<contact> conlist=new list<contact>();
         conlist.add(c);
         list<opportunity> opplist=new list<opportunity>();
         opplist.add(o);
         list<lead> Lelist=new list<lead>();
         lelist.add(l);
         t.getData();         
    }
}
Snap shot for code Coverage
_____________This is the Class where i am facing problem------------------------------
public class SaveMultiObj {


    public humanresource__c hr{get;set;}
      public CandidateHr__c cand{get;set;}
      public AdminService__c admin{get;set;}
        
        public SaveMultiObj(){
        hr=new humanresource__c();
        cand=new CandidateHr__c();
        admin=new AdminService__c ();
        }
    public void custsave(){
     
      insert hr;
     cand.HumanResource__c=hr.id;
     cand.rank__c=hr.rank__c;
     cand.last_name__c=hr.last_name__c;
      insert cand;   
     }
    public void custUpdate() {
      CandidateHr__c cand1 =[select id,last_name__c,rank__c,name from candidatehr__c where name=:cand.name];
       cand1.last_name__c=hr.last_name__c;
       cand1.rank__c=hr.rank__c;
       update cand1;
      
     admin.CandidateHr__c=cand1.id;
     admin.rank__c=cand1.rank__c;
     admin.last_name__c=cand1.last_name__c;
      insert admin;         
    }   
   }
-------------------------This is Test Class which is related to above Class ---which able to cover only 68%--------
@isTest
public class SaveMultiObj_TC
{
    static testMethod void testMthd()
    {
        SaveMultiObj s=new SaveMultiObj ();
        s.custsave();
        s.custUpdate();
        s.hr=new humanresource__c (name='xxx');
        s.cand=new CandidateHr__c (name='yyy');  
        insert s.cand;
        s.cand.name='yyo';   
        update s.cand;
        s.admin=new AdminService__c (name='uuu');
        insert s.admin;
    }
}
This is the snap shot for below issue
----------------This is the Controller Class Where i am facing Problem.---------------------
public class RerenderEx {

    public contact con{set;get;}
    public boolean Abool{set;get;}
    public boolean Bbool{set;get;}    

    public RerenderEx()
    {
        con=new contact();
        Abool=false;
        Bbool=false;
    }
    public void saveNew() {
        insert con;
        con.clear();//con=new contact();
    }

    public void saveSec() {
        insert con;
        Abool=true;
    }
    
    public void EditSec() {
        Abool=false;
        Bbool=true;
    }
    
     public void updateSec() {
        update con;
    }

}
------------------------------This is the Test Class which is unable to Cover above Class .Its covering only 50%----------
@isTest
public class RerenderEx_TC
{
    static testMethod void testMthd()
    {
     boolean Abool=false;
     boolean Bbool=false;    
    RerenderEx r=new RerenderEx();
     contact con=new contact(lastname='xxx');
    r.saveNew();
     insert con;
     con.lastname='xyy';
     update con;
      r.saveSec();
     r.EditSec();
     r.updateSec();
     }
}
 
Hi Friends,

Please check the screen shots:
Check the Query here:-

User-added image

Check the result here:

Problem on Database.Query method
I am overriding view page of lead, on which i am showing notes related list and new note button.
<apex:page standardController="Lead">
    <apex:pageBlock >
                           {!Lead.name}
    </apex:pageBlock>

   <apex:relatedList list="AttachedContentNotes"/>

</apex:page>
after clicking on new note button i am getting this error.
 
Hi,
I am running the test class and getting the debug lines printed in the code also, but somehow the code coverage remains 0%. Any guesses why this is happening.

Thanks,
Yogesh
@isTest
private class NBNAddUserToContact_test {
   
   
    private static testmethod void testUpdate() {
    
        NBNServiceSettings__c cs = new NBNServiceSettings__c();
        cs.name ='CreateUser';
        cs.Value__c ='Y';
        insert cs;
        
         NBNServiceSettings__c cs1 = new NBNServiceSettings__c();
        cs1.name ='CommunityUserEmail';
        cs1.Value__c ='testdummy@nbnco.com.au';
        insert cs1;
        
        user us = new user();
        us.LastName = 'tesst';
        us.FirstName = 'test272';
        us.LocaleSidKey = 'en_AU';
        us.TimeZoneSidKey = 'Australia/Sydney';
        us.ProfileID = '00e1a000000o1Vl';
        us.LanguageLocaleKey = 'en_US';
        us.EmailEncodingKey = 'ISO-8859-1';
        us.Email = 'nbn@nbnco.co.ac';
        us.Username = 'test22@gmail.com.nbndev01';
        us.WD_EmployeeNumber__c = '1232356223';
        us.Alias = 'tyre';
        us.CommunityNickname = 'test uuu';
        insert us;
        
        us.LastName = 'tess0t';
        update us;

    }
  private static testmethod void testInsert() {
        
     
        
       
        
        NBNServiceSettings__c cs21 = new NBNServiceSettings__c();
        cs21.name ='CreateUser';
        cs21.Value__c ='Y';
        insert cs21;
        
          NBNServiceSettings__c cs11 = new NBNServiceSettings__c();
        cs11.name ='CommunityUserEmail';
        cs11.Value__c ='testdummy@nbnco.com.au';
        insert cs11;
        
        account acct1 = new account(Name = 'NBNInc');
        
        contact con = new contact ();
        con.Contact_Source__c = 'WDSFDCIntegration';
        con.LastName = 'test';
        con.FirstName = 'test22';
        con.Accountid = acct1.id;
        con.email = 'nbn@nbnco.co.ac';
        con.Username__c = 'test@gmail.com';
        con.WDEmployeeNumber__c = '123232356223';
        con.WD_Employee_Type__c = 'Employee';
        con.Worker_Status__c = True;
        con.Nickname__c = 'test test22 tyre';
        con.Phone = '98959895';
        insert con;
              
    }
    
       private static testmethod void testInsertInactiveUser() {
        
       
        NBNServiceSettings__c cs3 = new NBNServiceSettings__c();
        cs3.name ='CreateUser';
        cs3.Value__c ='Y';
        insert cs3;
        
        NBNServiceSettings__c cs31 = new NBNServiceSettings__c();
        cs31.name ='CommunityUserEmail';
        cs31.Value__c ='testdummy@nbnco.com.au';
        insert cs31;
        account acctn = new account(Name = 'NBNInc');
        
        contact conInactive = new contact ();
        conInactive.Contact_Source__c = 'WDSFDCIntegration';
        conInactive.LastName = 'test';
        conInactive.FirstName = 'test22';
        conInactive.Accountid = acctn.id;
        conInactive.email = 'nbn@nbnco.co.ac';
        conInactive.Username__c = 'test@gmail.com';
        conInactive.WDEmployeeNumber__c = '1232356223';
        conInactive.WD_Employee_Type__c = 'Employee';
        conInactive.Worker_Status__c = False;
        conInactive.Nickname__c = 'test test22';
        conInactive.Phone = '98959895';
        insert conInactive;
   
    }

      
}
Hi,
When i hit the Third-party (Echosign) accessing through REST API,getting below erroe message :
System.CalloutException: Unexpected end of file from server.

Please find below are my REST Code:
String strendpoint = 'https://api.na1.echosign.com:443/api/rest/v3/agreements/3AAABLblqZhB5nTaAjhiCG_DBIuGAg85D7sAdm3wV1Q3UN6sSY4-We9ZqnxyfoMgpuYYhgRPh0hmGjT2cILvuWwwsKhrLbLNG';
HttpRequest hreq = new HttpRequest();
hreq.setEndpoint(strendpoint);
hreq.setHeader('Content-Length',String.valueof(strendpoint.length()));
hreq.setHeader('Content-Type','application/json;charset=UTF-8');
hreq.setMethod('GET');
hreq.setHeader('Access-Token','3AAABLblqZhDlrVcpsTnquJTsgcG2E4n7qQLt8Oo3fTTU9x8PT-HB_qe1TGJ2NkzbI_WnK3JJXWqlb9OVVSkGPKwpgDqUXQVK');
hreq.setTimeout(120000);
Http htp= new Http();
HttpResponse hres = htp.send(hreq);
System.Debug('hres========'+hres.getBody());



Pleasge give your valuable suggesstions, How to resolve this issue ??

Regards,
Kishore
Not clear what it is looking for I have a section in the code that pulls the Smith Records and I have added the Smith records.
<public class ContactAndLeadSearch {
    public static List<List<sObject>> searchContactsAndLeads(String searchName){
        
        List<List<Sobject>> contactsandleadsrecords =[find 'Smith' in all fields
                                      RETURNING contact(firstname,lastname),Lead(firstname,lastname)];
        
        List<List<sObject>> searchList = [FIND :searchName IN ALL FIELDS
                                      RETURNING Contact(FirstName,LastName),Lead(FirstName,LastName)];
        
        Contact[] smithContact1 = (Contact[])contactsandleadsrecords[0];
        Lead[] smithLead1 = (Lead[])contactsandleadsrecords[1];
        
        Contact[] searchContact = (Contact[])searchList[0];
        Lead[] searchLead = (Lead[])searchList[1];

        return searchList;
    }
}>
Hi All,

I am using below Trigger code to send notifications to external webservice
if(Trigger.isUpdate){
        contact old = Trigger.oldMap.get(c.Id);
        if (c.Email != old.Email||c.FirstName!=old.FirstName||c.LastName!=old.LastName||c.phone!=old.phone||c.Title__c!=old.Title__c||c.status__c!=old.status__c||c.AccountID!=old.AccountID||c.Accounts__r.Name!=old.Account__r.Name)
but my error is only in the last part  c.Accounts__r.Name!=old.Account__r.Name i want the trigger to fire when the account name is edited Like for Example when Account name "SFDC" is edited to "SFDC.COM" the related contacts of the account is also changed to SFDC.COM. i want the trigger to fire when this name change occurs in the account name field of contact object that is the reason for adding this  c.Accounts__r.Name!=old.Account__r.Name  but it is not working giving me Compile Error: Invalid foreign key relationship: Contact.Accounts__r

Please help me resolve this issue.

Thanks
Abraham
I'm working in sandbox and I want to deploy this to my production but I currently have 0% coverage. Any help is appreciated! 

public class tenPageSizeExt { public tenPageSizeExt(ApexPages.StandardSetController controller) { controller.setPageSize(10); } }
HI Experts,

while posting my code in developers community, getting this error what does it mean by."The operation is not permitted. If you received this in error, please contact info@developerforce.com (code: B2)"
Hi all,
I've tried alot of solutions for this issue but when I install the package then I received an email with exception info as below:
System.CalloutException: You have uncommitted work pending. Please commit or rollback before calling out.

Please find below my code:
global class PostInstallClass implements InstallHandler {
  global void onInstall(InstallContext context) {
      User u = GetUserById(context.installerId());
      try
      {
          if(!Test.isRunningTest())          UpdatePackageInstallationInfo(context.installerId(), u.Email);
      }
      catch(Exception e)
      {
          SendMessage(new String[]{'abc@xyz.com'},'Package failed to install/upgrade','Failed to install/upgraed package. ' + u.Email + ' tried to install/upgraed the package but failed because. Error Details: ' + e);
      }     
  }
    
    public User GetUserById(ID id)
    {
        User u = [Select Id, Email from User where Id =:id];
        return u;
    }
    
    @future(callout=true)
    public static void UpdatePackageInstallationInfo(String organizationId, String userEmail)
    {        
        String url = 'http://demoapi.sunapplabs.com/api/salesforce/updateinstallpackage?organizationid='+organizationId;
        Http h = new Http();
        HttpRequest req = new HttpRequest();
        req.setEndpoint(url);
        req.setMethod('GET');
        HttpResponse responseResult = h.send(req);
        if(responseResult.getBody() == 'true')
        {            
            SendMessage(new String[]{userEmail, 'abc@xyz.com'},'Package install successful','Thanks for installing the package. Response result : '+responseResult);
        }
        else
        {
            SendMessage(new String[]{'abc@xyz.com'},'Package failed to install/upgrade','Failed to install/upgraed package. ' + userEmail + ' tried to install/upgraed the package but failed because of failure from MyAPI response. Response result : '+responseResult);
        }
    }
    public static void SendMessage(String[] toAddresses, String subject, String message)
    {
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
        mail.setToAddresses(toAddresses);
        mail.setReplyTo('abc@xyz.com');
        mail.setSenderDisplayName('My Package Support');
        mail.setSubject(subject);
        mail.setPlainTextBody(message);
        Messaging.sendEmail(new Messaging.Email[] { mail }); 
    }
  }



 
Hi All,

How to add value to the multiselect Picklist through apex code.
I have a requirement to get the value from one Object's text field and  add that values to Multiselect pick list field in another object.


 

Hi,

 

I want to write some trigger on Product2 object so that when any new product record is created it can add new picklist value on Picklist__c (Picklist field) under CustomObject__c object.

 

Any help would be appreciated.

 

Thanks,

Nikhil

Hi,

 

  can any one tell how to implement password protection to a file in salesforce .

  • June 11, 2009
  • Like
  • 0