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


  • Chatter
    Feed
  • 1163
    Best Answers
  • 1
    Likes Received
  • 32
    Likes Given
  • 3
    Questions
  • 5598
    Replies
PageReference searchPOAgain
Hi Friends, 

Help me with test class, 
Below is my Apex Code.

public class LenderLoansDetailsSearchController {
    public String LoanID {get;set;}
    public String Email {get;set;}
    public String PAN {get;set;}
    public String Mobile {get;set;}
    public List<Loan__c> lstofResult {get;set;}
    public String LenderID{get;set;}
  
    public LenderLoansDetailsSearchController(){
        LoanID = '';
        PAN = '';
        Email = '';
        Mobile = '';
        lstofResult = new List<Loan__c>();
        LenderID= [select id,Phone,Lender_ID__c, name from User WHERE ID =:userinfo.getUserId()].Lender_ID__c;     
    }
    
    public void SearchAcc(){
        lstofResult = new List<Loan__c>();
        lstofResult = [SELECT Id,Name,Mobile__c,Customer_Name__c,Customer_Journey_Status__c,EMI_Amount__c,Loan_Amount__c,Customer_Email__c,Current_Assigned_Lender__c,Pan_Card__c FROM Loan__c WHERE Pan_Card__c like :PAN+'%'  AND Current_Assigned_Lender__c =:LenderID LIMIT 999];
           
    if (lstofResult.size() == 0){
       ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Warning,'No Loans Found Please try With Correct values'));
       }
     
    }
    
    public void SearchAcc1(){
        lstofResult = new List<Loan__c>();
        lstofResult = [SELECT Id,Name,Mobile__c,Customer_Name__c,Customer_Journey_Status__c,EMI_Amount__c,Loan_Amount__c,Customer_Email__c,Current_Assigned_Lender__c,Pan_Card__c FROM Loan__c WHERE Customer_Email__c like :Email+'%' AND Current_Assigned_Lender__c =:LenderID LIMIT 999];
           
    if (lstofResult.size() == 0){
       ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Warning,'No Loans Found Please try With Correct values'));
       }
     
    }
    public void SearchAcc2(){
        lstofResult = new List<Loan__c>();
        lstofResult = [SELECT Id,Name,Mobile__c,Customer_Name__c,Customer_Journey_Status__c,EMI_Amount__c,Loan_Amount__c,Customer_Email__c,Current_Assigned_Lender__c,Pan_Card__c FROM Loan__c WHERE Name like :LoanID+'%' AND Current_Assigned_Lender__c =:LenderID LIMIT 999];
           
    if (lstofResult.size() == 0){
       ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Warning,'No Loans Found Please try With Correct values'));
       }
     
    }
    public void SearchAcc3(){
        lstofResult = new List<Loan__c>();
        lstofResult = [SELECT Id,Name,Mobile__c,Customer_Name__c,Customer_Journey_Status__c,EMI_Amount__c,Loan_Amount__c,Customer_Email__c,Current_Assigned_Lender__c,Pan_Card__c FROM Loan__c WHERE Mobile__c like :Mobile+'%' AND Current_Assigned_Lender__c =:LenderID LIMIT 999];
           
    if (lstofResult.size() == 0){
       ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Warning,'No Loans Found Please try With Correct values'));
       }
     
    }
}
  • January 02, 2018
  • Like
  • 0
trigger UpdateStage on Account (after insert, after update, before insert, before Update) {   // Performs Custom actions after Record gets saved.
   
    List<Id> accountId = new List<Id>(); // get the list of all Account's ID to be Updated.
    
    for(Account acc : Trigger.new)
    {
        if(acc.All_Opportunities_Won__c==True)   // Checks if the Condition is True. 
            accountId.add(acc.Id);
    }
    
    List<Opportunity> oppsToUpdate = new List<Opportunity>();
    
    for(Opportunity opp : [select id, StageName, Amount from Opportunity where AccountId in: accountId AND Amount != 0]) // used to get all records from above ID.
    {
        opp.StageName='Closed-Won';   //Update StageName in Opportunity
        oppsToUpdate.add(opp); 
    }
    
    update oppsToUpdate;   // Update all Opportunity in List.
}

 
Hello,
On accounts we have a field called Category, that field is a Picklist. I would like to create a tirgger to update child accounts Category field with the value from parent account Category field.
This is what I have so far:
 
trigger updateCategoryFromParent on Account (after insert, after update) {

    List<Account> accList = new List<Account>();

    for (Account ac : Trigger.new) {
        if(ac.ParentId != null){
            Account ap = new Account();
            account au = new Account(Id = ac.Id);
            ap.Id = ac.ParentId;
            au.Category__c = ap.Category__c;
            accList.add(au);
        }
    }
    update accList;
}

 
Hi All, my class and test class below is just cover for 60%, I found that is not cover on for loop. How can I modify test class to cover for loop?
Many Thanks.

customLookUpController:
public class customLookUpController {
    @AuraEnabled
    public static List < sObject > fetchLookUpValues(List<String> fieldstoShow, String searchKeyWord, String ObjectName, String whereCondition, String limitRecord) {
        system.debug('ObjectName-->' + ObjectName);
        String searchKey = searchKeyWord + '%';
		String moreFields = ','+String.Join(fieldstoShow,',');
            
        List < sObject > returnList = new List < sObject > ();
      
        // Create a Dynamic SOQL Query For Fetch Record List with some LIMIT   
        String sQuery =  'select id, Name'+moreFields+' from '+ObjectName + ' where Name LIKE: searchKey '+whereCondition +' order by createdDate DESC limit '+limitRecord;
        List < sObject > lstOfRecords = Database.query(sQuery);
        
        for (sObject obj: lstOfRecords) {
            returnList.add(obj);
        }
        return returnList;
    }
}

customLookUpTestController:
@isTest(SeeAllData=true)
private class customLookUpTestController {
	@isTest static void testCustomLookup(){
		List <String> fieldstoShow = new List <String>();
        fieldstoShow.add('Id');
        fieldstoShow.add('Name');
        
        List < sObject > returnList = customLookUpController.fetchLookUpValues(fieldstoShow, '', 'Account', '', '5');
        System.assert(returnList != null);
        
    }
}

User-added image
Hello, I have written an Apex Class Extension to override standard create contact for my visualforce page, and it works fine in the Sandbox environment.  I am having trouble deploying the class in my production environment - class code coverage is only at 63%.  I am not sure how to write a test to see where there is a code issue.  Here is my code:

public class ContactSaveExtension {

    ApexPages.StandardController controller;

    public ContactSaveExtension(ApexPages.StandardController controller) {
        this.controller = controller;
    }

    public PageReference saveAndRedirect() {
        controller.save();
        PageReference redirect = new PageReference('/apex/Thank_You');
        redirect.setRedirect(true);
        return redirect;
    }

}

Thank you for your help!
Stephanie
I'm new to Visualforce and I want to create a unit test to test my page but I'm getting an error. Help will be really apreciated! 

Thanks

Pablo
.....

Apex Class:
public with sharing class UnqulifiedLeads
{
    public ApexPages.StandardSetController setCon;

    public UnqulifiedLeads(ApexPages.StandardSetController Ld){
        this.setCon= Ld;
    }

    public String selectedValue { get; set; }
    public Boolean UseCustomReasons { get; set; }
    
    public List<SelectOption> getMyOptions(){
      List<SelectOption> options = new List<SelectOption>();      

      // Reading picklist values and labels
      Schema.DescribeFieldResult fieldResult = Lead.Unqualified_Reason__c.getDescribe();
      List<Schema.PicklistEntry> picklistEntries = fieldResult.getPicklistValues();
  
       // Adding apicklist values to the select list
       options.add(new SelectOption('N/A','N/A')); 
       options.add(new SelectOption('Custom','Custom for each Lead')); 
       for(Schema.PicklistEntry entry : picklistEntries){
           options.add(new SelectOption(entry.getValue(), entry.getLabel())); 
       }
     return options;
    }

    public PageReference bumpLeads(){       
        List<Lead> selectedLeads = (List<Lead>) setCon.getSelected();
        if(test.isrunningTest()){
            selectedLeads = [    
                                SELECT 
                                    Id, Status, Firstname, Lastname,Unqualified_Reason__c 
                                FROM 
                                    Lead 
                                ORDER BY 
                                    createddate DESC 
                                LIMIT 1
                            ];
            selectedValue = 'N/A';
        }

        // Update records       
        for(Lead selectedlead : selectedLeads)
        {
            selectedlead.Status = 'Unqualified';
            system.debug('selectedValue' + selectedValue);
            if(selectedValue == 'N/A' || selectedValue == '' )
                selectedlead.Unqualified_Reason__c = 'Budget';
            else
                if(selectedValue != 'Custom')
                    selectedlead.Unqualified_Reason__c = selectedValue;   
        }       

        updateLeads();
        
        return null;        
    }

    public PageReference updateLeads()
    {       
        // Call StandardSetController 'save' method to update
        return setCon.save();   
    }
}

................................................

Visualforce page

<apex:page standardController="Lead" extensions="UnqulifiedLeads" recordSetVar="leads" >
   <apex:form >
       <apex:pageBlock title="Bump Selected Leads">
                <apex:outputLabel>Set Unqualify Reason for Leads   &nbsp; </apex:outputLabel>
                <apex:selectList label="hola" value="{!selectedValue}" size="1" multiselect="false">
                    <apex:selectOptions value="{!MyOptions}"/>
                </apex:selectList>
          
            <apex:pageBlockButtons >
                <apex:commandButton action="{!bumpLeads}" value="Confirm" id="Confirm"/>
            </apex:pageBlockButtons><br/><br/>
            <apex:pageBlockTable value="{!selected}" var="lead">
                <apex:column value="{!lead.FirstName}"/>
                <apex:column value="{!lead.LastName}"/>
                <apex:column value="{!lead.status}"/> 
                <apex:column headerValue="Reason">
                    <apex:actionRegion >
                        <apex:outputField value="{!lead.Unqualified_Reason__c}">
                            <apex:inlineEditSupport event="ondblClick" showOnEdit="Confirm" />
                        </apex:outputField>
                    </apex:actionRegion>
                </apex:column>

            </apex:pageBlockTable> 
        </apex:pageBlock>
    </apex:form>    
</apex:page>

......
Unit Test

@isTest
public class UnqulifiedLeadsTest{

    public static testMethod void testUnqulifiedLeads() {
    
    //Create Test leads
    List<Lead> leadList= new List<Lead>();
    Lead leadTest1 = new Lead();
    leadTest1.FirstName = 'Fisrtname1';
    leadTest1.LastName = 'Lastname1';
    leadTest1.Lead_Source_custom_field__c= 'Unknown';
    leadTest1.Status= '1 - Open Lead';
    Lead leadTest2 = new Lead();
    leadTest2.FirstName = 'Fisrtname2';
    leadTest2.LastName = 'Lastname2';
    leadTest2.Lead_Source_custom_field__c= 'Unknown';
    leadTest2.Status= '1 - Open Lead';
    leadList.add(leadTest1);
    leadList.add(leadTest2);
    insert leadList;
    
     Test.startTest();
     // load the page       
    PageReference pageRef = Page.MassUnqulifyLeads;
    Test.setCurrentPageReference(pageRef);
    ApexPages.StandardController sc = new ApexPages.StandardController(leadTest1);    
    UnqulifiedLeads leadsTest = new UnqulifiedLeads(sc); 

    Test.stopTest();
    
    }
    
}

Error Message: Error: Compile Error: Constructor not defined: [UnqulifiedLeads].<Constructor>(ApexPages.StandardController) at line 28 column 33


 
Hello,
Help me to get 100% code coverage of this code,
 
public class Overview_Controller {
    
    public string baseurl = URL.getSalesforceBaseUrl().toExternalForm();
    public string create = '/one/one.app#/alohaRedirect/'; 
    public string Framework = '/one/one.app#/sObject/CGR__CG_Framework__c/list';

    
    public PageReference CreateFramework(){
        if(UserInfo.getUiTheme()== 'Theme4d')
        {
            string FrameworkPrefix = CGR__CG_Framework__c.sObjectType.getDescribe().getKeyPrefix();
            PageReference  p = new PageReference (baseurl+create+FrameworkPrefix+'/e' );
            p.setRedirect(true);
            return p;
        }
		
		else
        {
            string FPre = CGR__CG_Framework__c.sObjectType.getDescribe().getKeyPrefix();
            PageReference p1 = new PageReference ('/'+FPre+'/e' );
            p1.setRedirect(true);
            return p1;
        }
	}
}

I tried this test class, but it only covers else part. it does not cover if (condition) block. 
 
@isTest
public class Overview_Controller_Test {
    
    private static testMethod void testOverview()
    {
        Overview_Controller oc = new Overview_Controller ();
        
        oc.CreateFramework();
    	
	}
}

Help me to achieve 100% code coverage.

--
Thank-You!
Krutarth Soni
 
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);
    }
}

 
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;
    }
}
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;    
 }
}
Hi Team,


Write a batch class for to delete all contacts of accounts where Account field : active__c="yes" ?


Please give me the reply to above scenario....

Regards
Lakshmi
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 ?
 

We're trying to do a mass import of Contacts using the Data Import Wizard (to prevent duplicates), but in doing so we had many errors because  we hit governance limits due to an Apex Trigger. I have since deactivated the Apex Trigger in Sandbox by unchecking the "Is Active" checkbox and sent the deactivated Trigger via a change set to the Production Org, but when I try to deploy it in Production, I receive an error that one of the tests has failed (and therefore cannot deploy).

I'm looking for advice on the easiest/best way to deactivate

I've included screenshots of the Error Message that I get when trying to deploy below, as well as the original Apex Trigger code. I can send through actual code if needed.

test failure

apex trigger code
Hello guys, let's say I have the following code:
 
@RestResource(urlMapping='/Account/*')
global with sharing class MyRestResource {
  
  @HttpPost
    global static String doPost(String name,
        String phone, String website) {
        Account account = new Account();
        account.Name = name;
        account.phone = phone;
        account.website = website;
        insert account;
        return account.Id;
    }
}

I'm testing it through https://www.hurl.it/ and there is an authentication section with username and password. My question is how can I check if it is the right combination?

And what would happen if they send me the information through a webservice that's not like that website but just an endpoint to my website? 
public class UpdateUser {
    Public static void method1(List<case> caseList){
        set<id> parentcaseId = new set<Id>();
        for(case cs:caseList){
            if(cs.Defect__c != null){
                parentcaseId.add(cs.Defect__c);
            }
        }
        
        List<Case> caseslistold = [SELECT Id, OwnerId FROM Case WHERE Id in : parentcaseId];
        for(Id csIdtoUpdate:parentcaseId){
            for(Case cas:caseslistold){
                for(case cs:caseList){
                    cs.Product_Lead__c=cas.ownerId;
                }
            }
        }
    }
}
 
trigger updateUsertrig on Case (before insert, before Update) {
    if((trigger.isInsert && trigger.isBefore) || (trigger.isUpdate && trigger.isBefore))
UpdateUser.method1(trigger.new);
}

 
PageReference searchPOAgain
string example = 'one;two;three';
List<String> list = new List<String>();
for(String s : example.split(';'))
{
list.add(s);
}
Beginner with Apex and test classes. Only getting 60% coverage. Any suggestions? Here is the class:

public class SearchAccountCommunity {
    public string searchEmail {get; set;}
   
    public PageReference findAccount(){
        List<Account> accountId = [SELECT Id from Account WHERE PersonEmail =:searchEmail LIMIT 1];
        PageReference registerNew;
        if(!accountId.isEmpty()){
            string url = 'https://myOrg.force.com/Residential/AssetOverrideCommunity?Account_lkid='+ accountId[0].id;
            registerNew = new PageReference(url);
            registerNew.setRedirect(true);
            return registerNew;
        }
        return registerNew;
    }

}

Here is the test class:

@isTest
public class test_SearchAccountCommunity {
    static testmethod void vailidateFindAccount(){
        SearchAccountCommunity test = new SearchAccountCommunity();
        test.searchEmail = 'test.email@email.com';
        string resultUrl = 'https://myOrg.force.com/Residential/AssetOverrideCommunity?Account_lkid=001j0000014FpHVAA0&isdtp=p1';
        PageReference pageTest = test.findAccount();
        System.assertEquals(resultUrl, pageTest.getUrl());
    }
}
 
Hi,

I have a requirement to set the Pricebook on the Opportunity but want to be able to do it with one SOQL query if possible.

From the Opportunity I can get the Campaign.PFC_Product_Name__c Id which I then want to be able to use to query the Pricebook object to get the Id for that PFC_Proudct__c.

Opportunity o = [SELECT Id, Campaign.PFC_Product_Name__c FROM Opportunity WHERE Id = '0063B000006bxt6QAA'];
Pricebook2 pb = [SELECT Id, Name FROM Pricebook2 WHERE PFC_Product__c = :o.Campaign.PFC_Product_Name__c];

Any help would be appreciated.

Thanks,
Jonno
 
trigger beforeup on Account (before update) {
    for(Account acc:trigger.new){
    acc.name='123';
    }  
    update trigger.new;
}
I created a formula field to look at the Event Name and if its a particular name it takes the ticket type and count of tickets is multiple by the cost of the ticket based  on the type of ticket and cost. I am get the following error message, but can't tell whats wrong with the formula
I should mention the VALUE part of the formula works fine, but in adding the IF statement I am now getting and error. Any help solving this is greatly appreciated. 

Error: Syntax error. Missing ')'

Formula:

IF(Event_Specific_Name__c = 02/04/2018 CC "Meditation Training Practice Day"  + VALUE(TEXT(General_Admission_of_Tickets_Ordered__c)) * 90.00 
I am trying to implement best practices in my trigger. I want to avoid writing a query in the loop but not getting the logic for it. can anyone please help?
I have a CSRid text field on contact and a badge__c text field in Employee object. I want to autofill employee lookup field on contact from contact trigger based on the CSRid on contact. This is the logic I have written which is working fine but couldnot avoid writing a query in the FOR loop. Please help.
Thank you

 list<contact> lstConid = new list<contact>();
    if(trigger.isUpdate && trigger.isBefore){
        for(contact con : trigger.new){
            if(con.CSRid__c != null){  //
                lstConid.add(con);
            }
        }
        if(!lstConid.isempty()){
            for(contact con: lstConid){
                if(con.CSRid__c != null){
                Employee_Table__c emp = [select id, name from Employee_Table__c where badge__c =: con.CSRid__c limit 1];
                if(emp.id != null)
                    con.SurveyEmployees__c = emp.id;
                }
            }
               
        }
        
     // map<lstCSRid, Employee_Table__c> CsrEmpMap = new map<lstCSRid, Employee_Table__c>([select Name from Employee_Table__c where badge__c in :lstCSRid]);
    }
Hi, I have a controller and a VF page where the vf page takes in a csv file and pass it to the controller. The controller follows a particular logic to create user. I am encountering no error but the list named as 'colleaguelist' is not getting populated.

CONTROLLER:
public class importDataFromCSVController {
public Blob csvFileBody{get;set;}
public string csvAsString{get;set;}
public String[] csvFileLines{get;set;}
public List<User> userlist{get;set;}
public List<Colleague_c__c> colleaguelist;
public List<String> Collid{get;set;}

    public importDataFromCSVController(){
        csvFileLines = new String[]{};
        userlist = New List<User>();
        colleaguelist = New List<Colleague_c__c>();
        collid = New List<String>();
    }
  
  public void importCSVFile(){
       
       try{
           csvAsString = csvFileBody.toString();
           csvFileLines = csvAsString.split('\n');
           System.debug('####csv' + csvFileLines);
           
           for(Integer i=1;i<csvFileLines.size();i++){
               String[] csvRecordData =csvFileLines[i].split(',');
               collid.add(csvRecordData[0]);
               
           }
           System.debug('####collid' + collid);
           colleaguelist = [Select Id, Name, IsActive__c, CompanyName__c, Email__c, EmployeeNumber__c from Colleague_c__c where EmployeeNumber__c in:collid];
           System.debug('####colllist' + colleaguelist);   
           for(Integer i=1;i<csvFileLines.size();i++){
           system.debug('###for1 entered');
               string[] csvRecordData = csvFileLines[i].split(',');
            for(Colleague_c__c coll: colleaguelist){
            system.debug('###for2 entered');
            system.debug('###csvRecordData[0]' + csvRecordData[0]);
            system.debug('###coll.EmployeeNumber__c' + coll.EmployeeNumber__c);
            system.debug('###coll.IsActive__c' + coll.IsActive__c);
                    if(csvRecordData[0] == coll.EmployeeNumber__c && coll.IsActive__c == true){
                       system.debug('###if entered');
                       User use = new User() ;
                       use.LastName = coll.Name ;            
                       use.Email = coll.Email__c;
                       use.Username = coll.Email__c;
                       use.CommunityNickname = coll.Name;
                       use.ProfileId = '00e28000001D7DM';
                       use.UserRoleId = '00E28000001lvac';
                       use.EmployeeNumber__c = coll.EmployeeNumber__c;
                       userlist.add(use);  
           }
           }
           
        
           }
           system.debug('####userlist' + userlist);
           insert userlist;
           System.debug('####List inserted');
       }
        
        catch (Exception e)
        {
            ApexPages.Message errorMessage = new ApexPages.Message(ApexPages.severity.ERROR,'An error has occured while importin data Please make sure input csv file is correct');
            ApexPages.addMessage(errorMessage);
         
        }
  } 
  }

VF Page:
<apex:page controller="importDataFromCSVController">
<apex:form >
<apex:pagemessages />
<apex:pageBlock >
<apex:pageBlockSection columns="4">
<apex:inputFile value="{!csvFileBody}" filename="{!csvAsString}"/>
<apex:commandButton value="Import user" action="{!importCSVFile}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>

Kindly help. Many thanks in advance.
Hello ,

How can I change the below veiw?
Thank you!
User-added image
I am getting error  in test class as 
System.DmlException: Update failed. First exception on row 0 with id a1h17000003NcsjAAC; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Please select only one checkbox: []
Class.TestselectOneCheckbox.myUnitTest: line 18, column 1
Please help :



Trigger:
trigger selectOneCheckbox on Survey_Mcd__c (before update) {
for(Survey_Mcd__c sms : Trigger.New){
  if(Trigger.isUpdate){
  if((sms.Yes_No__c && sms.X5_Scale_Rating__c && sms.Comment__c)  || (sms.Yes_No__c && sms.X5_Scale_Rating__c)  
  || (sms.Yes_No__c && sms.Comment__c) || (sms.X5_Scale_Rating__c && sms.Comment__c)){
  sms.addError('Please select only one checkbox');
   }
  }
 }
}

Test class

@isTest
public class TestselectOneCheckbox {
    static testMethod  void myUnitTest() {
        system.test.startTest();
         
            Survey_Mcd__c sms= new Survey_Mcd__c();
                 sms.Yes_No__c=true;
            sms.X5_Scale_Rating__c=true;
            sms.Comment__c=true;
               insert sms;
        List <Survey_Mcd__c> sm= [select id,Comment__c,X5_Scale_Rating__c,Yes_No__c 
                                  from Survey_Mcd__c where id=:sms.id];
         for ( Survey_Mcd__c v:sm)
        {
            v.Comment__c=true;
            v.X5_Scale_Rating__c=false;
        } 
    update sm;
        Survey_Mcd__c sms1= new Survey_Mcd__c();
                 sms1.Yes_No__c=true;
            sms1.X5_Scale_Rating__c=true;
            sms1.Comment__c=true;
               update sms1;
            system.test.stopTest();
        }
}

 
I am getting error as 
System.DmlException: Update failed. First exception on row 0; first error: MISSING_ARGUMENT, Id not specified in an update call: [] while executing my test class for trigger Please suggest:

Trigger:
trigger selectOneCheckbox on Survey_Mcd__c (before update) {
for(Survey_Mcd__c sms : Trigger.New){
  if(Trigger.isUpdate){
  if((sms.Yes_No__c && sms.X5_Scale_Rating__c && sms.Comment__c)  || (sms.Yes_No__c && sms.X5_Scale_Rating__c)  
  || (sms.Yes_No__c && sms.Comment__c) || (sms.X5_Scale_Rating__c && sms.Comment__c)){
  sms.addError('Please select only one checkbox');
   }
  }
 }
}

Test Class:
@isTest
public class TestselectOneCheckbox {

    static testMethod  void myUnitTest() {
        system.test.startTest();
            
            Survey_Mcd__c sms= new Survey_Mcd__c();
                 sms.Yes_No__c=true;
            sms.X5_Scale_Rating__c=true;
            sms.Comment__c=true;
               update sms;
        List <Survey_Mcd__c> sm= [select id,Comment__c,X5_Scale_Rating__c,Yes_No__c from Survey_Mcd__c where id=:sms.id];
         for ( Survey_Mcd__c v:sm)
        {
            v.Comment__c=true;
        } 
        insert sm;
            system.test.stopTest();
        
    }
}


 
Hello everyone, i'm developing a webservice in rest and i have no ideia about how write a test class in this case and this is my code
@RestResource(urlMapping='/upsertaccount')
global with sharing class WSCustomerEdit {
   
   @HttpPost
    global static Account doPost(){
        String accountJSON = RestContext.request.requestBody.toString();
        JsonAccount serializedAcc = (JsonAccount)(JSON.deserialize(accountJSON, JsonAccount.class));
    
        Account acc = [SELECT Id FROM Account WHERE id =: serializedAcc.Id];
        acc.Name = serializedAcc.name;
        acc.Phone = serializedAcc.phone;
        upsert acc;
        return acc;
        
    }

    global class JsonAccount{
        public String id      {get;set;}
        public String name    {get;set;}
        public String phone   {get;set;}
        public String address {get;set;}
    }
}
and my test class
@isTest
public class CustomerEditTest {

  @isTest
	static void teste(){
        
		WSCustomerEdit.JsonAccount acc = new WSCustomerEdit.JsonAccount();
        
		acc.id      = 'test';
		acc.name    = 'NameTest';
		acc.phone   = '1198785496';
		acc.address = 'Rua x';

		String myJSON = JSON.serialize(acc);
	}
}

how can I make a test class with 100% of code coverage? 
 
hi all,

the soql in the following code is failing. Could somebody explain this to me.
Map<Id, String> profileIds = new Map<Id, String>();
profileIds.put('00eee000000xxxx','System Administrator');
profileIds.put('00eee00000yyyyy','YYY Profile');
profileIds.put('00eee00000zzzzz','ZZZ Profile');

List<User> users = [SELECT Id, Name, Email, ProfileId FROM User WHERE NOT(Email like '%@example.com') AND ProfileId NOT IN :profileIds.keySet()];
System.debug(users.size());
for (User usr: users)
{
    System.debug(usr.id+'    '+usr.Email);
}
Where i remove one of the clause from the where statement, it works.

Thanks.
 
global class SendQuoteAsEmail 
{
    public static List <String> ToAddresses= New List<String>();

    webservice static string sendQuoteEmail(String OrderIdFromParam)
    {
    
        try
        {
        
            System.debug('Order ID passed'+OrderIdFromParam);
                   
            List<order> OrderDetailList = [select id, name,orderNumber,account.Billing_Owner__r.id,Client_Order_Owner__r.Email,Client_Order_Owner__r.id,Quote__c from Order where id=: OrderIdFromParam];
            List<order> orderId=new List<order>();
            //List<Order> ordersToUpdate=new List<Order>();
            
            List<Quote_Email__c> getCustomSettingValues= new List<Quote_Email__c>([select CC_Email_Address__c, From_Email_Address__c from Quote_Email__c limit 1]);
               
            String fromAddress= getCustomSettingValues.get(0).From_Email_Address__c ;
            //String[] ccaddress = new String[] {getCustomSettingValues.get(0).CC_Email_Address__c};
            
            OrgWideEmailAddress[] owea = [select Id from OrgWideEmailAddress where Address=:fromAddress];
                       
            for(Order ord: OrderDetailList )
            {
                ToAddresses.add(ord.Client_Order_Owner__r.Email);
                orderId.add(ord);
            }
                 
            system.debug('email ID:'+ToAddresses);
    
            Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
            PageReference pdf =  Page.QuoteDetailsPage;
            pdf.getParameters().put('id',OrderIdFromParam);
            pdf.getParameters().put('param','withprice');

            pdf.setRedirect(true);
    
            Blob b;
             
           // Take the PDF content
           if(Test.IsRunningTest())
           { 
                b=Blob.valueOf('UNIT.TEST');

           }
           else
           {
                b = pdf.getContent();
           }
    
            // Create the email attachment
    
            Messaging.EmailFileAttachment efa = new Messaging.EmailFileAttachment();
    
            efa.setFileName(OrderDetailList[0].orderNumber+'-Quote-DiamondAir International.pdf');
    
            efa.setBody(b);

             // Construct the list of emails we want to send
             List<Messaging.SingleEmailMessage> lstMsgs = new List<Messaging.SingleEmailMessage>();

             Messaging.SingleEmailMessage msg = new Messaging.SingleEmailMessage();
             email.setTemplateId( [select id from EmailTemplate where DeveloperName='Quote_Email_Template'].id );
             email.setWhatId(OrderIdFromParam);
             email.setTargetObjectId(OrderDetailList.get(0).Client_Order_Owner__r.id);
             email.setToAddresses( ToAddresses);
             //email.setCcAddresses(ccaddress);
             email.setFileAttachments(new Messaging.EmailFileAttachment[] {efa}); 
             email.setOrgWideEmailAddressId(owea.get(0).Id);
             lstMsgs.add(email);

            
            String upsertOrder=null;
            String updateInvoice=null;
            
              
                
                List<order> OrderToUpdate= new List<Order>();
                for(order orderListVal: orderId)
                {
                    datetime myDateTime = datetime.now();
                    string mydtstring = mydatetime.format();
                    orderListVal.Quote_status__c='Quote Sent to Client at '+myDateTime; 
                    orderListVal.Quote_Sent__c=true;
                    OrderToUpdate.add(orderListVal); 
                    
                }//end of for
                
                try{
                    update OrderToUpdate;
                    updateInvoice='Pass';
                }
                catch(Exception e)
                {
                    updateInvoice='Fail';
                    return 'false';
                }
                if(updateInvoice.equals('Pass'))
                {
                    List<Messaging.SendEmailResult> results=new List<Messaging.SendEmailResult>();
            
                    if(!Test.isRunningTest())
                        results=Messaging.sendEmail(lstMsgs);  
                   if(results.get(0).isSuccess())          
                        return 'true'; 
                   else 
                       return 'false';
                }
                else 
                    return 'false';
                         
      }//end of try
      catch(Exception e)
      {
          system.debug('Catch block'+e);
          return 'false';
          
      } 
      //end of catch  

    }//end of sendInvoiceEmail
}//end of class

 
Hi Friends, 

Help me with test class, 
Below is my Apex Code.

public class LenderLoansDetailsSearchController {
    public String LoanID {get;set;}
    public String Email {get;set;}
    public String PAN {get;set;}
    public String Mobile {get;set;}
    public List<Loan__c> lstofResult {get;set;}
    public String LenderID{get;set;}
  
    public LenderLoansDetailsSearchController(){
        LoanID = '';
        PAN = '';
        Email = '';
        Mobile = '';
        lstofResult = new List<Loan__c>();
        LenderID= [select id,Phone,Lender_ID__c, name from User WHERE ID =:userinfo.getUserId()].Lender_ID__c;     
    }
    
    public void SearchAcc(){
        lstofResult = new List<Loan__c>();
        lstofResult = [SELECT Id,Name,Mobile__c,Customer_Name__c,Customer_Journey_Status__c,EMI_Amount__c,Loan_Amount__c,Customer_Email__c,Current_Assigned_Lender__c,Pan_Card__c FROM Loan__c WHERE Pan_Card__c like :PAN+'%'  AND Current_Assigned_Lender__c =:LenderID LIMIT 999];
           
    if (lstofResult.size() == 0){
       ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Warning,'No Loans Found Please try With Correct values'));
       }
     
    }
    
    public void SearchAcc1(){
        lstofResult = new List<Loan__c>();
        lstofResult = [SELECT Id,Name,Mobile__c,Customer_Name__c,Customer_Journey_Status__c,EMI_Amount__c,Loan_Amount__c,Customer_Email__c,Current_Assigned_Lender__c,Pan_Card__c FROM Loan__c WHERE Customer_Email__c like :Email+'%' AND Current_Assigned_Lender__c =:LenderID LIMIT 999];
           
    if (lstofResult.size() == 0){
       ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Warning,'No Loans Found Please try With Correct values'));
       }
     
    }
    public void SearchAcc2(){
        lstofResult = new List<Loan__c>();
        lstofResult = [SELECT Id,Name,Mobile__c,Customer_Name__c,Customer_Journey_Status__c,EMI_Amount__c,Loan_Amount__c,Customer_Email__c,Current_Assigned_Lender__c,Pan_Card__c FROM Loan__c WHERE Name like :LoanID+'%' AND Current_Assigned_Lender__c =:LenderID LIMIT 999];
           
    if (lstofResult.size() == 0){
       ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Warning,'No Loans Found Please try With Correct values'));
       }
     
    }
    public void SearchAcc3(){
        lstofResult = new List<Loan__c>();
        lstofResult = [SELECT Id,Name,Mobile__c,Customer_Name__c,Customer_Journey_Status__c,EMI_Amount__c,Loan_Amount__c,Customer_Email__c,Current_Assigned_Lender__c,Pan_Card__c FROM Loan__c WHERE Mobile__c like :Mobile+'%' AND Current_Assigned_Lender__c =:LenderID LIMIT 999];
           
    if (lstofResult.size() == 0){
       ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Warning,'No Loans Found Please try With Correct values'));
       }
     
    }
}
  • January 02, 2018
  • Like
  • 0
@isTest
public class CaseClassTest {
    
    static TestMethod void MyUnitTest(){
        
        Test.startTest();
        Pagereference tocase = Page.NewVFPage;
        
        Case  testCase = new Case();
        
        testCase.Status='Closed';
        testCase.Reason='Other';
        
        insert testCase;
        
        Test.setCurrentPage(tocase);
        
        tocase.getParameters().put('Id',testCase.id);
        ApexPages.StandardController sc = new ApexPages.standardController(testCase);
        CaseClass  cas = new CaseClass (sc);
        
        test.stopTest();
        
        
    }
}

I'm not getting maximum code coverage.. Help me to sort out this
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?