• Amit Chaudhary 8
  • ALL STAR
  • 40700 Points
  • Member since 2014
  • Salesforce CRM Consultant


  • Chatter
    Feed
  • 1200
    Best Answers
  • 1
    Likes Received
  • 32
    Likes Given
  • 3
    Questions
  • 5762
    Replies
public class Handeller
{
    List<ID> tempAccList = new List<ID>();
     List<Account> aList = new List<Account>();
      List<Customer__c> cList = new List<Customer__c>(); 
      List<Account> aList1 = new List<Account>();
      
      public void getAccountId (List<Account> accList)
      {
          for (Account acc: accList)
          {
              tempAccList.add(acc.Id);
          }    
          if(!tempAccList.isEmpty())
          {
              createCustomer();
          }
       }
       
        public void createCustomer()
        {
          aList =[SELECT Id,Name,Phone,Role_of_the_main_contact__c FROM account WHERE Id IN:tempAcclist];
          for (Account acc1: aList)
          {
              Customer__c cust = new Customer__c();
              cust.Name = acc1.Name;
              cust.Phone__c= acc1.Phone;
              cust.Role_of_the_contact__c=acc1.Role_of_the_main_contact__c;
              cust.Related_Account__c=acc1.ID;
              cList.add(cust);
              
              acc1.Phone=null;
              acc1.Role_of_the_main_contact__c=null;
              aList1.add(acc1);
          }
          
          insert cList;
          update aList1;
          
        } 
}
public class AnimalsCallouts {
    public static HttpResponse makeGetCallout() {
        Http http = new Http();
        HttpRequest request = new HttpRequest();
        request.setEndpoint('https://th-apex-http-callout.herokuapp.com/animals');
        request.setMethod('GET');
        HttpResponse response = http.send(request);
        // If the request is successful, parse the JSON response.
        if (response.getStatusCode() == 200) {
            // Deserializes the JSON string into collections of primitive data types.
            Map<String, Object> results = (Map<String, Object>) JSON.deserializeUntyped(response.getBody());
            // Cast the values in the 'animals' key as a list
            List<Object> animals = (List<Object>) results.get('animals');
            System.debug('Received the following animals:');
            for (Object animal: animals) {
                System.debug(animal);
            }
        }
        return response;
    }
    public static HttpResponse makePostCallout() {
        Http http = new Http();
        HttpRequest request = new HttpRequest();
        request.setEndpoint('https://th-apex-http-callout.herokuapp.com/animals');
        request.setMethod('POST');
        request.setHeader('Content-Type', 'application/json;charset=UTF-8');
        request.setBody('{"name":"mighty moose"}');
        HttpResponse response = http.send(request);
        // Parse the JSON response
        if (response.getStatusCode() != 201) {
            System.debug('The status code returned was not expected: ' +
                response.getStatusCode() + ' ' + response.getStatus());
        } else {
            System.debug(response.getBody());
        }
        return response;
    }        
}
HOW TO CREATE A VISUALFORCE PAGE FOR THIS APEX CLASS??? WITH TWO BUTTONS OF POST AND GET????
THANKS >>>
 
trigger AssignToFirstOwnerForDuplicteLeads on Lead (before insert, before update) {
    set <string> newEmaiSet = new set<string>();
    set<string> newPhNumSet = new set<string>();
    for(lead l1: trigger.new) {
        if(l1.Email != null) {
            newEmaiSet.add(l1.Email);
        }
        if(l1.phone != null) {
            newPhNumSet.add(l1.phone);
        }
    }
    List<lead> leadWithMatchingEmail = [select id, email, OwnerId from lead where email in :newEmaiSet];
    List<lead> leadWithMatchingPhone = [select id, phone, OwnerId from lead where email in :newPhNumSet];
    Map<string, id> emailVSId = new Map<string, id>();
    Map<string, id> phoneVSId = new Map<string, id>();
    for(lead l1: leadWithMatchingEmail) {
        emailVSId.put(l1.Email, l1.OwnerId);
    }
    for(lead l1: leadWithMatchingPhone) {
        phoneVSId.put(l1.phone, l1.OwnerId);
    }
    for(lead l1: trigger.new) {
        if(emailVSId.containsKey(l1.Email)) {
            l1.OwnerId = emailVSId.get((l1.Email));
        }
      //  if(phoneVSId.containsKey(l1.phone)) {
      //      l1.OwnerId = phoneVSId.get((l1.phone));
     //   }
        system.debug('l1::@@'+l1);
    }
    
}

Thanks in advance
Hi,
i'm doing trailhead challenge on Automate Simple Business Processes with Process Builder, and i got an error that said "There was an unexpected error in your org which is preventing this assessment check from completing: System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Web Site must have an extension of .com, .org, or .net.: [Website]"

do you know how can i fix it ?

this is the step of the challenge =
The process can have any name
The process must have an Update Records action that updates Contact mailing address fields (Street, City, State, Postal Code, Country) when the parent Account shipping address field values are updated
The process must be active

NOTE: To complete this challenge, you may have to deactivate the validation rule for the Contacts object (created from a previous challenge).

and my work =
User-added image
User-added image
Hello guys, 
i created a controller with following methodes. I have 96% code coverage and want to deploy my controller..

- m1 - returns a list of a wrapper class object1
- m2 - returns a list of a wrapper class object2
- m3 - creates records with values releated to m1 & m2 

So, i have created for each methode more test methodes in my test class.

for m1: 
- positive -- the list returns some records
- null - the list doesen't return some recrods
- bulk - the list shows 100 records 

for m2: 
- positive -- the list returns some records
- null - the list doesen't return some recrods
- bulk - the list shows 100 records 

for m3:
- positiv - the methode creates one record
- Null - the methode creates no record
- bulk - the methode creates 100 records

i have checked each methode with system.assertEquals.

Now, my question(s).
- is this a good strategy for my test class ?
- i have created new test data for each test methode --- is this necessary ? 
- my test class has more than 300 lines -- is this too much ? 

thanks for your time. I really want to learn how to write good test classes.


Sandra 



 
I am getting myself confused here - I have built the App and my hotels are displaying on the Google map which is fab, but I now want to transfer it into Production and I appreciate that I need to test the Controller.

Am I testing that I can create a new record in my custom object?

OR

Am I testing that a new visualforce page is created
Kindly let me know, how to write a test class for this Apex class. I wrote a test class but it's not covering code coverage

public class AggregateTasklist{
public List<AggregateResult> Result {get;set;} 
List<Account> ListAct= New List<Account>();
 
public List<AddWrapperField> wraplist{get;set;}
 
    public AggregateTasklist(ApexPages.StandardController controller) {       
        
    }
    
    public void GetRecords(){
    
        String userid=UserInfo.getUserId();
        
        ListAct=[select ID,ownerId from Account where ownerId =:userid];
        
        If(ListAct.size()>0) {
        For(Account act:ListAct) {   
        wraplist=new List<AddWrapperField>();        
        Result=[select Max(Time_New__c) LastDueDate, Task.Account.Name Name from Task where  ownerId =:userid and Time_New__c!=Null 
        group By Task.Account.Name Having Max(Time_New__c)<LAST_N_DAYS:110]; 
          }
       }      
       for(AggregateResult res:Result){          
       wraplist.add(new AddWrapperField(Res));    
       }   
    }

    public class AddWrapperField{
       public Date LastDueDate{get;set;}
       public String Name {get;set;}
       
       AddWrapperField(AggregateResult res){
         this.LastDueDate=(Date)res.get('LastDueDate');
         this.Name =(String)res.get('Name');
         
       }
     }
     
    }


My Test Class:

@isTest(SeeAllData=false) class AggregateResultTest {
    @isTest static void test() {
    
      Profile p = [SELECT Id FROM Profile WHERE Name='Standard User'];
             
            User u = new User(Alias = 'Test', Email='Test@testorg.com', 
            EmailEncodingKey='UTF-8', LastName='Testing', LanguageLocaleKey='en_US', 
            LocaleSidKey='en_US', ProfileId = p.Id, 
            TimeZoneSidKey='America/Los_Angeles', UserName='shakila@gmail.com');
            
            insert u;
            
             
            Account a = new Account(Name = 'ApprovalTest' ,Lock_record__C=FALSE ,ownerid=u.ID);
           insert a; 
           
           Contact con = new COntact();
            con.email='test@fmail.co';
            con.ACCOUNTID=a.ID;
            con.ownerid=a.ownerid;
            con.lastname='test' ;
            
            insert con;
    
     System.runAs(u) 
        { 
            Task testTTask= new Task(Subject = 'EventTest',  Description = 'Description',WhoId= con.Id ,
             ownerid=con.ownerid);
             Insert testTTask;
             
             
        Test.startTest();
        testTTask= new task(Subject = 'EventTest',  Description = 'Description',WhoId= con.Id ,
        ownerid=con.ownerid);
        Database.SaveResult result = Database.insert(testTTask, false);
           Test.stopTest();
           }
        
    
    
    
     List<Account> listact=New List<Account>{[select OwnerID from Account Where ownerID=:u.ID ]};
    
        AggregateResult[] results = [SELECT Max(Time_New__c), WhatId  FROM Task GROUP BY WhatId ];
        
        }
      
    }
public class LPT_InterestAccrued_TriggerHandler {

    public static void updateIAonLoan(List<loan__Loan_Payment_Transaction__c> lptNewData){
        List<loan__Loan_Account__c> loanList = new List<loan__Loan_Account__c>();
        List<loan__Loan_Payment_Transaction__c> lptList = [select id, loan__Cleared__c,
                                                           loan__Loan_Account__r.loan__Loan_Status__c, 
                                                           loan__Loan_Account__r.loan__Interest_Accrued_Not_Due__c
                                                           from loan__Loan_Payment_Transaction__c where id in:lptNewData];
                                                           
                System.debug('Loan payment trsansactions list:====='+lptList);                                         
        for(loan__Loan_Payment_Transaction__c lpt: lptList){
            System.debug('Loan payment trsansactions list:====='+lpt);  
               

               if(lpt.loan__Loan_Account__r.loan__Loan_Status__c=='Closed- Written Off')
               {
                    loan__Loan_Account__c l = new loan__Loan_Account__c();
                    
                    l.id = lpt.loan__Loan_Account__c;
                    
                    System.debug('Loans:====='+l);  
                    if(lpt.loan__Loan_Account__r.loan__Interest_Accrued_Not_Due__c!=0){
                        l.loan__Interest_Accrued_Not_Due__c=0;
                        loanList.add(l);
                    System.debug('Loans list:====='+loanList);  
                    }            
                }
                
                
            } 
            
        
        try{
            update loanList;
        }
        Catch(Exception e){
            System.debug('Exception Occurred:'+e);
        }
    }
}
"myfirstcontapp" is a Namespace Prefix

Code for AnimalLocator Class:
public class AnimalLocator{
   public static String getAnimalNameById(Integer id){
        Http http = new Http();
        HttpRequest request = new HttpRequest();
        request.setEndpoint('https://th-apex-http-callout.herokuapp.com/animals/'+id);
        request.setMethod('GET');
        HttpResponse response = http.send(request);
        String strResp = '';
        system.debug('******response '+response.getStatusCode());
        system.debug('******response '+response.getBody());
        // If the request is successful, parse the JSON response.
        if (response.getStatusCode() == 200){
            // Deserializes the JSON string into collections of primitive data types.
            Map<String, Object> results = (Map<String, Object>) JSON.deserializeUntyped(response.getBody());
            // Cast the values in the 'animals' key as a list
            Map<string,object> animals = (map<string,object>) results.get('animal');
            System.debug('Received the following animals:' + animals );
            strResp = string.valueof(animals.get('name'));
            System.debug('strResp >>>>>>' + strResp );
        }
        return strResp ;
    }
}


Code for AnimalLocatorMock Mock Class
@isTest
global class AnimalLocatorMock implements HttpCalloutMock {
    // Implement this interface method
    global HTTPResponse respond(HTTPRequest request) {
        // Create a fake response
        HttpResponse response = new HttpResponse();
        response.setHeader('Content-Type', 'application/json');
        response.setBody('{"animal":{"id":1,"name":"chicken","eats":"chicken food","says":"cluck cluck"}}');
        response.setStatusCode(200);
        return response; 
    }
}
Code for AnimalLocatorTest​  Test Class:
@isTest
public class AnimalLocatorTest {
  @isTest public static void AnimalLocatorMock() {
       //Test.setMock(HttpCalloutMock.class, new AnimalLocatorMock());
      test.setMock(HttpCalloutMock.class, new AnimalLocatorMock());
        string result = AnimalLocator.getAnimalNameById(1);
      system.debug(result);
        String expectedResult = 'chicken';
        System.assertEquals(result,expectedResult );
    }
}
Thanks
Url is here
https://trailhead.salesforce.com/modules/visualforce_fundamentals/units/visualforce_standard_list_controllers

This module include visualforce code
Please teach me. I want controller code....
User-added image

I am getting the above message, I have followed the instrucitons carefully, but it wont lket me pass. I even tried making that custom field and applying it to the layout but it still wont let me pass.

 
I am working on Level Up with Advanced Formulas.  The challenge indicates that you must create a formula that returns text values of either "Early", "Middle", or "Late".  When checking the challenge I am recieving a message that the formula is expecting a number,  Has anyone been able to pass the challenge and if so, would you mind sharing your solution?
Hi Gurus ,
what is difference b/n one to many  ,one to many and junction object . bcz using  lookup relation  we can get many to many behaviour then what is special future junction object have ? Means creating lookup fields in both object we can get the many to many behaviour than what is need of creating  junction object ? than you in advance .
Thanks
Naveen k.
Hello, Here iam representing my code for this class i have to create @Test class

public class TRN_AccountDetailPage_Ctrl {
    //Getter setter //Property
    public Account acct{Get;Set;}
    //Constructor same sa class name
    public TRN_AccountDetailPage_Ctrl(){
    
        string strid = apexpages.currentpage().getparameters().get('id');
         if(strid !=''&& strid !=null){
          acct =[select id,name,phone,Accountnumber,Billingcity,billingcountry,billingstreet,fax from Account where id=:strid];
         }
     }
}
trigger Setpricebookentry1 on Product2 (after insert) 
{
    Set<ID> prodIdSet = Trigger.newMap.keySet();
    list<Pricebookentry> listpbe=new list<Pricebookentry>();
    Pricebook2 prbook=[select id from Pricebook2 where isStandard=true and isActive=true];
         system.debug('++++++>'+prbook);
        for(Product2 po:Trigger.New)
        {
            system.debug('=====>'+trigger.new);
            Pricebookentry pbe=new Pricebookentry();
            pbe.UnitPrice=10;
            pbe.Pricebook2Id=prbook.id;
            pbe.Product2Id=po.id;
            listpbe.add(pbe);
        }
        if(listpbe.size()>0)
        {
            insert listpbe;
            system.debug('------>'+listpbe);
        }
}   

this is my test code
@istest
public class TestSetpricebookentry1 
{
    @istest
    public static void mytest()
    {
        Product2 po=new Product2();
        po.Name='Raghav';
        po.IsActive=true;
        insert po;
        Id pricebookId = Test.getStandardPricebookId();
        PricebookEntry standardPrice = new PricebookEntry();
        standardPrice.Pricebook2Id = pricebookId; 
        standardPrice.Product2Id =po.Id;
        standardPrice.UnitPrice = 10000; 
        standardPrice.IsActive = true;
        insert standardPrice;
    }
}
Hi All,
I have written a small trigger on opportunity.Which is updating field 'opportunity sales Leader' with the user in opportunity team member.Here is trigger.
trigger UpdateOpportunity on Opportunity (after insert) 
{
    Set<Id> setOfOppty = new Set<Id>();
    List<Opportunity> listOfOpptyToUpdate = new List<Opportunity>();
    for(Opportunity opp : Trigger.New){
        if(opp != null && (opp.RecordTypeId == Label.Oppty_Record_Type_ISV || opp.RecordTypeId == Label.Oppty_Record_Type_OEM || opp.RecordTypeId == Label.Oppty_Record_Type_Wholesale || opp.RecordTypeId == Label.Oppty_Record_Type_xSP)){
            setOfOppty.add(opp.Id);
        }
    }
    List<OpportunityTeamMember> listOTM = new List<OpportunityTeamMember>([SELECT Id, UserId, OpportunityId, User.Name FROM OpportunityTeamMember WHERE OpportunityId in :setOfOppty AND TeamMemberRole = :Label.Opportunity_Sales_Leader]);
    for(OpportunityTeamMember otmObj: listOTM){
        
        if(otmObj != null && otmObj.UserId!=null && otmObj.OpportunityId != null){
            Opportunity opp = new Opportunity(Id = otmObj.OpportunityId, Opportunity_Team_Member_Sales_Leader__c = otmObj.UserId);
            listOfOpptyToUpdate.add(opp);
        }
    }   
    if(!listOfOpptyToUpdate.IsEmpty()){
        Database.SaveResult[] saveResultList = Database.update(listOfOpptyToUpdate,false);
        for(Database.SaveResult svResult : saveResultList){
            if(!svResult.isSuccess()){                
                system.debug('Error::'+svResult);
                break;
            }
        }
    }
}

And Here Is Test clas.;
@Istest(SeeAllData=false)
Private class Test_opportunity 
{
     public static testmethod void testOpportunity()
     {   
         //ProId = [SELECT Id FROM Profile WHERE Name = 'Consumer Sales Ops'].Id;
         User user = new User();
        
        user.FirstName = 'Test';
        user.LastName = 'Name';
        user.CompanyName = 'IT Test Company';
        user.MobilePhone = '123-456-7890';
        
        user.Username = 'testUser-' + '@test.com';
        user.Email = 'testUser-' +'@test.com';
  user.Alias = 'test';
        user.CommunityNickname = 'test1';
        user.TimeZoneSidKey = 'America/New_York';
        user.LocaleSidKey = 'en_US';
        user.EmailEncodingKey = 'UTF-8';
        user.ProfileId = '00e1I000000Veel';
        user.LanguageLocaleKey = 'en_US';
        
        user.Street = '123 Test St';
        user.City = 'Testcity';
        user.State = 'va';
        user.PostalCode = '23223';
        user.Country = 'USA';
        
        insert user;
         Date myDate = Date.today();
         Opportunity opp=new opportunity();
         opp.RecordTypeId='0122F0000004ot9';
         opp.name='test opp';
         opp.AccountId='0012F00000EXcyQ';
         opp.CurrencyIsoCode='AED';
         opp.CloseDate= myDate;
         opp.StageName='Identification';
         opp.Opportunity_Team_Member_Sales_Leader__c=user.Id;
         insert opp;
         OpportunityTeamMember opptyteam=new OpportunityTeamMember();
         opptyteam.opportunityId=opp.Id;
         opptyteam.TeamMemberRole='Sales Leader';
         opptyteam.UserId=user.Id;
         insert opptyteam;
         opp.Opportunity_Team_Member_Sales_Leader__c = opptyteam.UserId;
         update opp;
         
     }
}

But its covering only 53 %
if(otmObj != null && otmObj.UserId!=null && otmObj.OpportunityId != null){
            Opportunity opp = new Opportunity(Id = otmObj.OpportunityId, Opportunity_Team_Member_Sales_Leader__c = otmObj.UserId);
            listOfOpptyToUpdate.add(opp);
        }

this if condition and also error statment is not been covered.any suggestion on this would be really help full

So i have my test class which i wrote:

@isTest 
public class Controller2TestClass 
{
   static testMethod void testMethod1() 
   {
        Account acc = new Account();
        showAccount showAcc = new showAccount();
        acc.Name='Test';
        acc.Phone='0644204232';
        showAcc.save();
        
          PageReference pageRef = Page.screen2 ;
          Test.setCurrentPage(pageRef);
       
        String checkIdAccount = ApexPages.currentPage().getParameters().get('id');
       
        System.assertEquals(checkIdAccount, acc.id);
       
     }
}

VF Page:

<apex:page controller="showAccount" >
 <apex:form >
     <apex:pageBlock >
         <apex:pageBlockSection >
             <apex:outputField value="{!account.name}"/>
             <apex:inputField value="{!account.phone}"/>
             <apex:commandButton value="update" action="{!save}"/>
         </apex:pageBlockSection>
     </apex:pageBlock>
 </apex:form>
</apex:page>

And this is the class that I'm testing. I'm only covering 33% and I wonder how can I cover 100%? What I've missed? 
 
public class showAccount 
{
  public Account account{get;set;}
  
    public showAccount()
    {
        Id idAccount = apexpages.currentPage().getParameters().get('id'); 
        account=[Select ID, Name, Phone from Account where id = : idAccount];
    }
    
    public pageReference save(){
        update account;
        PageReference pageRef = new PageReference('/apex/screen3');
        pageRef.getParameters().put('id', account.Id);
        return pageRef;
    }
}

Final output comming as Account and Opportunity ID. i want to display Account name and opportunity names

public class Map_Opportunities {
    public Map<string,List<Opportunity>> oppMap        {set;get;}
    public List<Opportunity> optyList                {set;get;}
    
    public Map_Opportunities(){
        oppMap = new Map<string,List<Opportunity>>();  
        
        for (Account acc: [SELECT name,(SELECT Name FROM Opportunities)FROM Account]){            
            oppMap.put(acc.Name,acc.Opportunities);            
        }        
    }
}
///VF
<apex:page controller="Map_Opportunities">
    <apex:form >
        <apex:pageBlock title="Account Map">
            <apex:pageBlockButtons location="Bottom" style="opportunity">                
            </apex:pageBlockButtons>
            <apex:pageBlockSection columns="1" collapsible="false" >
                <apex:pageBlockTable value="{!oppMap}" var="m">
                    <apex:column value="{!m}" headerValue="Account Name"/>
                    <apex:column value="{!oppMap[m]}" headerValue="Opportunity Name"/>
                </apex:pageBlockTable>                
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>
 
I wrote a trigger to prevent the duplicate based on mobile or Email

Requirement 

If Email Not Equal to blank -Check all the Email fields- If records exist with Email -Error -Duplicate Lead

If Email Blank and Mobile Not Equal Blank - Check all the mobile fields- If records exist with the same number -Error -Duplicate Lead
============
My Code is not passing to the second condition ..can anyone help me to out this error
==Always am getting first error======


Trigger leaddup1 on lead(before insert,Before Update)
{

List<Lead> llist=new list<lead>();
List<Lead> elist=new list<lead>();


Set<string> setnumber =new set<String>();
set<string> setemail =new set<string>();

for(Lead l:Trigger.new)
{
setnumber .add(l.MobilePhone);
setnumber .add(l.Whatsapp_Mobile__c);
setnumber .add(l.Mobile_Additional__c);
setnumber .add(l.Phone);
setnumber .add(l.Phone_Additional__c);
setemail.add(l.Email);
setemail.add(l.E_Mail_Additional__c);

}

 IF(setemail!=Null)
    {

        elist=[select ID from Lead where Email =:setemail or        E_Mail_Additional__c=:setemail];
    }
        
 IF(setemail==Null && &&setnumber !=Null)
    {
 llist=[select ID from Lead where MobilePhone =:setnumber or Phone =:setnumber or
 Mobile_Additional__c =:setnumber or Whatsapp_Mobile__c =:setnumber or Phone_Additional__c =:setnumber ];

    }    
       

For(Lead l : Trigger.New)
{
If (Trigger.isinsert)
{
         IF(setemail!=Null && elist.size()>0 )
               {        
                l.adderror('Duplicate Lead -Already Lead Exist with this Email 1');
             }
             
             IF(setemail==Null  && setnumber !=Null &&llist.size()>0)
            {       
                l.adderror('Duplicate Lead -Already Lead Exist with this Mobile 2');
             }
             

}
}

}
I got to know that , Salesforce has recently introduced the Platform Developer 1 certification (DEV450) to replace the Developer (DEV401) certification. All practitioners, with the DEV401 certification, must complete the DEV450 exam during 2016 to retain a Salesforce developer certification.

Is this true as i dnt not got any email from salesforce / webassessvor that if you will not give the DEV450 exam then your DEV401 certifcate will expire ?
 
When i am posting code "" is not printing. And Some code is removing automatically. 

Any idea . It look like some issue ?
External Lookup Relationship could now be setup between external objects and Salesforce object.
External Object - They are same as custom objects but used to map to data located outside Salesforce.
External object take data from External source and External source obviously has its own DB. 
To create external object : From Setup, click Develop | External Objects.
To create external Data source : Develop | External data source
 
I got to know that , Salesforce has recently introduced the Platform Developer 1 certification (DEV450) to replace the Developer (DEV401) certification. All practitioners, with the DEV401 certification, must complete the DEV450 exam during 2016 to retain a Salesforce developer certification.

Is this true as i dnt not got any email from salesforce / webassessvor that if you will not give the DEV450 exam then your DEV401 certifcate will expire ?
 

it keeps return not writeable error... how should i resolve this error?
 
private List<Contact> contactList;

   public void addMore() {
    

        string nameT = Apexpages.currentPage().getParameters().get('nameT');
        string phoneT = Apexpages.currentPage().getParameters().get('phoneT');
        string emailT = Apexpages.currentPage().getParameters().get('emailT');

    system.debug(nameT + '//' + phoneT + '//' + emailT);


    Contact att = new Contact();

    att.name = nameT;
    att.phone = phoneT;
    att.email = emailT;

    contactList.add(att);


 //i want this parameters to List value but it doesnt work properly..
  • May 24, 2018
  • Like
  • 0
trigger CloneOpp on Opportunity( after insert, after update ) {
  Set<String> fields = Opportunity.getSobjectType().getDescribe().fields.getMap().keySet();

  Map<Id,opportunity_clone__c> co2 = new Map<Id,Opportunity_clone__c>();
  for(Opportunity record: Trigger.new) {
    co2.put(record.opportunity_clone__c,new opportunity_clone__c(id=record.opportunity_clone__c));
    for(String field:fields) {
      if(field.indexOf('__c')>-1) { // This is a custom field.
        try {
          Opportunity_clone__c.get(record.opportunity_clone__c).put(field,record.getSObject(field));
        } catch(exception e) { /* NOTE: This just means copy failed. */ }
      }
    }
  }
  update co2.values();
}

 
public class Handeller
{
    List<ID> tempAccList = new List<ID>();
     List<Account> aList = new List<Account>();
      List<Customer__c> cList = new List<Customer__c>(); 
      List<Account> aList1 = new List<Account>();
      
      public void getAccountId (List<Account> accList)
      {
          for (Account acc: accList)
          {
              tempAccList.add(acc.Id);
          }    
          if(!tempAccList.isEmpty())
          {
              createCustomer();
          }
       }
       
        public void createCustomer()
        {
          aList =[SELECT Id,Name,Phone,Role_of_the_main_contact__c FROM account WHERE Id IN:tempAcclist];
          for (Account acc1: aList)
          {
              Customer__c cust = new Customer__c();
              cust.Name = acc1.Name;
              cust.Phone__c= acc1.Phone;
              cust.Role_of_the_contact__c=acc1.Role_of_the_main_contact__c;
              cust.Related_Account__c=acc1.ID;
              cList.add(cust);
              
              acc1.Phone=null;
              acc1.Role_of_the_main_contact__c=null;
              aList1.add(acc1);
          }
          
          insert cList;
          update aList1;
          
        } 
}
global class bigObject implements database.Batchable<Sobject> {
    
    global database.QueryLocator start(database.BatchableContext bc){
        string query = 'select id,name,Industry from Account';
        return database.getQueryLocator(query);
    }
    global void execute(database.BatchableContext bc , list<account> scope ){
        list<Customer_Interaction__b> customer = new list<Customer_Interaction__b>();
        for(account a : scope){
            Customer_Interaction__b cusint = new Customer_Interaction__b();
            a.Id=cusint.Id;
            a.Name=cusint.Level_Achieved__c;
            a.Industry=cusint.Game_Platform__c;
            
            customer.add(cusint);
            
        }
        insert customer;
    }
    global void finish(database.BatchableContext bc){
        
    }
}
trigger Lead_Update on Lead (before insert,before update) {
    String dam ='';
    String jub='';
    String west1 ='';
    String west2 = '';
    String central = '';
    String Gcc = '';
    
     String uid=UserInfo.getUserId(); 
      User UserDetails =   [select  User.Lead_Region__c, User.Location__c from User Where User.Id =:uid limit 1]; 
       string UserLoc = UserDetails.Location__c;
       string LeadRegion = UserDetails.Lead_Region__c; 
        
    
    for(Lead lt : trigger.new){
        
       lt.Lead_City__c = UserLoc;
       lt.Region__c = LeadRegion;
    
        
    }

}
public class AnimalsCallouts {
    public static HttpResponse makeGetCallout() {
        Http http = new Http();
        HttpRequest request = new HttpRequest();
        request.setEndpoint('https://th-apex-http-callout.herokuapp.com/animals');
        request.setMethod('GET');
        HttpResponse response = http.send(request);
        // If the request is successful, parse the JSON response.
        if (response.getStatusCode() == 200) {
            // Deserializes the JSON string into collections of primitive data types.
            Map<String, Object> results = (Map<String, Object>) JSON.deserializeUntyped(response.getBody());
            // Cast the values in the 'animals' key as a list
            List<Object> animals = (List<Object>) results.get('animals');
            System.debug('Received the following animals:');
            for (Object animal: animals) {
                System.debug(animal);
            }
        }
        return response;
    }
    public static HttpResponse makePostCallout() {
        Http http = new Http();
        HttpRequest request = new HttpRequest();
        request.setEndpoint('https://th-apex-http-callout.herokuapp.com/animals');
        request.setMethod('POST');
        request.setHeader('Content-Type', 'application/json;charset=UTF-8');
        request.setBody('{"name":"mighty moose"}');
        HttpResponse response = http.send(request);
        // Parse the JSON response
        if (response.getStatusCode() != 201) {
            System.debug('The status code returned was not expected: ' +
                response.getStatusCode() + ' ' + response.getStatus());
        } else {
            System.debug(response.getBody());
        }
        return response;
    }        
}
HOW TO CREATE A VISUALFORCE PAGE FOR THIS APEX CLASS??? WITH TWO BUTTONS OF POST AND GET????
THANKS >>>
 

Hello.

How may I bulkify a query inside of another query efficiently? I realize that I should not query inside of a loop, but I'm afraid I don't know how to approach this. Any help would be greatly appreciated.

Trigger:

trigger someTask on Task (after insert, after update) {
	if(trigger.isupdate && trigger.isAfter){
        SomeClass.someMethod(Trigger.newMap, Trigger.oldMap);
    }
}


Class:

public class SomeClass {

    public static void someMethod(Map<id, Task> newMap, 
                                  Map<id, Task> oldMap) {
                                              
        // Iterate through all of the new map values
        for (Task someTask : newMap.values()) {
            
        	// Check if custom field is null
        	if (someTask.customField__c == null) {
            	
                // Populate next follow up by with contact name
                someTask.customField__c = [SELECT Owner.Name FROM Task WHERE id =: someTask.Id LIMIT 1].get(0).Id;
        	}
            else { // Do nothing
            }
        }
    }
}

Sincerely,

Jackie

Hello
We have two Sandboxes : one Full and one Developer sandbox.

For the Full sandbox, when we run the tests, we get test coverage but also when we click on a particular class we can see which lines are covered and which are not, thanks to the red and blue highlighting.

For the Developer sandbox, when we run the tests, we get test coverage but no red and blue highlighting.
So for example, when we have 90% coverage for a class, we cannot see which lines are affected by the the 10% missing coverage.

We've had this issue since the beginning, and it's becoming very annoying, because we have to deploy to Full sandbox to see which lines are covered.
We want to be able to do that at the beginning of our development lifecyle, that is, in the Developer sandbox.

So the question is, has anybody been able to see which lines are covered by tests in a Developer sandbox?
trigger AssignToFirstOwnerForDuplicteLeads on Lead (before insert, before update) {
    set <string> newEmaiSet = new set<string>();
    set<string> newPhNumSet = new set<string>();
    for(lead l1: trigger.new) {
        if(l1.Email != null) {
            newEmaiSet.add(l1.Email);
        }
        if(l1.phone != null) {
            newPhNumSet.add(l1.phone);
        }
    }
    List<lead> leadWithMatchingEmail = [select id, email, OwnerId from lead where email in :newEmaiSet];
    List<lead> leadWithMatchingPhone = [select id, phone, OwnerId from lead where email in :newPhNumSet];
    Map<string, id> emailVSId = new Map<string, id>();
    Map<string, id> phoneVSId = new Map<string, id>();
    for(lead l1: leadWithMatchingEmail) {
        emailVSId.put(l1.Email, l1.OwnerId);
    }
    for(lead l1: leadWithMatchingPhone) {
        phoneVSId.put(l1.phone, l1.OwnerId);
    }
    for(lead l1: trigger.new) {
        if(emailVSId.containsKey(l1.Email)) {
            l1.OwnerId = emailVSId.get((l1.Email));
        }
      //  if(phoneVSId.containsKey(l1.phone)) {
      //      l1.OwnerId = phoneVSId.get((l1.phone));
     //   }
        system.debug('l1::@@'+l1);
    }
    
}

Thanks in advance
Hi Experts,
I’m using eclipse to migrate metadata rom one Salesforce org to another salesforce org.
I’m facing issue to migrate custom fields of account object from source Salesforce org to target salesforce org. How can I do it? Please help.
 
@AuraEnabled
    public static Map<String, object> botaoExportarNovo(Map<String, object> btnExportar){
        Map<String, object> mapaObj = new Map<String, object>(); 
        CaseExpCsvController controller = new CaseExpCsvController();
        
        try{   
            controller.lInicio = Date.valueOf((String)btnExportar.get('dataInicio'));
            controller.lfim = Date.valueOf((String)btnExportar.get('dataFinal'));
            controller.lAtualizar = Boolean.valueOf(btnExportar.get('lAtualizar'));
            controller.lFltTipoCaso = String.valueOf(btnExportar.get('lFltTipoCaso'));
            controller.lFltStatusCaso = String.valueOf(btnExportar.get('lFltStatusCaso'));
            controller.llCsvGerado = true;
            controller.botaoExportar();
            mapaObj.put('lSelect', controller.ldisplay);
            
        }catch(exception e){ 
            controller.errors.add(e.getMessage());
        }
        mapaObj.put('Errors', controller.errors);
        return mapaObj;
    }

 

Hi all,

I wrote Trigger Apex with Apex class.

All is Ok on my sandbox, all Apex code is over 75% of code coverage but when I deploy Trigger on my production, I have 0% of code coverage (just for trigger):
"Each trigger must have at least 1% code coverage."

 

trigger CompleteFirstResponseEmail on EmailMessage (after insert) {
    if (UserInfo.getUserType() == 'Standard'){
        DateTime completionDate = System.now();
        Map<Id, String> emIds = new Map<Id, String>();
        for (EmailMessage em : Trigger.new){
            if(em.Incoming == false)
                emIds.put(em.ParentId, em.ToAddress);
        }
        if (emIds.isEmpty() == false){
            Set <Id> emCaseIds = new Set<Id>();
            emCaseIds = emIds.keySet();
                List<Case> caseList = [Select c.Id, c.ContactId, c.Contact.Email,
                    c.OwnerId, c.Status,
                    c.EntitlementId,
                    c.SlaStartDate, c.SlaExitDate
                    From Case c where c.Id IN :emCaseIds];
            if (caseList.isEmpty()==false){
                    List<Id> updateCases = new List<Id>();
                    for (Case caseObj:caseList) {
                        if ((emIds.get(caseObj.Id)==caseObj.Contact.Email)&&
                            //(caseObj.Status == 'In Progress')&&
                            (caseObj.EntitlementId != null)&&
                            (caseObj.SlaStartDate <= completionDate)&&
                            (caseObj.SlaStartDate != null)&&
                            (caseObj.SlaExitDate == null))
                            updateCases.add(caseObj.Id);
                    }
                if(updateCases.isEmpty() == false){
                    milestoneUtils.completeMilestone(updateCases, 
                                'First Response', completionDate);
                }
            }
        }
    }        
}
 
public class MilestoneUtils {
    public static void completeMilestone(List<Id> caseIds, 
            String milestoneName, DateTime complDate) {
    if  (complDate != date.today().addDays(-5)) {
                    List<CaseMilestone> cmsToUpdate = [select Id, completionDate
            from CaseMilestone cm
            where caseId in :caseIds and cm.MilestoneType.Name=:milestoneName 
            and completionDate = null limit 1];
            if (cmsToUpdate.isEmpty() == false){
        for (CaseMilestone cm : cmsToUpdate){
            cm.completionDate = complDate;
            }
        update cmsToUpdate;
        }
    else {
        // BAD CODE, JUST HERE TO HAVE OVER 75 %
        List<CaseMilestone> cmsTest = [select Id, completionDate
            from CaseMilestone cm
            where caseId in :caseIds limit 1];
        if (cmsToUpdate.isEmpty() == true) {
            update cmsTest;
        }
    }
    }          
    }
}
@isTest
private class MilestoneTest {

static testMethod void TestCompleteMilestoneCase(){

List<Account> acts = new List<Account>();
Account myAcc = new Account(Name='TestAct', phone='1001231234');
acts.add(myAcc);

Account busAcc = new Account(Name = 'TestForMS', phone='4567890999');
acts.add(busAcc);
insert acts;
Contact cont = new Contact(FirstName = 'Test', LastName = 'LastName', phone='4567890999', accountid = busAcc.id);
insert(cont);

Contact oContact = [select id from Contact limit 1];
        String contactId;
        if (oContact != null)
          contactId = oContact.Id;

Asset ast = new Asset(Name='support platinum', 
                      AccountId=busAcc.Id, 
                      Start_date__c = date.today().addDays(-5), 
                      End_date__c = date.today().addDays(5));
insert ast;

ast = [SELECT Id, Name, Active__c, Start_date__c, End_date__c, AccountId FROM Asset WHERE Id=:ast.Id];
    
String astId;
if (astId != null)
astId = ast.Id;    
    
Entitlement entl = new Entitlement(Name='First Response - SUPPORT PLATINUM PLAN - TestForMS', AccountId=busAcc.Id, AssetId = astId, EndDate= date.today().addDays(5), StartDate= date.today());
insert entl;
    
String entlId;
if (entl != null)
entlId = entl.Id; 
        
List<Case> cases = new List<Case>{};
if (entlId != null){
    Case c = new Case(Subject = 'Test Case with Entitlement ', 
    EntitlementId = entlId, ContactId = contactId, Description = 'test', Departement__c = 'Centreon', AssetId = astId, Priority = 'Blocking', SlaStartDate = date.today());
    cases.add(c);
}
if (cases.isEmpty()==false){
    insert cases;
    
    List<Id> caseIds = new List<Id>();
    for (Case cL : cases){
        caseIds.add(cL.Id);
    }
    milestoneUtils.completeMilestone(caseIds, 'First Response', System.now());
}
}
    
static testMethod void testCompleteMilestoneViaCase(){
List<Account> acts = new List<Account>();
Account myAcc = new Account(Name='TestAct', phone='1001231234');
acts.add(myAcc);

Account busAcc = new Account(Name = 'TestForMS', phone='4567890999');
acts.add(busAcc);
insert acts;
Contact cont = new Contact(FirstName = 'Test', LastName = 'LastName', phone='4567890999', accountid = busAcc.id, Email='test@test.com');
insert(cont);

Contact oContact = [select id from Contact WHERE Email != NULL limit 1];
        String contactId;
        if (oContact != null)
          contactId = oContact.Id;

Asset ast = new Asset(Name='support platinum', 
                      AccountId=busAcc.Id, 
                      Start_date__c = date.today().addDays(-5), 
                      End_date__c = date.today().addDays(5));
insert ast;

ast = [SELECT Id, Name, Active__c, Start_date__c, End_date__c, AccountId FROM Asset WHERE Id=:ast.Id];
    
String astId;
if (astId != null)
astId = ast.Id;  
    
    
Entitlement entl = new Entitlement(Name='First Response - SUPPORT PLATINUM PLAN - TestForMS', AccountId=busAcc.Id, AssetId = astId, EndDate= date.today().addDays(5), StartDate= date.today());
insert entl;
        // Perform data preparation
        entl = [select id from Entitlement limit 1];
        String entlId;
        if (entl != null)
            entlId = entl.Id;
        List<Case> cases = new List<Case>{};
        for(Integer i = 0; i < 1; i++){
            Case c = new Case(Subject = 'Test Case ' + i, Description = 'test');
            cases.add(c);
            if (entlId != null){
                c = new Case(Subject = 'Test Case with Entitlement ' + i, EntitlementId = entlId
                             , ContactId = contactId, Description = 'test', Departement__c = 'Centreon'
                             , AssetId = astId, Priority = 'Blocking', SlaStartDate = date.today());
                cases.add(c);
            }
        }
        
        // Insert the Account records that cause the trigger to execute.
        insert cases;

        List<CaseComment> ccs = new List<CaseComment>{};
        for(Case c : cases){
            CaseComment cc = new CaseComment(CommentBody='TestPublic', IsPublished=true, ParentId=c.Id);
            ccs.add(cc);
            cc = new CaseComment(CommentBody='TestPrivate', IsPublished=false, ParentId=c.Id);
            ccs.add(cc);
        }
        if (ccs.isEmpty()==false)
            insert ccs;
    
    // Now create emailmessage objects for them.
    
        List<EmailMessage> emails = new List<EmailMessage>();
        for(Case c : cases){
            emails.add(new EmailMessage(parentId = c.id));
        }
        if(emails.isEmpty()==false)
            database.insert(emails);
        
        for(Case c : cases){
            Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
            String[] toAddr = new String[] {'test@test.com'};
            mail.setToAddresses(toAddr);
            mail.setSaveAsActivity(false);
            mail.setTargetObjectId(c.ContactId);
            mail.setWhatId(c.Id);
            mail.setHtmlBody('TestHTMLBody');
            mail.setPlainTextBody('TestTextBody');
            Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
        }
      
        // Query the database for the newly inserted records.
        List<Case> insertedCases = [SELECT Subject,
                                           Description,
                                          (SELECT IsPublished, CommentBody From CaseComments),
                                          (SELECT TextBody, Subject, Incoming From EmailMessages)
                                           FROM Case
                                           WHERE Id IN :cases];
    }    
    
}

Can you help me?

Thanks
Hi,
i'm doing trailhead challenge on Automate Simple Business Processes with Process Builder, and i got an error that said "There was an unexpected error in your org which is preventing this assessment check from completing: System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Web Site must have an extension of .com, .org, or .net.: [Website]"

do you know how can i fix it ?

this is the step of the challenge =
The process can have any name
The process must have an Update Records action that updates Contact mailing address fields (Street, City, State, Postal Code, Country) when the parent Account shipping address field values are updated
The process must be active

NOTE: To complete this challenge, you may have to deactivate the validation rule for the Contacts object (created from a previous challenge).

and my work =
User-added image
User-added image
Hi,

I have a batch class running, which allocates sales rep based on the the zip code assigned.

My problem here is , It is running for one profile , but not running for other. .

Is there something in configuration , that I am missing ? Please advise 

 
I created a very basic Trigger:

trigger HelloWorld on Lead (before update) {
    for (Lead L : Trigger.new) {
    L.FirstName = 'Hello';
    L.LastName  = 'World';
  }
}

When I create a new Lead record in Classic, it works as expected (ie, no change since it should fire only in Update) but when I create a new Lead record in Lightning, as soon as I save, the first and last name gets updated to Hello World.

This is a brand new developer Org and so there are no other triggers etc. Has anyone else run into this problem?
trigger updateFundraiser on Account (before update) { 
    set<id> conIds = new set<id>(); 
    for(account a1: trigger.new) {
        if(a1.Contact_Associated__c != null) {
            conIds.add(a1.Contact_Associated__c);
        }
    }
    system.debug('conIds::'+conIds);
    map<id,contact> conMap = new map<id,contact>([select id,Name, Beneficiary_Name__c,Email, MobilePhone from contact where id IN :conIds]);
    system.debug('conMap::'+conMap);
    for(account a1:trigger.new){
        system.debug('a1.Contact_Associated__c::'+a1.Contact_Associated__c);
        system.debug('!!!!!!'+trigger.oldMap.get(a1.id).Contact_Associated__c);
        //if(a1.Contact_Associated__c != trigger.oldMap.get(a1.id).Contact_Associated__c) {
            system.debug('herere!!!');
           a1.Mobile_Number__c = conMap.get(a1.Contact_Associated__c).MobilePhone;
            a1.Created_By_Email__c = conMap.get(a1.Contact_Associated__c).Email;   
            a1.Name = conMap.get(a1.Contact_Associated__c).Name;   

            system.debug('herere!!!');
            system.debug('a1'+a1);   
        //}
    }
   
    

}
I was working on the Customize Your Login Process with My Domain module and I accidentally changed my domain of my Hands-On Org. Is it possible to change it back to what it was? I get an error message now when I try to launch my hands-on org. L

My former Hands On Org. URL is as follows: curious-badger-397879-dev-ed.my.salesforce.com

The domain I changed it to is: mylightsaber.dom-dev-ed.my.salesforce.com
 
NOT (ISPICKVAL( Transfer_ID__r.Transfer_Type__c , 'Store to WHS') AND (Shipping_Quantity__c > Serial_No__r.Quantity_available__c ))

I am getting ) missing in thie validation rule, Can someone help?

System.QueryException: List has more than 1 row for assignment to SObject
Class.AccountSearchUI.<init>: line 13, column 1

My VF Page

<apex:page standardController="Account" extensions="AccountSearchUI">
<head>
<title>Account Search UI</title>
<style type="text/css"> </style>
</head>

<body>
<table width="99%" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
    <tr>
        <td height="5" bgcolor="#FFFFFF">&nbsp;</td>
        <td height="5" bgcolor="#FFFFFF">&nbsp;</td>
        <td height="5" bgcolor="#FFFFFF">&nbsp;</td>
    </tr>
    <tr>
        <td bgcolor="#FFFFFF"></td>
        <td bgcolor="#FFFFFF"></td>
        <td bgcolor="#FFFFFF"></td>
      </tr>
    <tr>
        <td height="5" bgcolor="#FFFFFF">&nbsp;</td>
        <td height="5" bgcolor="#FFFFFF">&nbsp;</td>
        <td height="5" bgcolor="#FFFFFF">&nbsp;</td>
    </tr>
    <tr>
    <td bgcolor="#FFFFFF" valign="top">
        <table width="100%" border="0" align="center" cellpadding="1" cellspacing="0" class="tablemain">
            <tr><td height="1"></td></tr>
            <tr><td height="50" class="headingmain">&nbsp;Account Search UI</td></tr>
            <tr>
                <td align="center">
                  <table width="100%" border="0" cellspacing="0" cellpadding="1" class="tablemain">
                    <tr>
                      <td width="10%" height="23" class="headingsub1">Group Org Acc</td>
                      <td width="10%" height="23" class="headingsub1">Vertical</td>
                      <td width="10%" height="23" class="headingsub1">Account Name</td>
                      <td width="10%" height="23" class="headingsub1">Type</td>
                      <td width="10%" height="23" class="headingsub1">Owner Last Name</td>
                      <td width="10%" height="23" class="headingsub1">Client Rank</td>
                      <td width="10%" height="23" class="headingsub1">Account Plan</td>
                      <td width="10%" height="23" class="headingsub1">Last Modified</td>
                      <td width="10%" height="23" class="headingsub1">View Latest PDF</td>
                      <td width="10%" height="23" class="headingsub1">PDF Upload Date</td>
                    </tr>
                    <apex:repeat value="{!accPList}" var="cp">
                    <tr>
                        <td height="23" class="headingsub1"><apex:outputField value="{!cp.Group_Org__c}"/></td>
                        <td height="23" class="headingsub1"><apex:outputField value="{!cp.Vertical__c}"/></td>
                        <td height="23" class="headingsub1"><apex:outputField value="{!cp.Name}"/></td>
                        <td height="23" class="headingsub1"><apex:outputField value="{!cp.Type}"/></td>
                        <td height="23" class="headingsub1"><apex:outputField value="{!cp.Client_Rank__c}"/></td>
                        <td height="23" class="headingsub1"><apex:outputField value="{!cp.Group_Org__c}"/></td>
                        <td height="23" class="headingsub1"><apex:outputField value="{!cp.Vertical__c}"/></td>
                        <td height="23" class="headingsub1"><apex:outputField value="{!cp.Name}"/></td>
                        <td height="23" class="headingsub1"><apex:outputField value="{!cp.Type}"/></td>
                        <td height="23" class="headingsub1"><apex:outputField value="{!cp.Client_Rank__c}"/></td>
                    </tr>
                    </apex:repeat>
          </table>
        </td>
        
      </tr>
    </table></td>
    <td bgcolor="#FFFFFF" valign="top"></td>
    <td bgcolor="#FFFFFF" valign="top"></td>
  </tr>
  
  <tr>
    <td bgcolor="#FFFFFF">&nbsp;</td>
    <td bgcolor="#FFFFFF">&nbsp;</td>
    <td bgcolor="#FFFFFF">&nbsp;</td>
  </tr>

</table>

</body>

</apex:page>

APEX Class
public with sharing class AccountSearchUI{    

    public ApexPages.StandardController stdController {get; set;}
    public Account acc {get; set;}
    public Account accPList {get; set;}
    
    public String accountName ='';
    public AccountSearchUI(ApexPages.StandardController stdController){
    this.stdController = stdController;

 accPList = [select Group_Org__c, Vertical__c, Name, Type, Client_Rank__c from Account where Top_25_Client__c = true and Client_Rank__c < 26 order by Client_Rank__c ASC limit 5];
    }
}
Can anyone help with the issue.
 
This is my code
=============
global class BatchApex implements Database.Batchable<sobject>{
    global Database.QueryLocator start(Database.BatchableContext bc){
        return Database.getQueryLocator('select id from Opportunity');
        
    }
    global void execute(Database.BatchableContext bc,List<Opportunity>scope){
        for(Opportunity o:scope){
            o.Name='sandhya';
        }
    update scope;
}
    global void finish(Database.BatchableContext bc){
            
   Messaging.SingleEmailMessage[] mail=new Messaging.SingleEmailMessage();
        String[] toAddresses=new String[] {'forcesfdcloud@gmail.com'};
            mail.setToAddresses(toAddresses);
        mail.setSubject('sending mail ');
        mail.setPlainTextBody('process completed success fully');
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] {mail});
      
    }
    }
I want to update my opportunities. After updating the opportunities i want to send a mail to the above mentioned address, but it shows error like" Illegal assignment from Messaging.SingleEmailMessage to List<Messaging.SingleEmailMessage>" can any one tell me how to solve this issue.
trigger CheckValidationonCaseClose on Case (after update) {     
for(Case e:Trigger.New){          
Case d=Trigger.oldMap.get(e.Id);         
if(d.Signature_Required__c==true && d.Customer_Signature_Status__c!='Completed' && e.IsClosed==true)
{  
e.adderror('Cannot Close Case');
}

its urgent
}  
Hi,

I have a rquirement to format a time which is given in HH:MM format (24-hour clock) into the user's locale. I assumed that there would be a fromat() method as the DateTime class does, but it does not exist.

Any ideas how I can do this?

Thanks
I have a Salesforce App which passed security review for the first time in the last year. This App also includes integration with external web application, due to this I also submitted a BURP scan report of the external web application. I am not sure about how Salesforce conducts periodic security review and have some queries.

As you may know, Salesforce provides periodic, point-in-time review at an interval determined by salesforce.com (typically anywhere between 6 months to 2 years).

• As per Salesforce documentation for already passed Apps, around the expiry date, Salesforce contacts partners to arrange another review. Can you guide me on how much time Salesforce gives us to prepare for Security Review?

• BURP scan and fixing the issues reported by it can take time. If I could not submit a clean BURP scan report within the time frame provided by Salesforce, Does Salesforce remove package from AppExchange?

• Salesforce charges for Security Review process for paid Apps, as one-time upfront fee, and a small subsequent annual fee. Can you guide me on how much subsequent annual fee Salesforce charges to partners? Salesforce also charges annual listing fee of $150 USD. Is that correct?

Kindly help me with this. Thanks in advance.
Hi All,

I want to disable the global search for particular users,i have disabled the chatter in chatte section,please give me suggestion how to disable the global search.
see the below screen shot where i have disabled
User-added image

see the below screen shot for what i want to disable 

User-added image

Thanks,
Surya
I'm stuck on only one unit for this module; the controlling access to fields unit:

"Two team members need to view and update Accounts, but only one should be able to see and edit the Rating field. Create one profile and one permission set with field level security to solve for this use case.The profile must be named 'Basic Account User' and result in an API name of 'Basic_Account_User'. It should use the 'Salesforce' user license type.
The permission set must be named ‘Account Rating’ and result in an API name of 'Account_Rating'."

"Challenge Not yet complete... here's what's wrong:
The 'Basic Account User' profile did not have the appropriate object and field-level security for the Account object "
  • February 02, 2016
  • Like
  • 1
Hi Jacob,

I have already completed 5 badges, but still no email for obtaining the Cloak of Adventure sweatshirt. Does it take username or email address for sending emails, as my email address and user name are different.

User-added image
Hi,

I want to send an email alert to task owner if they have any open task which due date is already passed.
I want to send it 1 day after due date and 1 week after due date.
Please suggest how I can achieve it because through workflow it is not achievable.

Regards
Emily
 view state and need a steps how can we reduce view state without help of transient
Hi,

I have executed "Run all test" to get code coverage of all apex classes. Is there way to get all apex classes code coverage with percentage copy to excel sheet. I am able to see all classes with percentage in Developer console. But not able to copy all those. Please provide some suggestion.
We are using Apex Data Loader 19.0 and cliq_process.  Using Apex Data Loader & Cliq_process, we are exporting the data into salesforce custom object. The process was working fine past 2 years and till last week. Last few days we are getting the below error.


2015-08-17 06:12:31,218 INFO  [ExportRevenue] process.ProcessRunner run (ProcessRunner.java:104) - Logging in to: https://www.salesforce.com/services/Soap/u/19.0
2015-08-17 06:12:31,233 INFO  [ExportRevenue] client.PartnerClient login (PartnerClient.java:989) - Beginning Partner Salesforce login ....
2015-08-17 06:12:31,249 INFO  [ExportRevenue] client.PartnerClient login (PartnerClient.java:998) - Salesforce login to https://www.salesforce.com/services/Soap/u/19.0/services/Soap/u/19.0 as user forceuser@<company>.com
2015-08-17 06:12:31,655 INFO  [ExportRevenue] dao.DataAccessObjectFactory getDaoInstance (DataAccessObjectFactory.java:51) - Instantiating data access object: C:\Program Files\salesforce.com\Apex Data Loader 19.0\cliq_process\ExportRevenue\write\ExportRevenue.csv of type: csvWrite
2015-08-17 06:12:31,655 INFO  [ExportRevenue] process.ProcessRunner run (ProcessRunner.java:109) - Checking the data access object connection
2015-08-17 06:12:31,655 INFO  [ExportRevenue] process.ProcessRunner run (ProcessRunner.java:114) - Setting field types
2015-08-17 06:12:31,766 ERROR [ExportRevenue] client.PartnerClient describeSObject (PartnerClient.java:1249) - Error while calling web service operation: describeSObject, error was: Failed to send request to https://ncst.my.salesforce.com/services/Soap/u/19.0/00D400000009okc
com.sforce.ws.ConnectionException: Failed to send request to https://<company>.my.salesforce.com/services/Soap/u/19.0/00D400000009okc
    at com.sforce.ws.transport.SoapConnection.send(SoapConnection.java:113)
    at com.sforce.soap.partner.PartnerConnection.describeSObject(PartnerConnection.java:48)
    at com.salesforce.dataloader.client.PartnerClient.describeSObject(PartnerClient.java:1240)
    at com.salesforce.dataloader.client.PartnerClient.setFieldTypes(PartnerClient.java:1196)
    at com.salesforce.dataloader.controller.Controller.setFieldTypes(Controller.java:127)
    at com.salesforce.dataloader.process.ProcessRunner.run(ProcessRunner.java:115)
    at com.salesforce.dataloader.process.ProcessRunner.main(ProcessRunner.java:229)
Caused by: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
    at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Alerts.java:150)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1476)
    at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Handshaker.java:174)
    at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Handshaker.java:168)
    at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:847)
    at com.sun.net.ssl.internal.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:106)
    at com.sun.net.ssl.internal.ssl.Handshaker.processLoop(Handshaker.java:495)
    at com.sun.net.ssl.internal.ssl.Handshaker.process_record(Handshaker.java:433)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:815)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1025)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1038)
    at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:402)
    at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:170)
    at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:836)
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:230)
    at com.sforce.ws.transport.JdkHttpTransport.connectLocal(JdkHttpTransport.java:97)
    at com.sforce.ws.transport.JdkHttpTransport.connect(JdkHttpTransport.java:82)
    at com.sforce.ws.transport.SoapConnection.send(SoapConnection.java:99)
    ... 6 more
Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
    at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:221)
    at sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:145)
    at sun.security.validator.Validator.validate(Validator.java:203)
    at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:172)
    at com.sun.net.ssl.internal.ssl.JsseX509TrustManager.checkServerTrusted(SSLContextImpl.java:320)
    at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:840)
    ... 19 more
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
    at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:236)
    at java.security.cert.CertPathBuilder.build(CertPathBuilder.java:194)
    at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:216)
    ... 24 more
2015-08-17 06:12:31,766 FATAL [main] process.ProcessRunner topLevelError (ProcessRunner.java:214) - Unable to run process ExportRevenue
java.lang.RuntimeException: com.sforce.ws.ConnectionException: Failed to send request to https://<company>.my.salesforce.com/services/Soap/u/19.0/00D400000009okc
    at com.salesforce.dataloader.process.ProcessRunner.run(ProcessRunner.java:139)
    at com.salesforce.dataloader.process.ProcessRunner.main(ProcessRunner.java:229)
Caused by: com.sforce.ws.ConnectionException: Failed to send request to https://<company>.my.salesforce.com/services/Soap/u/19.0/00D400000009okc
    at com.sforce.ws.transport.SoapConnection.send(SoapConnection.java:113)
    at com.sforce.soap.partner.PartnerConnection.describeSObject(PartnerConnection.java:48)
    at com.salesforce.dataloader.client.PartnerClient.describeSObject(PartnerClient.java:1240)
    at com.salesforce.dataloader.client.PartnerClient.setFieldTypes(PartnerClient.java:1196)
    at com.salesforce.dataloader.controller.Controller.setFieldTypes(Controller.java:127)
    at com.salesforce.dataloader.process.ProcessRunner.run(ProcessRunner.java:115)
    ... 1 more
Caused by: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
    at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Alerts.java:150)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1476)
    at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Handshaker.java:174)
    at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Handshaker.java:168)
    at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:847)
    at com.sun.net.ssl.internal.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:106)
    at com.sun.net.ssl.internal.ssl.Handshaker.processLoop(Handshaker.java:495)
    at com.sun.net.ssl.internal.ssl.Handshaker.process_record(Handshaker.java:433)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:815)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1025)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1038)
    at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:402)
    at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:170)
    at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:836)
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:230)
    at com.sforce.ws.transport.JdkHttpTransport.connectLocal(JdkHttpTransport.java:97)
    at com.sforce.ws.transport.JdkHttpTransport.connect(JdkHttpTransport.java:82)
    at com.sforce.ws.transport.SoapConnection.send(SoapConnection.java:99)
    ... 6 more
Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
    at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:221)
    at sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:145)
Exact replication steps:
1. Create a connected app
2. Add the callback URL to that connected app as the URL of a VF page. For Eg - 'https://c.eu2.visual.force.com/apex/mypage'.
3. Connect to another salesforce org of the same instance.Énter the login details ie username and password
4. Allow permission to the connected app create on your source org to access info about target org by clicking on Állow Button'
5. Instead of redirecting back to source org it redirects me to the target org and tries to open up the page mentioned in the callback url.
6. This issue is coming when my source and target org are on same instance. It works fine when source and target instances are different.
Hello,
I have some queries on release versioning and listing subsequent versions on AppExchange:
  1. Can I release and maintain 2 versions on AppExchange? In other words, if there a v1.0 that is listed on AppExchange, and we release a new version v1.1 that has passed Security Review and ready to be listed on AppExchange, does it automatically replace the v1.0 that was listed earlier? 
  2. Do the existing customer orgs get any notification of a new released version? If yes, does it automatically contain the install link? If not, what is the most preferred practice?
  3. If I deprecate an earlier version, do the customer orgs using this version get a notification to upgrade? Are they forced to upgrade?
  4. If a patch is created for a particular released version, do I have to manually inform all customer orgs using it? Or do they get automatic notifications of the same and can choose to apply the patch as needed?
Thanks in advance!
Hi,

I want to develop an "Open CTI Adapter", where can I find the documentation(API/Library) for the same?

Regards,
Rohan
Hi ,
  
 I'm trying to parse Account records to JSON string. But I'm getting unnecessary data like attributes(type,url) that is not required in String.

Can any one pls help me in how to parse the string to required format.
List<Account> accnts=[Select Name,Phone From Account];
String s=JSON.serialize(accnts);
The resulting output is in below fromat..
{
  "attributes" : {
    "type" : "Account",
    "url" : "/services/data/v34.0/sobjects/Account/00128000002trGGAAY"
  },
  "Name" : "GenePoint",
  "Phone" : "(650) 867-3450",
  "Id" : "00128000002trGGAAY"
}


My requirement is to generate resulting String as below JSON string format.
 
{
  "Name" : "GenePoint",
  "Phone" : "(650) 867-3450",
  "Id" : "00128000002trGGAAY"
}

So that I can minimize the data to to be sent the the client system.

Any help is really appreciated. Thanks in advance.

Regards,
Naveen.
I need to download Contacts Near By component for the trailhead - field sales app project but I am not able to find it on appexchange. Any idea where can I get it from?