• SS Karthick
  • PRO
  • 2034 Points
  • Member since 2014

  • Chatter
    Feed
  • 3
    Best Answers
  • 7
    Likes Received
  • 0
    Likes Given
  • 226
    Questions
  • 163
    Replies
Hi All,

I'm attempting a Trailhead challenge and it requires me to create a test class on a method that takes date parameters. See below:
 
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) {
		//check for date2 being in the past
        	if( date2 < date1) { return false; }
        
        	//check that date2 is within (>=) 30 days of date1
        	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;
	}

}

...this is my first test method:
 
@istest private class TestVerifyDate {

    @istest static void method1crit1 (){
        Date method1res1 = VerifyDate.CheckDates(12/15/15,12/16/15);
        system.assertEquals(12/16/15,method1res1);
    }
}
...and I am getting the following error in the problems tab of the Dev Console:

"Method does not exist or incorrect signature: VerifyDate.CheckDates(Integer, Integer)"

Please help.

Thanks,

Mark
 
trigger UpdateRemitUsedStatus on Account (after insert, after update) {

for (Account act: Trigger.new) {

Update act.RemitfromUsedStatus == True from act

where act.Enterprise_ID__C in (select Remit_From__c from Account)

}

Please help me modify the above code in trigger which i wrote in simple SQL. I want to update RemitfromUsedStatus == True  on account object when account Enterprise_ID is a RemitFrom ID( RemotFrom_ID is a look up to account object on enterprise ID) for some records.
Hi folks,
    Can anyone tell me how to rerender a particular pageblock when the action method using pageReference?

My use case is I want to rerender a particular block when I click the command button

VFP:
<apex:commandButton action="{!Download}" value="download" id="chatterDownload" reRender="FeedFilePanel"   /><br/>


  <apex:outputPanel id="FeedFilePanel" rendered={!feedFile}>
                If you want to download the files that are attached to the Feeds then click below button<br/>
                
     
             <center>   <apex:commandButton id="uploadZipButton" value="Download Files" action="{!uploadZip}" /></center>
            </apex:outputPanel>

Apex class:
public PageReference Download(){  
     
       feedFile=true;
        
        if(!feedItemList.isEmpty()){
            String fileName = 'Feeds' +  DateTime.Now() + '.pdf';
            Apexpages.currentPage().getHeaders().put('content-disposition', 'attachment; filename=' + fileName);
            PageReference chatterdownload= Page.ChatterDownload;
            chatterdownload.setRedirect(false);
            return chatterdownload; 
        } 
        else{
            
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'No Feeds, Please select an another Date to Download'));
            return null;
             
        }     
       
   }

Please someone telI me how to use Rerender attribute in that command button?

Thanks in advance
Karthick


 
Hi folks,
        Can anyone tell me how to get the contentData and contentFileName for FeedComment ?
I can get same for FeedItem using below query.
select Id,RelatedRecordId,Type,Body,CreatedDate,CreatedBy.FirstName,CreatedBy.LastName,Title,LinkUrl,ContentData,ContentFileName From FeedItem


But there is no contentData,ContentFileName field in FeedComment Class.
Please help me how can I  get for FeedComment?

Thanks in advance,
Karthick
Hi folks,
      Can anyone tell me how to create a zip file in salesforce via apex?
I have seen the below link but it doesnt work for me.
http://www.valnavjo.com/blog/compressing-files-in-salesforce/

Please someone give me the working code sinppet for creating zipfile.

Thanks in advance
Karthick
Hi folks,
      Can anyone tell me how to download the multiple files via apex?
I have a visualforce page which contains download button. Once I click this button then it will download all the files in my attachement object.
For that how can i implement.



Thanks in advance
Karthick
Hi folks,
     Can anyone tell me how to get the id of the feedItem files?
Like I want to know the id(ContentDocument.LatestPublishedVersionId) of the files that are attached to the feeditem and feedcomment.
Please someone give me the soql for above usecase.


Thanks in advance
Karthick
Hi folks,
      Can anyone tell me how to download the chatter files in visaulforce page?
like
If the chatter post type is :ContentPost
then I need to download that file?


For that How can I implement?

Thanks in advance
Karthick

Hi I have a question which I'm not 100% is possible in Salesforce but will welcome any suggestions / ideas. I have an APEX class which creates multiple licence keys and has dual functionality, it will either allow the user to email them as part of an email body or create the licenses as a txt file attachment to an outbound email. Now the issue is the text file needs to be enclosed within a zip file due to different mail clients unable to process the .lic extension. Is there any mechanism which will let me wrap a txt file into a zip file as part of an attachment ? Been wracking my brain for ages on this. Any assistance would be welcome even if its not possible.