• 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 have a controller where in am getting this error displayed on my VF page.
Below is my code
public String distributionIds;
    
  public List<Distribution_List_Item__c> distItemLst{get;set;}
    
    //CONSTRUCTOR
    public VistAudit_VFC()
    {
        visitId=ApexPages.currentPage().getParameters().get('id');
        relatedAccountId=ApexPages.currentPage().getParameters().get('accid');
        distItemLst=new List<Distribution_List_Item__c>();
        distributionIds='';
    }
    
    //Constructs the data displayed on the page for all sections
    public void createData()
    {
     distributionIds=[select Id from Distribution_List__c where Business_Partner__c=:relatedAccountId 
                      AND Start_Date__c < today AND End_Date__c > today AND Status__c='Active'].Id;

     distItemLst=[select id from Distribution_List_Item__c where Distribution_List__c =:distributionIds];
}

in the above code,actually no record exisits in database to return the rows.But because of this error it discards the further execution of the code.
So can anyone please suggest how do i get rid of this error when there are no records present in database?

Thanks
Hello ,
I am using Developemnt Org. And in the Build--> Customize section, I could'nt find  Task object. I need to write some trigger on it. Please let me know, i am looking in wrong place.. or any issue with the visibility ?
Hi,
This trigger is used to find the duplicates while entering the new contacts.

trigger dupcon on Contact (before insert, before update){
for (Contact c :trigger.new) {
//c.adderror('Hello');
if (c.FirstName != null && c.LastName!= null && c.BirthDate!= null) {
c.adderror('Hello');
List <Contact> dupcon = [SELECT Id FROM Contact WHERE FirstName = :c.FirstName AND LastName = :c.LastName ];
if (dupcon.size() >0 ) {
String Errmsg = 'ERROR';
Errmsg += 'Record Id'+dupcon[0].Id;
c.adderror(Errmsg);
}
}
}
}
 Seems like the If condition doesnt work. I tried to add an errormessage just before the if statement. Then "hello" appears along  with an Error msg saying "Contacts not associated with accounts are private and cannot be viewed by other users or included in reports."

Please help me on this . Thanks Much in Advance
Hi folks,

Can anyone tell me how to resolve the below error while upserting 20k records.but it works fine if it is 10k.
I don't know why its comes.Am using soap api for connecting sfdc.

AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
faultSubcode:
faultString: java.net.SocketException: Connection reset
faultActor:
faultNode:
faultDetail:
{http://xml.apache.org/axis/}stackTrace:java.net.SocketException: Connection reset

Thanks in advance,
Karthick.S
Hi folks,
       Can anyone tell me how to call the action function in visualforce javascript remoting?
My usecase is I want to execute action method after ther remoting 

I've onclick and action method in command button
 I want to perform onclick first which perform some remote action once it completed then it will call the action method
for that how to write the code?

Thanks in adavnce
Karthick
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 folks,
       Can anyone tell me how to use the Date Literal in apex?
My use case is I want to use Date literal as a custom picklsit.
I want to create custom picklist as follows
User-added image


Please someone tell me how can I implement,


Thanks in advance,
Karthick
Hi folks,
       Can anyone tell me how to access the child records in parent child relationship?
My code snippet as follows
List<Account> acc = [SELECT Id,Name,(SELECT Id,LastName FROM Contacts) FROM Account];
for(Account  a: acc){
     System.debug('CAaount name:'+ a.Name);

//I dono how to acces contact s here
       for(Contact c:a.Contacts)
     { System.debug('Conatct Last:' +c.LastName);
     }


Thanks in advance,
Karthick
Hi folks,
    Can anyone tell me how to redirect one visualforce page to another visualforce page automatically ?
below is my visualforce page :
<apex:page standardController="Account" extensions="AccountDownload" 
contentType="application/msWord/#Test-{!NOW()}.doc"
   recordSetVar="accounts" sidebar="false"  cache="true"> 
    
    <html xmlns:w="urn:schemas-microsoft-com:office:word">
        <head>
            
        
        </head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
         
        <body>                       
            <apex:form >
                <apex:pageBlock title="Archiver For Account">
                     <div style="text-align:left" >          
                         <apex:pageBlockTable value="{!accounts}" var="ac" >
                             <apex:column headerValue="AccountName">
                                 <apex:outputText >{!ac.Name}</apex:outputText>
                             </apex:column>
                             <apex:column headerValue="Account Number">
                                 <apex:outputText >{!ac.AccountNumber}</apex:outputText>
                             </apex:column>
                             <apex:column headerValue="AccountType">
                                 <apex:outputText >{!ac.Type}</apex:outputText>
                             </apex:column>
                             <apex:column headerValue="Phone Number">
                                 <apex:outputText >{!ac.Phone}</apex:outputText>
                             </apex:column>                                       
                         </apex:pageBlockTable>  
                      </div>           
                    </apex:pageBlock>
    
               <apex:outputText value="hi dude,"/>
           </apex:form>
           
        </body>
        <script>
 
            function redirect(){
                window.location.href='https://c.ap1.visual.force.com/apex/AccountasTextfile'; 
            }
 
            window.onload = window.setTimeout(redirect(),5000);
 
        </script>
    </html>
</apex:page>

My question is once the document is downloaded then it will automatically redirect to another page as mentioned above.
I have tried using action attribute,calling redirect method from constructor. but nothing happen.
Finally I got the idea is using javascript we can redirect automatically.
but it dosent work for me.

Someone please tell me what I have to modify.



Thanks in advance
Karthick
HI folks,
   I am going to take DEV401 exam on march 2.  But Salesforce has recently release new version Spring 15.
Please let me know as soon as possible if this changes question patterns.


Thanks in advance
Karthick
HI folks,
           Can anyone tell me how to validate the uploaded file as image?
My vfp:
<apex:page standardController="Contact" sidebar="false" extensions="DpConnectApiExt">
    <apex:form >
        
        <apex:outputPanel id="ProfilePicturePanel">
            <apex:pageMessages ></apex:pageMessages>
            <apex:outputText ><b>Current User Profile Picture Using Connect API</b></apex:outputText><br/>
            <apex:actionRegion >
            <center> <apex:image url="{!UserfullPhoto}" />    </center><br/><br/>
            </apex:actionRegion>
        </apex:outputPanel>
            <apex:outputtext > <b> Uploading Image Via Connet API </b></apex:outputtext>
            <apex:inputfile value="{!file}"></apex:inputfile>
            <apex:commandButton value="Submit" action="{!upload}"  />
            
        
    </apex:form>
  
</apex:page>

and my controller:
 
global class DpConnectApiExt {
    
    global String UserfullPhoto { get; set; }
    global transient Blob file{get;set;}
    global DpConnectApiExt(ApexPages.StandardController controller) {
         
        ConnectApi.Photo p = ConnectApi.ChatterUsers.getPhoto(null, UserInfo.getUserId());
        UserfullPhoto =p.fullEmailPhotoUrl;
    }
    public void upload(){
            system.debug('File:'+file);
//I want to validate here

            ConnectApi.BinaryInput b=new ConnectApi.BinaryInput(file,'image/jpeg','myimage');
            

            ConnectApi.ChatterUsers.setPhoto(null,userinfo.getUserId(),b);   
        
        
    }
}

I dont know how to validate the blob data type
any help would be appreciatble
Thanks in advance
Karthick
Hi folks,
        Can anyone tell me how to deploy approval process from dev org to another dev org?


Please its urgent..


Thanks in advance
Karthick
Hi folks,
      Can anyone tell me how to execute the action mthod as first and javascript function as second .

My problem is: I have command button which has action method and js function.
I want to execute action function as first like (handle all the validation errors ) and then execute javascript function if there is no valdiation error.
If there is valdiation error then the page still remains same.

For this so far i have tried following

< apex:commandButton value="Next" styleClass="btn btn-success" action="{!tab3}" reRender="TabContent" oncomplete="changeStyle('{!$Component.tab3}','{!$Component.tab2}','{!$Component.tab1}','{!$Component.tab4}');"/>

Here am using oncomplete method but it doesnot work what I expect. Is there anyway to implement ?

Thanks in advance
Karthick
Hi folks,
        Can anyone tell me how to write the trigger based on the approved records?
Like
I want to enter the records to queue if the record is approved by appropriate user.
I need a sample code for this..


Thanks in advance
​Karthick

 
Hi folks,
      Can anyone tell me how to write the test class for pagination?
Below is my test class which covers 85%  but it didnt covers the hasnext,previous and pagenumber method.
 
@isTest(SeeAllData=true)
public class PaginationControllerTest {
    
        public static testMethod void testSearchAccount() {
        PageReference pageRef = Page.TestPagination;
        Test.setCurrentPage(pageRef);

        // Instantiate a new controller with all parameters in the page
    
        PaginationController  p=new PaginationController ();
        
        p.getAccountList();
        p.Next();
        p.First();
        p.Last();
        p.Previous();
        p.Cancel();
        p.con.getHasPrevious();
        p.con.getHasNext();
        p.con.getPageNumber();
        
       
     }

}



Controller:
public class PaginationController {
    public ApexPages.StandardSetController con {
        get {
                if(con == null) {
                    con = new ApexPages.StandardSetController(Database.getQueryLocator([Select Id, Name,Type FROM Account])); 
                    con.setPageSize(5);                      
                }
                return con;
        }
        set;
    }
    
    public List<Account> getAccountList(){
        return (List<Account>)con.getRecords();
    }
    
    public Boolean hasNext {
        get {
                return con.getHasNext();
            }
        set;
    }
   
    public Boolean hasPrevious {
        get {
            return con.getHasPrevious();
        }
        set;
    }
   
    public Integer pageNumber {
        get {
            return con.getPageNumber();
        }
        set;
    }
   
    public void first() {
        con.first();
    }
   
    public void last() {
        con.last();
    }

    public void previous() {
        con.previous();
    }
    
    public void next() {
        con.next();
    }
  
    public void cancel() {
        con.cancel();
    }        

}


Thanks in advance
Karthick
Hi follks,
        Can anyone tell me what is the purpose of AddFields Method in Standard Controller?
I Cant get what they provided in salesforce doc.
I need a clear explanation with example and please explain me when should I use it?
Any help would be greatly appreciate

Thanks in advance
Karthick
Hi folks,
         Can anyone tell me what is the need of custom extention in visualforce page?
Becase everything we can  done by using custom controller .


Thanks in advance
Karthick
Hi folks,
          Can anyone tell me how to hide and show outpanel
My usecase is:
I have 2 output panel. In the first I have a button when I click on the button the 1st outputpanel should get hide and 2nd one get display.
and same for second output panel

For that how can i write code for visualforce page
Is ther any sample code for this usecase


Thanks in advance
Karthick
Hi folks,
       can anyone tell me soql for getting user id who has access the record??
Like 
I have created test objects
5 users in my org.
if user 1 creates record on test object then user2,user3,user5 access that reocrd and user4 cannot access the reocrd
I wanna soql query for get all user id who has permission to access the record that is created by user1

Thanks in advance
Karthick
Hi folks
       Can anyone tell me what is trigger.oldmakp.keyset() and give me sample example for that

Please Help
Hi Everyone,
      Can anyone tell me what is trigger.new, trigger.old and trigger.newmap ,trigger.oldmap
Trigger.oldmap.keyset with sample example


Thanks in advance
Karthick

Can anyone tell me the working process for sales objects in salesforce
Thanks in advance
Karthick
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.

  • October 01, 2010
  • Like
  • 0