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


  • Chatter
    Feed
  • 1149
    Best Answers
  • 1
    Likes Received
  • 32
    Likes Given
  • 3
    Questions
  • 5544
    Replies
Hi All,

I completed my extension page so now I need to write a test class.

I have been researching into how to write a test class but all the example i have seen are very different to mine therefore I dont still undertand how to apply the content to my test class.

This is my extension page code:

public with sharing class extencntrl{
    
    private ApexPages.StandardController sc;
    public extencntrl(ApexPages.StandardController sc) {
        this.sc = sc;
    }
    
    public boolean displayPopup {get; set;}     
    
    public void closePopup() {  
        displayPopup = false;
        
    }     
    public void showPopup() {        
        displayPopup = true;
        
    }
    
public PageReference Save() {
          PageReference detailPage = sc.Save();
        if (detailPage != null) {
            PageReference editPage = new PageReference(Label.websiteurl); 
            return editPage ;
        } else {
            return detailPage;
        }
    }
}


Please if someone knows how I could possible start developing the test class, please let me know!

Thanks,
Ola
Hi,
I'm going through "https://trailhead.salesforce.com/trails/force_com_dev_beginner/modules/apex_database/units/apex_database_dml" module and while implementing the challenge, I am getting following error:
Challenge Not yet complete... here's what's wrong: 
There was an unexpected error in your org which is preventing this assessment check from completing: System.DmlException: Delete failed. First exception on row 0 with id 0017F00000LQrpmQAD; first error: DELETE_FAILED, Your attempt to delete My Test Account could not be completed because it is associated with the following cases.: 00001036 : []

There is no account with name as "My Test Account" & no case with number  as "00001036" visible in my org. Also, I am creating an account record why is it reflecting a message related to deleting of account? Please suggest.

Regards
Hi All,
I am net to Map and need ur help here.

Can anyone help me how to fill value in Map in below example. Can you please help me with the Code?

Map<id,List<Contacts>> CustMap = new Map<Id,List<Contacts>>;

for(Account ac:[SELECT id,name,(SELECT id FROM Contacts) FROM Account])
{
How to fill Map here where Id would be Account Id and Values would be list of Contacts.?
}

Regards,
Varun
 
For this trigger trailhead question:
For this challenge, you need to create a trigger that, before insert or update, checks for a checkbox, and if the checkbox field is true, sets the Shipping Postal Code (whose API name is ShippingPostalCode) to be the same as the Billing Postal Code (BillingPostalCode).

The Apex trigger must be called 'AccountAddressTrigger'.
The Account object will need a new custom checkbox that should have the Field Label 'Match Billing Address' and Field Name of 'Match_Billing_Address'. The resulting API Name should be 'Match_Billing_Address__c'.
With 'AccountAddressTrigger' active, if an Account has a Billing Postal Code and 'Match_Billing_Address__c' is true, the record should have the Shipping Postal Code set to match on insert or update.


Getting following error while checking the challenge on trailheads:
Challenge Not yet complete... here's what's wrong:
There was an unexpected error in your org which is preventing this assessment check from completing: System.QueryException: List has no rows for assignment to SObject
Trigger

trigger SDS_AE_onAccount on Account (before update) {
//load salesmapping table in memory
List<Sales_mapping__c> Shiva = [Select OwnerId, mapping_type__c,AE__c from sales_mapping__c];    
List<Account> UpdateSDSAE = new List<Account>();
    for(account a: Trigger.new)
    {
        if(a.Owner_profile__c == 'SDS' || a.Owner_profile__c == 'SDS Manager')
        {
            a.SDS__c = a.OwnerId;
            UpdateSDSAE.add(a);
        }
        else if(a.Owner_Profile__c=='AE' && trigger.Oldmap.get(a.Id).SDS__c == trigger.Newmap.get(a.Id).SDS__c)
        {
          a.AE__c = a.OwnerId;
            UpdateSDSAE.add(a);
            SDSAD.SSDSD(UpdateSDSAE);
            //look up the salesmapping table in memory
                
        }
        else if(a.AE__c != null && trigger.oldmap.get(a.id).AE__c != trigger.newmap.get(a.id).AE__c){
            SDSAD.SSDSD(UpdateSDSAE);            
        }
        }
}


-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Class  and Method : 

public class SDSAD {
    public static void SSDSD(List<Account>UpdateSDSAE){
    list<account> shiva = [Select Id, AE__c from Account where Id In: UpdateSDSAE];
    list<sales_mapping__c> Koushik = [Select Id, AE__c, mapping_type__c,SDS__c from Sales_mapping__c];
        for(account a : shiva){
            for(sales_mapping__c s: koushik) {
                if (a.AE__c == s.AE__c && s.mapping_type__c == 'AE/SDS'){
                a.SDS__c = s.SDS__c;                    
                }
                else if(a.AE__c == s.AE__c && s.mapping_type__c == 'AE/IWAE'){
                    a.iWayAE__c = s.sds__c; 
                }
            }
        }
    }
}

The trigger calls the class based on condition, but i need to bulkify the class without changing the functionality.

Note : Account and Sales_Mapping__c Objects are not related in any way, the sales mapping Object has all mapped AE and SDS users, hence i need to get SDS value from Sales_mapping__c object when AE is the account owner.
Hi all,

I got this fail text:
Challenge Not yet complete... here's what's wrong: 
Could not find a contact named "Edna Frank" or there are multiple contacts with the name "Edna Frank". Ensure that there is only one contact named "Edna Frank" in your org.

But there's only one Edna in the org I used. ( spelled correctly) Is this familiar to someone? I would be grateful.

Greetings, Bernard
How do I log in to Trailhead to complete installing the app just downloaded to complete App Exchange challenge? Upon download only Production or sandbox is an option, no developer orgs.
 
A trivial (but helpful, I admit) error in the module 'Apex Integration Services' -> Apex Web Services,  in the @HttpPut method - 
https://trailhead.salesforce.com/modules/apex_integration_services/units/apex_integration_webservices
An additional line of code (thisCase.id = id;) is missing before the 'upsert'  statement in the following practice code of this trailhead section. Request to please correct this if judged appropriate. btw, this mistake was helpful to me during learning....so up to you.

@HttpPut
global static ID upsertCase(String subject, String status,
    String origin, String priority, String id) {
    Case thisCase = new Case(
        Id=id,
        Subject=subject,
        Status=status,
        Origin=origin,
        Priority=priority);
    // Match case by Id, if present.
    // Otherwise, create new case.
    upsert thisCase;
    // Return the case ID.
    return thisCase.Id;
}
 
public with sharing class accsearchcontroller
  {
    public accsearchcontroller(ApexPages.StandardController controller) {     }   
  public String l { get; set; }
public list <quote> acc {get;set;}
public string searchstring {get;set;}
public String quoteid{get; set;}
public Boolean search{get; set;}
public Boolean result{get; set;}
public accsearchcontroller( )
  { }
public void search()
{ string searchquery='select QuoteNumber,Name,Email,Opportunity.Name,SAP_Reference_Number__c  from quote where SAP_Reference_Number__c like \'%'+searchstring+'%\' OR SAP_Reference_Number__c like \'*'+searchstring+'*\'  Limit 20'; acc= Database.query(searchquery);
}
public void clear()
{
acc.clear();
}
public PageReference processLinkClick()
 {                 
  search = false;    
    result = false;     
    //Pagereference p1 = new PageReference('https://ap7.salesforce.com/'+quoteid);     
  Pagereference p1 = new PageReference('https://swainswain-dev-ed.my.salesforce.com/'+quoteid);     
    p1.setRedirect(true);    
     return p1;    
 }
}
global class PartnerUserNotLoggedfor30DaysBatch implements Database.Batchable<sObject>{
    
    Date myDate;
    
    Date myDate30Days;
    Id email30DaysTemplateId;
    
    global PartnerUserNotLoggedfor30DaysBatch(){
        myDate = Date.today();
        myDate30Days= Date.today()+30;
        
    }
   
    global Database.querylocator start(Database.BatchableContext BC)
    {
        return Database.getQueryLocator([SELECT Id,name,IsActive,isFrozen__c,IsPortalEnabled,Validity_Date__c,ABB_Manager__c,
                            Profile.name,LastLoginDate,email FROM User WHERE IsPortalEnabled = true AND IsActive = true 
                            AND isFrozen__c = false AND (Profile.Name=:Label.SYS_ABBExtChannelPartnerCommunityUser 
                            OR Profile.Name=:Label.SYS_ABB_Ext_Rep_Community_User 
                            OR Profile.Name=:Label.SYS_ABB_Ext_Agent_Community_User)
                            AND LastLoginDate =: myDate30Days]);   
    }
    global void execute(Database.BatchableContext BC, List<User> listOfUsers)
    { 
    
        Set<Id> setChnlMngrIds=new Set<Id>();
        Set<Id> set30DaysExpUsers = new set<Id>();
        Set<Id> set4WksExpUsers = new set<Id>();
        Map<Id,User> mapOf30DaysExpUsers = new Map<Id,User>();
        Map<Id,User> mapOf4WksExpUsers = new Map<Id,User>();
        Map<Id,User> mapOfABBMngrEmails;
        
        if(listOfUsers.size()>0 && listOfUsers != null){
            
            for(user usr : listOfUsers){
                setChnlMngrIds.add(usr.ABB_Manager__c);
                if(usr.LastLoginDate == myDate30Days){
                    set30DaysExpUsers.add(usr.id);
                    mapOf30DaysExpUsers.put(usr.id,usr);
                }
            }
            if(setChnlMngrIds.size()>0){
            mapOfABBMngrEmails = new Map<Id,User>([Select id,name,email from User where id =: setChnlMngrIds Limit 5000 ]);
            }
            
            List<String> lstToAddRecp = new List<String>();
            List<Messaging.SingleEmailMessage> emails = new List<Messaging.SingleEmailMessage>();
            
            if(mapOf30DaysExpUsers != null && mapOf30DaysExpUsers.size()>0){
                Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
                for(User usr : mapOf30DaysExpUsers.values()){
                    String BodyText = '<html><body>Dear '+ usr.name +'<br/><br/>'+
                                        'Not Logged for 30 days '+ usr.LastLoginDate+'.'+
                                        '<br/><br/>'+
                                        'To extend your access for next 365 days please contact your ABB Channel Manager.'+
                                        '<br/><br/>Best regards,<br/>SFDC Team<br/><br/>'+
                                        'This is system notification. Please do not reply to this email.'+
                                        '</body></html>'; 
                                        email.setHtmlBody(BodyText );
                    lstToAddRecp.add(usr.email);
                    email.setToAddresses(lstToAddRecp);
                    
                    email.setTargetObjectId(usr.id);
                    email.setSaveAsActivity(false);
                    emails.add(email);    
                    lstToAddRecp.clear();
                }
            }
            
            
            if(emails != null){                    
                Messaging.SendEmailResult[] results = Messaging.sendEmail(emails);
                
            }
            
        }
        
        
    }
    
    global void finish(Database.BatchableContext BC)
      {

      }
}

Thnaks in Advance..
Hello!

In our org, we associate customer service cases to leads. I wrote a trigger to update a case associated with a lead with contact information when a lead is converted. However, I am having trouble with the test class. Any help is greatly appreciated. Below is the code. 

Trigger: 

trigger UpdateCaseWhenLeadConverted on Lead (after update) {
    if(Trigger.isAfter && Trigger.isUpdate)
    {
       List<Case> lstCase = new List<Case>();
        Set<Id> convertedLeads = new Set<Id>();
        id convertcontact;
        for(Lead objLead : Trigger.new)
        {
            if(objLead.isConverted)
                convertedLeads.add(objLead.Id);
                convertcontact = objLead.ConvertedContactId;
        }
        for(Case objCase : [SELECT Lead__c FROM Case WHERE Lead__c IN : convertedLeads])    
        {
            objCase.Lead__c = null;
            objCase.ContactId = convertcontact;
            lstCase.add(objCase);
        }
        update lstCase;
    }
}

Test Class:
@isTest
public class UpdateCaseWhenLeadConvertedTest {

    private static testMethod void LeadConvertedTest(){
        //create a Lead
        Lead lead=new Lead(LastName='Test',FirstName='Tester',Status='Known');
        insert lead;
        lead= [SELECT Id, Status FROM Lead Where Id = :lead.Id];
        // create a Case
        Id RecordTypeIdCase = Schema.SObjectType.Case.getRecordTypeInfosByName().get('Customer_Service_Record_Type').getRecordTypeId();
        Case cscase=new Case(RecordTypeId= RecordTypeIdCase, Lead__c = lead.Id);
        //update Lead
        Database.LeadConvert convertlead = new database.LeadConvert();
        convertlead.setLeadId(lead.Id);
        LeadStatus convertStatus = [SELECT Id, MasterLabel FROM LeadStatus WHERE IsConverted=true];
        convertlead.setConvertedStatus(convertStatus.MasterLabel);
        Database.LeadConvertResult lcr = Database.convertLead(convertlead);
        System.assert(lcr.isSuccess());
        //test if case is updated
        lead= [SELECT ConvertedContactId, Id FROM Lead Where Id = :lead.Id];
        cscase= [SELECT ContactId FROM Case WHERE Lead__c = :lead.Id];
        System.assertEquals('lead.ConvertedContactId','cscase.ContactId' );
    }
}
 
I'm working on a test for my batch process.  The batch works fine, however, I'm getting an error message in my test class.  Can anyone help?

Here is the batch I'm executing:
 
/**
This batch process will be triggered when a Campaign is deactivated and will stamp the Campaign with the dateTime value.
This batch will kick off two processes that also update Leads and CampaignMembers with the appropriate values.

*/

global class batchDeactivateCampaignCM implements Database.Batchable<sObject>,Database.Stateful{  
   
  
   global final DateTime nowStamp;
   //global final Integer nowStamp;
   global final Integer currentNowDateTime;  
   global List<Campaign> recordsToUpdate;
   
   
   global batchDeactivateCampaignCM(Integer nowDateTime)  
   {  
     currentNowDateTime = nowDateTime;  
     nowStamp = datetime.now();  
     recordsToUpdate = new List<Campaign>();  
   }  
   global Database.QueryLocator start(Database.BatchableContext BC)  
   {  
    return Database.getQueryLocator('Select id, Name, IsActive, Deactivate_Date__c from Campaign WHERE IsActive = FALSE AND Deactivate_Date__c = NULL');
    //Patrick, add this Where clause back in WHERE IsActive = FALSE AND Deactivate_Date__c = NULL
   }  
   global void execute(Database.BatchableContext BC, List<Campaign> scope)  
   {  
    for(Campaign c: scope)  
    {  if(c.IsActive == False && c.Deactivate_Date__c ==NULL){
     c.Deactivate_Date__c = nowStamp;  
    }
    }
    recordsToUpdate.addAll(scope);   
    update scope;  
   }  
    global void finish(Database.BatchableContext BC)
    {
	// Get the ID of the AsyncApexJob representing this batch job
	// from Database.BatchableContext.
	// Query the AsyncApexJob object to retrieve the current job's information.
	AsyncApexJob a = [SELECT Id, 
							Status, 
							NumberOfErrors, 
							JobItemsProcessed,
							TotalJobItems, 
							CreatedBy.Email
							FROM AsyncApexJob 
							WHERE Id = :BC.getJobId()];
	// Send an email to the Apex job's submitter notifying of job completion.
	Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
	String[] toAddresses = new String[] {a.CreatedBy.Email};
	mail.setToAddresses(toAddresses);
	mail.setSubject('Batch Process to Deactivate Campaigns ' + a.Status);
	mail.setPlainTextBody
	('The batch Apex job batchDeactivateCampaignCM processed ' + a.TotalJobItems +
	' batches with '+ a.NumberOfErrors + ' failures.');
	Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
	
System.debug('DateTimeStamped : '+ nowStamp);
System.ScheduleBatch(new batchDeactivateCampaignMembers(recordsToUpdate),'Batch to Update CampaignMembers :'+String.valueOf(Datetime.now()),1,50);  
System.ScheduleBatch(new batchDeactivateLeads(recordsToUpdate),'Batch to Update Leads :'+String.valueOf(Datetime.now()),2,50);   
	
	}
}

My test class is below. 

I'm getting an error on line 18, col 1 stating ( campList.add((Campaign)QIT.next()); ).  The error reads: "System.NoSuchElementException: Iterator has no more elements
Class.Database.QueryLocatorIterator.next: line 52, column 1
Class.batchDeactivateCMLeadTest.testBatch: line 18, column 1"
 
@IsTest  
 class batchDeactivateCMLeadTest  
 {  
 static testMethod void testBatch()  
 {  
  Campaign c = new Campaign(Name='Test Batch Campaign');  
  insert c;  
  Lead l = new Lead(firstname ='Testbatchfirst', lastname = 'Testbatchlast', company = 'Testbatchcompany', National_Provider_Number_NPN__c = '12354868541');  
  insert l;
  CampaignMember cm = new CampaignMember(CampaignId = c.id, LeadId = l.id);
  insert cm;
  Database.BatchableContext BC;  
  batchDeactivateCampaignCM bdc = new batchDeactivateCampaignCM(50);  
  bdc.start(BC);  
  Database.QueryLocator QL = bdc.Start(BC);  
  List<Campaign> campList = new List<Campaign>();  
  Database.QueryLocatorIterator QIT = QL.iterator();  
  campList.add((Campaign)QIT.next());  
  bdc.execute(BC,campList);  
  bdc.finish(BC);  
//   System.assertEquals([Select 
//                         id,
//                         Name
//                         from Campaign
//                         where Name = 'Test Batch Campaign']);  
  Database.BatchableContext BC_new;  
  batchDeactivateCampaignMembers bdcm = new batchDeactivateCampaignMembers([Select Id from Campaign]);  
  bdcm.start(BC_new);  
  Database.QueryLocator QL_new = bdcm.Start(BC_new);  
  List<CampaignMember> campaignMem = new List<CampaignMember>();  
  Database.QueryLocatorIterator QIT_new = QL_new.iterator();  
  campaignMem.add((CampaignMember)QIT_new.next());  
  bdcm.execute(BC_new,campaignMem);  
  bdcm.finish(BC_new);  

  Database.BatchableContext BC_new2;  
  batchDeactivateLeads bdl = new batchDeactivateLeads([Select Id from Campaign]);  
  bdl.start(BC_new2);  
  Database.QueryLocator QL_new2 = bdl.Start(BC_new);  
  List<Lead> campaignLead = new List<Lead>();  
  Database.QueryLocatorIterator QIT_new2 = QL_new2.iterator();  
  campaignLead.add((Lead)QIT_new.next());  
  bdl.execute(BC_new,campaignLead);  
  bdl.finish(BC_new);

 }  
 }

 
Trigger is as below:
trigger CMbeforeUpdate on CM__c (before Update) {
    List<CM__c> listCMUpdate = new List<CM__c>();
    for(CM__c cm : trigger.new) {
        if(cm.CM_Reason__c != trigger.oldMap.get(cm.id).CM__c 
            || cm.Location__c != trigger.oldMap.get(cm.id).Location__c
            
            || cm.Credit_LOB__c != trigger.oldMap.get(cm.id).Credit_LOB__c) {
            listCMUpdate.add(cm);
        }
    }
    if( listCMUpdate.size() > 0)
    { 
        CM_Handler.updateReasonCategoryCode(listCMUpdate);
        CM_Handler.CMapproverdetails(listCMUpdate);
    }    
}
The test class is:
@isTest
public class CMbeforeUpdatetest {
static testMethod void testCheck() {
   CM__c cm= new CM__c();
    cm.name = 'test';
    cm.CM_Reason__c = 'test';
    cm.Location__c = 'test';
 
  
    insert cm; 
    
    cm.Location__c = 'test123';
    
    update cm;
   
  }
}
the coverage is 70%. Need to cover " listCMUpdate.add(cm);" part, How to do that?
User-added image

I`m create the "cases" report.

User-added image

after saving and validating the error happens

User-added image
User-added image
Hi all

I have a batch class that I am gettin​g very litte test coverage for, can someone please assist. Lines 9 to 18 are not being covered.
global class ragStatusUpdate implements Database.Batchable<sObject>{

   global Database.QueryLocator start(Database.BatchableContext BC)

  {   string query = 'select id, Update_Rag_Status_Time__c from Shipment_Order__c  where Shipping_Status__c != \'POD Received\' AND Shipping_Status__c != \'On Hold\'AND Shipping_Status__c != \'Cancelled\'AND Shipping_Status__c != \'Shipment Pending\' AND Shipping_Status__c != \'Cancelled - With fees/costs\' AND Shipping_Status__c != \'Cancelled\'AND Shipping_Status__c != \'Cancelled - No fees/costs\' AND Shipping_Status__c != \'Customs Clearance Docs Received\' ';
      return Database.getQueryLocator(query);
   }

   global void execute(Database.BatchableContext BC, List<Shipment_Order__c>scope )
   {
list<Shipment_Order__c> SO = new list<Shipment_Order__c>();
        for(Shipment_Order__c s : scope)
           {
            s.Update_Rag_Status_Time__c  = TRUE;
            
             SO.add(s);
            }      
          update SO;
     }

   global void finish(Database.BatchableContext BC){

   }

}
 
@isTest
private class RagStatusTest {


static testMethod void testMethod1() {
    
        
        Account testClient = new account(Name='TestingClient',Client_Status__c = 'Prospect',Estimated_Vat__c = 123,CSE_IOR__c='0050Y000001LTZO');

        insert testClient;

        Contact testcontact = new Contact(LastName='Maseli',AccountId=testClient.Id);

        insert testcontact;
        
        country_price_approval__c cpa = new country_price_approval__c( name ='Serbia', Billing_term__c = 'DAP/CIF - IOR pays',  Airwaybill_Instructions__c = 'User IOR Address');
        insert cpa;
        
        IOR_Price_List__c testIOR = new IOR_Price_List__c();

        testIOR.Client_Name__c = testClient.Id;
        testIOR.Name = 'Serbia';
        testIOR.IOR_Fee__c = 1;
        
        insert testIOR;

        Shipment_Order__c shipmentOrder = new Shipment_Order__c();
        shipmentOrder.Account__c = testClient.Id;
        shipmentOrder.IOR_Price_List__c = testIOR.Id;
        shipmentOrder.Client_Contact_for_this_Shipment__c = testcontact.Id;
        shipmentOrder.Shipment_Value_USD__c = 123;
        shipmentOrder.Who_arranges_International_courier__c ='Client'; 
        shipmentOrder.Tax_Treatment__c ='DAP/CIF - IOR pays';
        shipmentOrder.Ship_to_Country__c = cpa.Id;
        shipmentOrder.Update_Rag_Status_Time__c = TRUE;
        
        insert shipmentOrder;

        
        
        Test.startTest();

        ragStatusUpdate batch = new ragStatusUpdate(); 
        database.executebatch(batch);
       
          
          

          Test.stopTest();
      }

    }

 
global class mailsend implements Database.Batchable <sobject>, Database.Stateful{

   // global List<string> mailx;
    public id mailid;
    public string mailx;
    public string dumname;
    public string urlcode;
    public List<Contact> Slist;
    public string messageBody;    
    public string queryString = '';
    public set<Id> setIds = new set<Id>();
    
    public mailsend(){}
    
   public mailsend(id DummyconId, string dummymail, string dummyname,   List<Contact>SelectedDc ) {   
       mailid = DummyconId;
       mailx  = dummymail;
       dumname = dummyname;
       this.Slist  = SelectedDc ;
       EmailTemplate templateId = [Select id from EmailTemplate where name = 'Sales: New Customer Email'];   
   }

    global Database.QueryLocator start(Database.Batchablecontext Bc){    
        queryString += ' Where Id IN: setIds ';  
        return Database.getQueryLocator(queryString);
    }

    global void execute(Database.Batchablecontext Bc, List<Dummy_Contact__c> Scope){
            
        Map<id, String> mMap = new Map<id, String>();        
      List<Messaging.SingleEmailMessage> mails = new List<Messaging.SingleEmailMessage>();
       For(Dummy_Contact__c dc: Scope){               
         ContactUpdateURL__c mc = ContactUpdateURL__c.getall().values();
         urlcode = mc.URLforContactUpdate__c;       
         String body = '' ;
          //Creating tabular format for the case details
          body = '<html><body>Dear '+dc.name+',<br><br> '+  + 
                                            
                                           'I' + 'm currently updating my contact database and want to make sure I have your current data right.' + +
                                                    
                                           'Could you have a quick look at below info? If you would like to change or update certain information, just click the ' + 'Update Now' + ' link on the bottom of the email and save your changes when done.<br> <br>' + +
                                           
                                            'Last Name:' +dc.name+  '<br><br>' + +
                                            
                                            'Email:' + dc.email__c+ '<br><br>' + +
                                             
                                                                                       
                                            'Title:' +dc.Title__c + '<br><br>'+ +
                                            
                                            'Phone:' +dc.phone__c+ '<br><br>' + +
                                            
                                            'Mobile:' +dc.Mobile_Phone__c+ '<br><br>' + +
                                            
                                            'Fax:' +dc.fax__c+ '<br>' + +
                                            
                                            'Street:' +dc.Mailing_Street__c+ '<br><br>' + +
                                            
                                            'Postalcode:' +dc.Mailing_Zip_Postal_Code__c+ '<br><br>'+ +
                                            
                                            'City:' +dc.Mailing_City__c+ '<br><br>' + +
                                            
                                            'State/Province:' +dc.Mailing_State_Province__c+ '<br><br>' + +
                                            
                                            'Country:' +dc.Mailing_Country__c+ '<br><br>' + +
                                                                                       
                                                                                            
                                            '<a href="'+urlcode+dc.id+'">Update Now</a>' + '<br><br><br>' + +
                                            
                                             'Many thanks in advance, ' +'<br>' + +

                                            
                                           '' + UserInfo.getlastname() +' </html></body>';
        
          Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage() ;
          String[] toAddresses = new String[] {dc.Email__c} ;
          mail.setToAddresses(toAddresses) ;
          mail.setSubject('Touch Contact');
          mail.setHtmlBody(body);
          mails.add(mail);          
        }
        Messaging.sendEmail(mails);
    }
    
    global void finish(Database.Batchablecontext Bc){}
}

 
Hello,
I am very new to programming and am learning to code with apex.
If you have experience in coding with apex, you will observe that the following code breaches many good practices' rules but, for now, I do not care (this is not about good practices, this question is about the error); I am just trying to understand WHY am I getting this error (Variable does not exit: Id)
I think it might have something to do with the "scope" of the code where this variable is being referenced but, I still need understand and to learn how to avoid these kind of issue in the future.

Could you possibly explain in plain English (for a beginner), why is this error being produced and how to avoid it?

Thank you very much. Here is the code:
trigger OwnerManager on Opportunity (after insert) {
    for(Opportunity opp : Trigger.new){
        //Get opp owner manager info
        Opportunity oppWithManagerInfo = [SELECT Id,
                                          Owner.ManagerId
                                          FROM Opportunity
                                          WHERE Id = :opp.Id];
        //Get opp owner direct dependents
        List<user> directDependents = [SELECT Id
                                       FROM user
                                       WHERE ManagerId = :opp.OwnerId
                                       LIMIT 1];
        //Create Opportunity Team Role
        if (oppWithManagerInfo.Owner.ManagerId != null) {
            OpportunityTeamMember otm = new OpportunityTeamMember();
            otm.UserId                = oppWithManagerInfo.Owner.ManagerId;
            otm.OpportunityId         = opp.Id;
            otm.TeamMemberRole        = 'Sales Manager';
            insert otm;
            //Create another Opportunity Team Role with directDependent
            if (directDependents.size()>0){
                OpportunityTeamMember otm2 = new OpportunityTeamMember();
                otm2.UserId                = directDependents.Id; // HERE is the error
                otm.OpportunityId          = opp.Id;
                otm.TeamMemberRole         = 'Sales Rep.';
                insert otm2;
            }
        }
    }
}

 
ApexClassとの交渉の活動履歴を取得し、Visualforceページに以下のように表示しようとしています。ここではテストクラスを作成しようとしていますが、わからないのでApexの初心者は理解しづらいです。私はあなたに助言したいと思います。ご検討をお願いいたします。


パブリッククラスOppIkouTodo {

    publicリスト<ActivityHistory> Act_records {get; };
    
    OppIkouTodo(ApexPages.StandardController stdController){
        Opportunity } =(Opportunity)stdController.getRecord();
        Id aid = opp.id;
        機会レコード=
            [SELECT id、name、
                (SELECT id
                            、Subject
                            、Description)
                            、ActivityDate
                          
                FROM ActivityHistories where checkbox__c = true)
             FROM Opportunity WHERE id =:aid];
        Act_records = record.ActivityHistories;
    }
  }
How would I write the test for the below trigger?

trigger updtrichtextfld on Selected_Service__c (before insert) {
Set<Id> serviceIds = new set<Id>();
Map<Id, string> serviceMap = new Map<Id, string>();
for(Selected_Service__c ss : Trigger.new)
{
    serviceIds.add(ss.Service__c); //to fetch related Id
}
//Description field needs to be queried else will result in null
for(Service__c ser : [select id, Deliverables__c from Service__c where id in: serviceIds])
{
    serviceMap.put(ser.id, ser.Deliverables__c);
}
for(Selected_Service__c u : trigger.new)
{
    //Selected_Service__c.Custom_Description__c=Service__c.Deliverables__c; This is wrong
    u.Custom_Description__c = serviceMap.get(u.Service__c);
}
}

I have been able to write the following so far but it is giving me the error "Illegal assignment from List to Selected_Service__c"

@isTest

public class updtrichtextfldtest
{
    static testMethod void testUnit()
    {
     Selected_Service__c ss = new Selected_Service__c();
        ss = [
            SELECT Id, Deliverables__c
            From Service__c
            Where Id = :ss.Id
        ];
    }
}
I'm having trouble verifying a step in the Customize an Org to Support a New Business Unit. (https://trailhead.salesforce.com/projects/customize-an-org-to-support-a-new-business-unit/steps/manage-user-access) I've reviewed the setup a handful of times and even created a new playground and still receiving same error message:
Challenge Not yet complete... here's what's wrong: 
Could not find a user name 'Fumiko Suzuki' with the configuration specified in the project. Please check the step again.
Fumiko Susuki User Setup
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 ?
 
The hands on challenge to install Dream house app is not working. It does not find my trailhead playground and yes, I am logged in.  The app will install on my SF Org! 
I need to create a test class, but I'm not sure how to since my Apex Class is essentially a query with a sort functionality and not an action to a field (like the examples I've seen on Trailhead). Any help would be much appreciated. 
 
public class ExhibitAController {
    public Customer_Pricing__c cust{set;get;}
    public List<Customers_Product_Code__c> customerproducts{get;set;}
    public Set<Customers_Product_Code__c> customerproducts2{get;set;}
        
    public ExhibitAController(ApexPages.StandardController stdController){
    
        this.cust = (Customer_Pricing__c)stdController.getRecord();
		cust = [select Id, Account_Name_Text__c, Project_Scope__c,Eff_Start_Date__c,Min_Invoice__c,Assessment__c from Customer_Pricing__c where Id =: cust.Id];
		customerproducts = new List<Customers_Product_Code__c>();
		customerproducts2 = new Set<Customers_Product_Code__c>();
        customerproducts  = [SELECT Description_for_Invoice__c,Caveats__c,Category__c,Container_Size__c,UM__c,Price__c
                             FROM Customers_Product_Code__c
                             where Customer_Pricing__c =:cust.Id
                             ORDER BY Category__c, Description_for_Invoice__c, Container_Size__c]; 
        customerproducts2.addAll(customerproducts);
        for(Integer i = 0; i < customerproducts.size(); i++)
            for(Integer j = i; j < customerproducts.size(); j++)
            {
                if(customerproducts[i].Id != customerproducts[j].Id)
                {
                    if(customerproducts[i].Description_for_Invoice__c == customerproducts[j].Description_for_Invoice__c && customerproducts[i].Container_Size__c == customerproducts[j].Container_Size__c && customerproducts[i].Caveats__c == customerproducts[j].Caveats__c)
                    {
                        customerproducts2.remove(customerproducts[j]);
                    }
                }
            }
        customerproducts.clear();
        customerproducts.addAll(customerproducts2);
    }
}

 
Hi Gurus, 

I have finished writting my test class for my entension page and its curently on 92% coverage - as theres one line that is not covered.  ( line 25 -  return detailPage; )

This is my code extension apex class code: 

public with sharing class extencntrl{
    
    private ApexPages.StandardController sc;
    public extencntrl(ApexPages.StandardController sc) {
        this.sc = sc;
    }
    
    public boolean displayPopup {get; set;}     
    
    public void closePopup() {  
        displayPopup = false;
        
    }     
    public void showPopup() {        
        displayPopup = true;
        
    }
    
public PageReference Save() {
          PageReference detailPage = sc.Save();
        if (detailPage != null) {
            PageReference editPage = new PageReference(Label.websiteurl); 
            return editPage ;
        } else {
            return detailPage;
        }
    }
}




This is my test class code:


@isTest
public class extencntrlTest{
    static testmethod void validateStandardController()
    {
        Account acc = new Account();
        acc.name ='Test';
        insert acc;
        
        ApexPages.StandardController sc = new ApexPages.StandardController(acc);
        extencntrl ext = new extencntrl(sc);
        ext.closePopup();
        ext.showPopup();
        ext.Save();
    }
}



The only line that my test class does not cover is line 25 ( return detailPage;) on my extension. 

Does anyone know what I can add to my code to cover the last line aswell? If so, please let me know!

Thanks very much!
Hi, I'm getting an error on this challenge: https://trailhead.salesforce.com/modules/workflow_migration/units/workflow_migration_actions

It thinks my dev org is missing a field, but it's clearly there in the Opportunity object. Here's a screenshot - has anyone else experienced this?
User-added image
public with sharing class AccountsController 
{
	@AuraEnabled
    public static List<Account> getAccounts()
    {
        return[SELECT Id, Name, Industry , Type, NumberofEmployees, TickerSymbol, Phone FROM Account];
    }
}

 
Hi Team,


Can any one please tell me the challenges facing in Salesforce Administration?


Thanks & Regards
Lakshmi
Hi Team,

What are the challenges we are facimg in deployment using ANT migration tool?


Thanks & Regards
Lakshmi
Hi Dev Guru's,

I've saved couple of pdf documents in the SF Document Object >> Shared Documents folder and would like to attach to sendEmail method. The below class code working but need help with Test Class code. 

<And please advise if below code is not efficient>

        List<Messaging.Emailfileattachment> xxx  = new List<Messaging.Emailfileattachment>();
        List<Messaging.Emailfileattachment> yyy = new List<Messaging.Emailfileattachment>();

                  for ( Document doc : [SELECT Name, Body, BodyLength, ContentType FROM Document
                                      WHERE (Name =: AAA OR Name =: BBB ) LIMIT 2] ) {
                    if(doc.Name == 'AAA' ){                        
                            Messaging.EmailFileAttachment efa = new Messaging.EmailFileAttachment();
                                efa.setFileName(doc.Name);
                                efa.setBody(doc.Body);
                                efa.setContentType(doc.ContentType);
                            xxx.add(efa);
                    } else if(doc.Name == 'BBB' ){                        
                            Messaging.EmailFileAttachment efa = new Messaging.EmailFileAttachment();
                                efa.setFileName(doc.Name);
                                efa.setBody(doc.Body);
                                efa.setContentType(doc.ContentType);
                            yyy.add(efa);
                    }
                }
                
Thank You
JR
public class RelatedCase {


public class Relatedcaseinner {

public string fullname {get;set;}
public string city {get;set;}


}

public static List <Relatedcaseinner> getmethod1(Id id)
{
     String AccountName=[select name from Account where id=:id].name;
     
     List<Relatedcaseinner> relinner= new List<Relatedcaseinner>();
     
     List <Contact> con = [select firstname,lastname from contact where lastname=:AccountName ];
     
     for (Contact c : con)
     {
     
         Relatedcaseinner csewrap= new Relatedcaseinner ();
         
         csewrap.fullname=c.firstname;
         csewrap.city=c.lastname;
         
        relinner.add(csewrap);
     
     }

return relinner;
}
 
Hi All,

I completed my extension page so now I need to write a test class.

I have been researching into how to write a test class but all the example i have seen are very different to mine therefore I dont still undertand how to apply the content to my test class.

This is my extension page code:

public with sharing class extencntrl{
    
    private ApexPages.StandardController sc;
    public extencntrl(ApexPages.StandardController sc) {
        this.sc = sc;
    }
    
    public boolean displayPopup {get; set;}     
    
    public void closePopup() {  
        displayPopup = false;
        
    }     
    public void showPopup() {        
        displayPopup = true;
        
    }
    
public PageReference Save() {
          PageReference detailPage = sc.Save();
        if (detailPage != null) {
            PageReference editPage = new PageReference(Label.websiteurl); 
            return editPage ;
        } else {
            return detailPage;
        }
    }
}


Please if someone knows how I could possible start developing the test class, please let me know!

Thanks,
Ola
Why I am getting this error--
"Executing the 'insertNewAccount' method failed. Either the method does not exist, is not static, or does not insert the proper account."
my code--

public class AccountHandler {

     public static Account insertNewAccount(String name){
        
          Account a = new Account();
          a.Name = 'name';
        
        try{
            insert a;
        }
        catch(Exception e){
            return null;
        }    
       return a;
    }
}
Apex Class:

global with sharing class InstallationServiceReportController {

   public Injection_Moulding_Machine_Installation__c ISR;
   public String imageURL{get;set;}
   
public InstallationServiceReportController(ApexPages.StandardController controller) {
ISR = (Injection_Moulding_Machine_Installation__c)controller.getRecord(); 
    
imageURL='/servlet/servlet.FileDownload?file=';
    
List<Attachment> AttachmentList=[select Id, Name, LastModifiedDate FROM Attachment WHERE Name =:ISR.Id ORDER BY LastModifiedDate DESC NULLS LAST];
       
if( AttachmentList != null &&AttachmentList.size()>0)

  {

   imageURL=imageURL+AttachmentList[0].id;
   }
}

public pageReference clear(){
    pageReference page = new PageReference('/'+ISR.id);
  page.setRedirect(false);
   return page;

  
public PageReference savePDF() {
    PageReference pageRef = new PageReference('/apex/InstallationServiceReport');
     List<Attachment> AttachmentList=[select Id, Name, LastModifiedDate FROM Attachment WHERE Name =:ISR.Id];
     if( AttachmentList.size() == 0){
      ApexPages.AddMessage(new ApexPages.Message(ApexPages.Severity.ERROR,'First Capture Customer Signature and then try to Generate Report'));
      
          Return pageRef; 
        }   
     else{
      PageReference pdf = new PageReference('/apex/InstallationServiceReport');
      pdf.getParameters().put('id',ISR.Id);
Blob pdfBlob = pdf.getContentasPDF();
       
    // add parent id to the parameters for standardcontroller
    // create the new attachment
    Contentversion CV = new Contentversion();
    // the contents of the attachment from the pdf
    Blob body;

    try {
        // returns the output of the page as a PDF
        body = pdf.getContentasPDF();

    } catch (VisualforceException e) {
        body = Blob.valueOf('SomeWebServiceCalloutThatReturnsBlob()');
    }

    CV.VersionData = body;
    CV.Title = ISR.Shop_Order_Number__c+'-Machine Installation Report';
    
    // attach the pdf to the WorkOrder
    CV.FirstPublishLocationId = ISR.Id;
    CV = new ContentVersion (FirstPublishLocationId = ISR.Id,Title = CV.Title,PathOnClient=CV.Title+'.pdf', VersionData = pdf.getContentasPDF());
      insert CV;

    // send the user to the account to view results
    return new PageReference('/'+ISR.Id);
    }
    }
 
public pageReference cancel(){
    pageReference page = new PageReference('/'+ISR.id);
    page.setRedirect(true);
    return page;
}
  }
Hi,
I'm going through "https://trailhead.salesforce.com/trails/force_com_dev_beginner/modules/apex_database/units/apex_database_dml" module and while implementing the challenge, I am getting following error:
Challenge Not yet complete... here's what's wrong: 
There was an unexpected error in your org which is preventing this assessment check from completing: System.DmlException: Delete failed. First exception on row 0 with id 0017F00000LQrpmQAD; first error: DELETE_FAILED, Your attempt to delete My Test Account could not be completed because it is associated with the following cases.: 00001036 : []

There is no account with name as "My Test Account" & no case with number  as "00001036" visible in my org. Also, I am creating an account record why is it reflecting a message related to deleting of account? Please suggest.

Regards
Scenario: When contact last name does not equal to null, send an email to that contact

public class sendemail_contacts 
{
list<contact>lstcont=new list<contact>();    
for(lstcont=[select id,name from contact where firstname!=''])
{
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();  
string body = 'Hi ';
String[] toAddresses = new String[] {'example@gmail.com'}; 
mail.setToAddresses(toAddresses);
mail.setSubject('Test Subject'); 
}
}

I am new to Salesforce development. I dont know why this error has been occured.
Can you please anyone explain and suggest the answer for this below code?
 
  • December 04, 2017
  • Like
  • 0
Hi All,
I am net to Map and need ur help here.

Can anyone help me how to fill value in Map in below example. Can you please help me with the Code?

Map<id,List<Contacts>> CustMap = new Map<Id,List<Contacts>>;

for(Account ac:[SELECT id,name,(SELECT id FROM Contacts) FROM Account])
{
How to fill Map here where Id would be Account Id and Values would be list of Contacts.?
}

Regards,
Varun
 
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?