• Mert YALTI
  • NEWBIE
  • 110 Points
  • Member since 2015
  • Salesforce Developer
  • Avandel Inc.


  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 17
    Replies
Apex class as following-

public class VerifyDate {
//method to handle potential checks against two dates
public static Date CheckDates(Date date1, Date date2) {
//if date2 is within the next 30 days of date1, use date2. Otherwise use the end of the month
if(DateWithin30Days(date1,date2)) {
return date2;
} else {
return SetEndOfMonthDate(date1);
}
}
//method to check if date2 is within the next 30 days of date1
private static Boolean DateWithin30Days(Date date1, Date date2) {
Date date30Days = date1.addDays(30); //create a date 30 days away from date1
if( date2 > date30Days ) { return false; }
else { return true; }
}
 
//method to return the end of the month of a given date
private static Date SetEndOfMonthDate(Date date1) {
Integer totalDays = Date.daysInMonth(date1.year(), date1.month());
Date lastDay = Date.newInstance(date1.year(), date1.month(), totalDays);
return lastDay;
}
}

-------------------------------------------------
@Test class as following-

@isTest
public class TestVerifyDate
{
     @isTest static void testWarmTemp()
     {
          Date dte = VerifyDate.CheckDates(1,10);
          System.assertEquals(10,dte);
     }
}

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

test code show me the following error-
[Error] Error: Compile Error: Method does not exist or incorrect signature: VerifyDate.CheckDates(Integer, Integer) at line 6 column 21

vfpage-----


<apex:page Controller="Employee" showheader="false">
  <apex:form >
   <script type='text/javascript'>
   function runOnEnter(ev) {
        if (window.event && window.event.keyCode == 13 || ev.which == 13) {
            searchEmpRecs();
            return false;
        } else {
            return true;
        }
}
</script>
 <apex:inputText value="{!searchString}" onkeypress="return runOnEnter(event);"/>
  <apex:commandButton value="Submit" action="{!searchEmp}" reRender="pgblcktbl"/>
    <apex:pageBlock title="Employee Details">
     <apex:pageBlockTable value="{!empList}" var="emp" id="pgblcktbl">
        <apex:column value="{!emp.First_Name__c}"/>
           <apex:column value="{!emp.Last_Name__c}"/>
             <apex:column value="{!emp.EmpID__c}"/>
               <apex:column value="{!emp.Email__c  }"/>
                 <apex:column value="{!emp.contact__c}"/>
                <apex:column value="{!emp.cityy__c}"/>
               <apex:column value="{!emp.Address__c}"/>
             <apex:column value="{!emp.Department__c}"/>
        </apex:pageBlockTable>
        </apex:pageBlock>
      <apex:actionFunction name="searchEmpRecs" action="{!searchEmp}" reRender="pgblcktbl"/>
  </apex:form>
</apex:page>

class---------

public class Employee {

    public Employee() {
        empList = new List<Employees__c>();
        empList = [select id,First_Name__c,Last_Name__c,EmpID__c,Email__c,Department__c,contact__c,cityy__c,Address__c from Employees__c];
    }
   
    Public List<Employees__c> empList{get;set;}
    Public string searchString{get;set;}


   Public void searchEmp(){
        searchString += '%';
        empList = new List<Employees__c>();
        empList = [select First_Name__c,Last_Name__c,EmpID__c,Email__c,contact__c,cityy__c,Department__c,Address__c from Employees__c where First_Name__c like : searchString limit 10];
       
    }   
 }


 
I´m receiving the following error: Non-selective query against large object type (more than 100000 rows). Consider an indexed filter or contact salesforce.com about custom indexing.
Even if a field is indexed a filter might still not be selective when:
1. The filter value includes null (for instance binding with a list that contains null)
2. Data skew exists whereby the number of matching rows is very large (for instance, filtering for a particular foreign key value that occurs many times)Class.OpportunityService.calculaPromedio: line 77, column 1Class.OpportunityTriggerHandler.OnBeforeUpdate: line 62, column 1Trigger.OpportunityTrigger: line 15, column 1

The previous error occurs on the object Opportunity when I do a consult.

Here is the method:

User-added image

Any help will be appreciated.
Apex class as following-

public class VerifyDate {
//method to handle potential checks against two dates
public static Date CheckDates(Date date1, Date date2) {
//if date2 is within the next 30 days of date1, use date2. Otherwise use the end of the month
if(DateWithin30Days(date1,date2)) {
return date2;
} else {
return SetEndOfMonthDate(date1);
}
}
//method to check if date2 is within the next 30 days of date1
private static Boolean DateWithin30Days(Date date1, Date date2) {
Date date30Days = date1.addDays(30); //create a date 30 days away from date1
if( date2 > date30Days ) { return false; }
else { return true; }
}
 
//method to return the end of the month of a given date
private static Date SetEndOfMonthDate(Date date1) {
Integer totalDays = Date.daysInMonth(date1.year(), date1.month());
Date lastDay = Date.newInstance(date1.year(), date1.month(), totalDays);
return lastDay;
}
}

-------------------------------------------------
@Test class as following-

@isTest
public class TestVerifyDate
{
     @isTest static void testWarmTemp()
     {
          Date dte = VerifyDate.CheckDates(1,10);
          System.assertEquals(10,dte);
     }
}

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

test code show me the following error-
[Error] Error: Compile Error: Method does not exist or incorrect signature: VerifyDate.CheckDates(Integer, Integer) at line 6 column 21
Hi, I was able to create a google map on a custom object through a VF page. I was wondering if there is a way to click that map and it opens a new window taking me to google maps and that location? Similar to what is built into the Accounts already, if you click that map it opens a new tab and google maps appears. Thanks! 
Hello,

I have Milestones PM+ for Salesforce. Up until now we have been able to change projects in another user's name as the project owner. However today, this message appeared and it won't allow me to change the project owner to another user. Can someone help? Thanks!

Error: Apex trigger MPM4_BASE.Milestone1_Project_Trigger caused an unexpected exception, contact your administrator: MPM4_BASE.Milestone1_Project_Trigger: execution of BeforeUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id a0G4000000IngfkEAB; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, MPM4_BASE.Milestone1_Milestone_Trigger: execution of AfterUpdate caused by: System.NullPointerException: Attempt to de-reference a null object (MPM4_BASE) : []: (MPM4_BASE)

Thanks,

Nick

vfpage-----


<apex:page Controller="Employee" showheader="false">
  <apex:form >
   <script type='text/javascript'>
   function runOnEnter(ev) {
        if (window.event && window.event.keyCode == 13 || ev.which == 13) {
            searchEmpRecs();
            return false;
        } else {
            return true;
        }
}
</script>
 <apex:inputText value="{!searchString}" onkeypress="return runOnEnter(event);"/>
  <apex:commandButton value="Submit" action="{!searchEmp}" reRender="pgblcktbl"/>
    <apex:pageBlock title="Employee Details">
     <apex:pageBlockTable value="{!empList}" var="emp" id="pgblcktbl">
        <apex:column value="{!emp.First_Name__c}"/>
           <apex:column value="{!emp.Last_Name__c}"/>
             <apex:column value="{!emp.EmpID__c}"/>
               <apex:column value="{!emp.Email__c  }"/>
                 <apex:column value="{!emp.contact__c}"/>
                <apex:column value="{!emp.cityy__c}"/>
               <apex:column value="{!emp.Address__c}"/>
             <apex:column value="{!emp.Department__c}"/>
        </apex:pageBlockTable>
        </apex:pageBlock>
      <apex:actionFunction name="searchEmpRecs" action="{!searchEmp}" reRender="pgblcktbl"/>
  </apex:form>
</apex:page>

class---------

public class Employee {

    public Employee() {
        empList = new List<Employees__c>();
        empList = [select id,First_Name__c,Last_Name__c,EmpID__c,Email__c,Department__c,contact__c,cityy__c,Address__c from Employees__c];
    }
   
    Public List<Employees__c> empList{get;set;}
    Public string searchString{get;set;}


   Public void searchEmp(){
        searchString += '%';
        empList = new List<Employees__c>();
        empList = [select First_Name__c,Last_Name__c,EmpID__c,Email__c,contact__c,cityy__c,Department__c,Address__c from Employees__c where First_Name__c like : searchString limit 10];
       
    }   
 }


 
How can i assert for the return value of save(), Here is my code for class
public pagereference save() {

        ipAsset.AsLi_Status__c = AsLi_Constants.ASSETSTATUS_DRAFT;
        try {
            copyAccountCompanyDesc();
            upsert ipAsset;

            for(AsLi_AssetTechnology__c at : assetTechTags){
                if(at.AsLi_AssetMD__c == null){
                    at.AsLi_AssetMD__c = ipAsset.Id;
                }
            }

            upsert assetTechTags;
            
            
            PageReference IPAssetPage = new ApexPages.StandardController(ipasset).view();
                
            IPAssetPage.setRedirect(true);
            return IPAssetPage;
            
        } catch (DmlException ex) {
            ApexPages.addMessages(ex);
            return null;
        }
            
    }
Here is my test class
RecordType rt = [select id,Name from RecordType where SobjectType='AsLi_IPAsset__c' And Name = 'RFP Answer'];
        System.debug(rt);
        
        List<AsLi_TechnologiesTags__c> techTest = new List<AsLi_TechnologiesTags__c>();
        AsLi_TechnologiesTags__c tags1 = new AsLi_TechnologiesTags__c(Name = 'Google', AsLi_Active__c = True, AsLi_ForApproval__c = False);
        AsLi_TechnologiesTags__c tags2 = new AsLi_TechnologiesTags__c(Name = 'Google Talk', AsLi_Active__c = True, AsLi_ForApproval__c = False);
        AsLi_TechnologiesTags__c tags3 = new AsLi_TechnologiesTags__c(Name = 'Google Drive', AsLi_Active__c = True, AsLi_ForApproval__c = False);
        
        techTest.add(tags1);
        techTest.add(tags2);
        techTest.add(tags3);
        
        insert techTest;
        
        AsLi_IPAsset__c asset2 = new AsLi_IPAsset__c(RecordTypeId = rt.Id, Name = 'test2');
        insert asset2;
        PageReference pageRef = new PageReference('https://c.cs24.visual.force.com/apex/AsLi_AssetEdit/?Id=' + asset2.Id);



Test.setCurrentPage(pageRef);
        
        ApexPages.StandardController sCon = new ApexPages.StandardController(asset2);
        AsLi_AssetEditControllerExtension controller = new  AsLi_AssetEditControllerExtension(sCon);
        AsLi_AssetEditControllerExtension.TechnologyWrapper wr = new AsLi_AssetEditControllerExtension.TechnologyWrapper();
        controller.showPopup();
        Test.startTest();
        PageReference search1 = controller.showPopup();
        controller.searchText = 'Google';
        controller.search();
        controller.getOnFirstPage();
        controller.getOnLastPage();
        controller.add();   
        controller.save();
        Test.stopTest();
        
        
        
        System.assertEquals(3,controller.searchCount.size());
        AsLi_AssetTechnology__c assetTag = [Select Id, Name, AsLi_TechnologiesTagsMD__c, AsLi_AssetMD__c From AsLi_AssetTechnology__c];
        
        System.debug(assetTag);
        System.assertEquals(asset2.id,assetTag.AsLi_AssetMD__c);
        System.assertEquals(techTest[0].id,assetTag.AsLi_TechnologiesTagsMD__c);
        

        
    }
Hi,

I'm trying to figure out a way to obtain the instance information from Custom Production / Sandbox URLs.

For example: If a Standard URL is "https://eu3.salesforce.com/" the instance information I'm looking for is "eu3" which can be obtained by calling "System.URL.getSalesforceBaseUrl()" and then parsing out the string.

But, when the URL is something like, "https://abc.my.salesforce.com/", how do I get the instance? Any help appreciated.

Thanks,
Shashank
Hi ,
I am able to send email using sendemail method.In order to send email with attachments I think we need to use SendRawEmail method.,I used sendrawEmail method .I am getting response as 200 but I didn't receive any emails/attachments.Can anyone provide a sample code for this?
Hi All need a small help in
how to send email along with attachment  using Amazon SES from apex class?

I am able to send email using 'Action=SendEmail' (like http://salesforce.stackexchange.com/questions/18428/connection-between-awsamazon-web-service-ses-and-sales-force-using-apex-code-t)but unable to send email along with attachment.
  • September 22, 2014
  • Like
  • 0