• Sayasoni
  • NEWBIE
  • 185 Points
  • Member since 2011

  • Chatter
    Feed
  • 7
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 40
    Questions
  • 58
    Replies

Hi Good People,

I am trying to download an attachment from a command button in Visualforce page. My functionality works fine on records that have an attachment.However, i get "Invalid parameter for function URLFOR

Error is in expression '{!URLFOR($Action.Attachment.Download, attId)}' in component <apex:page> in page mypage"  error on a record that does not have an attachement. How do i get to display this message on records that have no attachment when the Command button is clicked. ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'The document is unavailable!')); instead of getting the above error?

 

Below is part of my controller and Visualforce page that does the download:

public String attId{get;set;}
Candidate__c cand = [Select id,Name,First_Name__c,from Candidate__c where id = :PgId];
Attachment att = [Select id,parentId from Attachment  where parentId = :cand.id];
    if(att != null){
    	attId = att.id;
    	}  
   }  

 

<apex:commandButton action="{!URLFOR($Action.Attachment.Download, attId)}" styleClass="buttonStyle" style="width:100px;height:30px;background:#6699FF;" value="Display Document" rerender="false"/>        

 

 

Hi,

Do anyone know the best resume parser that I can integrate with salesforce or a company that has webservices for parsing resumes that I can integrate with salesforce.

I have a controller that sends notications a month before a candidate's birthday. I can't seem to cover the else part of my if statements in my test class.The red parts being the ones not covered.

Kindly assist:

 

public class candidateEmailNotification{

public List<Candidates__c> candidates = [select First_Name__c,Name,Date_of_Birth__c
                         from Candidates__c];
       
 
       public List<Candidates__c> includeInEmail(){  
            
              List<Candidates__c> newcadidates = new  List<Candidates__c>(); 
              for(Candidates__c c: candidates) {

                  
                    if(c.Date_of_Birth__c==null){
                    
                    }
               else{
                    
              
               if(c.Date_of_Birth__c.dayOfYear() - System.today().dayOfYear()==30){

               
               newcadidates.add(c);
             
               }
               
           }
          } 

          return newcadidates;
        } 
        
        
        
     public String composeMessage(){
     
        
       String emailMsg = '';
       List<Candidates__c> c = includeInEmail();

       if(includeInEmail().size()==0){
       return null;
          }else{
       for(Integer i = 0;i< c.size(); i++){ emailMsg += '<tr><td>'+c.get(i).First_Name__c +'</td><td>'+c.get(i).Name+'</td><td style = color:red> '+c.get(i).Date_of_Birth__c.day()+ ' - '+c.get(i).Date_of_Birth__c.month() +' - '+System.today().year()+'</td></tr>';
       
    
       }
      
       
        } 
         
       return '<table><tr><th>First Name </th><th>Last Name</th><th>Birthday</th></tr>'+emailMsg+'</table>';
        }           
  
    public void sendMail() {
         if(composeMessage()==null){
         
         }else{
 
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); String[] toAddresses = new String[] {'martin.mathu@jjpeople.com'}; mail.setToAddresses(toAddresses); mail.setSubject(' Birthday Notification'); mail.setUseSignature(false); mail.setHtmlBody('<div style=color:green;><u>The Following Candidate(s) Have Birthday in one Month Time</u></div><br>' + composeMessage()); // Send the email Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });  
    }
    }

}

 Below is my test class:

@isTest
public class CandidateEmailNotificationTest {
    static testMethod void EmailNotificationTest() {
        List<Candidates__c> cand =  new List<Candidates__c>();
        Candidates__c candidate = new Candidates__c(Candidate_Source__c='Monster',Main_Email__c='emaill@email.com',Candidate_Mobile_Phone__c='000',Name ='LastN',First_Name__c = 'Tester',Candidate_Address__c='000',Date_of_Birth__c = System.today());
        Candidates__c candidate2 = new Candidates__c(Candidate_Source__c='test',Main_Email__c='emaill2@email.com',Candidate_Mobile_Phone__c='0011',Name ='LastN2',First_Name__c = 'Tester2',Candidate_Address__c='00022',Date_of_Birth__c = System.today());
        cand.add(candidate);
        cand.add(candidate2);
        insert cand;        
        
        Test.startTest();
        candidateEmailNotification cn =  new candidateEmailNotification();
        cn.candidates = cand;
        cn.includeInEmail();
        cn.composeMessage();
        cn.sendMail();       
        Test.stopTest();
                
        System.assertEquals(candidate.Date_of_Birth__c, System.today());
        }

}

 

I have a controller which aids in displaying a visualforce page with the Edit & delete functionality.However, my delete doesn't seem to work.

Kindly assist.Am using this post as a guide:

public class OrderDealsExtension {
	
	public List<Deals__c> deals {get;set;}
	public String SelectedDealId {get;set;}
	
	public OrderDealsExtension() {
		loadData();
	}
		
	public void loadData() {
			
		deals = [Select id,Name,Deal_Start_Date__c,Candidates__c,Contact__c,Deal_End_Date__c,Deal_Type__c,Deal_Buy_Price__c,Deal_Client_Rate__c,CreatedDate from Deals__c Order By CreatedDate desc];
	}
	
	public void deleteDeal(){
		if(SelectedDealId == null){
			return;
		}
		//find the deal record within the collection
		Deals__c tobeDeleted = null;
		for(Deals__c d :deals){
			if(d.Id == SelectedDealId){
				tobeDeleted = d;
				break;
			}
			
			//if deal record found delete it
			if(tobeDeleted != null){
				Delete tobeDeleted;
			}
			
			//refresh the data
			loadData();
		}
	}
	
}

Visualforce Page.

<apex:page controller="OrderDealsExtension">
<apex:form id="form" >
<apex:pageBlock title="Deals">
  <apex:pageMessages ></apex:pageMessages>
  <apex:pageBlockTable value="{!deals}" var="d">
     <apex:column >
       <apex:outputLink title="" value="/{!d.id}/e?retURL=/apex/{!$CurrentPage.Name}" style="font-weight:bold">Edit</apex:outputLink>&nbsp;|&nbsp;
       <a href="javascript&colon;if (window.confirm('Are you sure?')) deleteDeal('{!d.Id}');" style="font-weight:bold">Del</a>
     </apex:column>
    <apex:column headervalue="Order Number" >
	<apex:outputLink value="/{!d.id}">
	<apex:outputField value="{!d.Name}"/>
	</apex:outputLink>
</apex:column>
<apex:column value="{!d.Candidates__c}" />
<apex:column value="{!d.Contact__c}" />
<apex:column value="{!d.Deal_Start_Date__c}" />
<apex:column value="{!d.Deal_End_Date__c}" />
<apex:column value="{!d.Deal_Buy_Price__c}" />
<apex:column value="{!d.Deal_Client_Rate__c}" />
  </apex:pageBlockTable>
</apex:pageBlock>

<apex:actionFunction action="{!deleteDeal}" name="DeleteDeal" reRender="form" >
   <apex:param name="dealid" value="" assignTo="{!SelectedDealId}"/>
</apex:actionFunction>
</apex:form>
</apex:page>

 

 

I need to send a notification to a user for deals that Annula Review date(custom filed) equals to Today's date.

I have an apex scheduler class and the class that does the SingleEmail messaging.

My problem is that nothing seems to work since my query for retrieving the records doesn't seem to return any records despite having several records meet that criteria.I have even tried querying using a diffrent field value not the date and this too doesn't seem to return any results.Kindly assist.

Below is my controller for sending the email as well as the Apex scheduler.

 

public class SendAnnualReviewNote {

  public void sendNotification() {
	Date d = Date.today();					
	List<Deals__c> deals = [Select Id,Deal_Start_Date__c,Annual_Review_Formula_Date__c,Name,Contact__c from Deals__c where Annual_review_date__c = :d];
   for(Deals__c deal : dealz) {
	   Messaging.Singleemailmessage email = new Messaging.Singleemailmessage();
		String [] toAddresses = New String[]{'xxx@xxx.com'};
		email.setSubject('Deals Due For Annual Review');
		email.setPlainTextBody('The following deals are due for Annual Review in the next one month: ' +dealz[0].Name+ '.');
		email.setToAddresses(toAddresses);
		
		//Send the email
		Messaging.sendEmail(New Messaging.Singleemailmessage[]{email});	
	
	}
   }
	

}

 Scheduler:

global class ScheduleAnnualReview implements Schedulable{
	
	global void execute(SchedulableContext ctx) {
	  SendAnnualReviewNote sc =  new SendAnnualReviewNote();
	  sc.sendNotification();		
	}	

	public static testMethod void testScheduler() {
	  Test.startTest();
		ScheduleAnnualReview sch =  new ScheduleAnnualReview();
		String schd = '0 0 23 * * ?';	
                System.schedule('Test Annual Review', schd, sch);
           Test.stopTest();
	}
}

 

I would like to customize the Document search in salesforce.Kindly advice me on how to come up with an apex controller that will perform the search performed by the standard Document search on the document search in salesforce.

 

Hello,

 

I am able to insert new entries to a salesforce object from SiteForce.com interface by using "Forms" element.

But, I am not able to find out a way to edit an existing entry in salesforce.com object from SiteForce.com interface.

 

For Example: Assume there is a "Description Field" on a salesforce.com object entry. Can I update the text in the "Description Field" from SiteForce.com interface?

 

TIA.

 

-Ketan

I have a visualforce page that searches for contacts based on FirstName & LastName.The firstname & lastname fields are autopopulated using the email address value from another custom object.

However, i would also like the user to have the ability to edit the auto-populated firstname & lastname values with their on input before the search. The problem is the page only seems to perform the search using only the original auto-populated values & will not accept newly user input values,since everytime the user input values & clicks the search button,the PageBlockSection refreshes and fill the fields with the original auto-populated values.

Kindly advice on how to make the input text field accept both autopopulated values as well as user input values.

Below is some part of my wrapper class & visualforce page.

public String  firstName;
public String  lastName;
public String userinput;
public String userinp;
public List<cContact> contactList {get; set;}  

Public List<Contact> results = new List<Contact>();
 
/* Getter and setter methods for getting the user input ie. Contact name from the UI */ public String getUserinput(){return userinput;} public void setUserinput(String userinp){this.userinput=userinp;} public String getUserinp(){return userinp;} public void setUserinp(String userinp){this.userinp=userinp;}
//Getter and setters for firstname and lastname
/* Method to Search the contact database to fetch the query results */ public List<Contact> contactsearch() { contactList = new List<cContact>(); for(Contact c : [select Account.Name,Name,Alternative_Email_Address1__c,Alternative_Email_Address2__c,Assistant_s_Email2__c,FirstName,LastName,Email,title,Id from Contact where Email like :userinput+'%' and (FirstName = :firstName or FirstName like :userinp+'%' )and (LastName = :lastName or LastName like :userin+'%') ]) { contactList.add(new cContact(c)); } return null; }
/* Method for returning the contact search results to the UI */
public List<cContact> getResults()
{  
  return contactList;
}

 

<apex:form >
<apex:sectionHeader title="Step 1" subtitle="Select Client(s) to Add to:"/>
<apex:pageblock id="theBlock">
<apex:pageMessages /> <!-- this is where the error messages will appear -->
<apex:pageBlockSection title="Search Contacts" columns="1" ></apex:pageBlockSection>
<!-- Div to give a colored box effect -->
<div style="border-width:2px;border-style:solid;border-color:orange;">
    <!-- Panel grid to display boxes for accepting user input values -->
    <apex:panelGrid columns="2" >
        <apex:outputLabel style="font-weight:bold;" value="Client First Name" ></apex:outputLabel>
        <apex:inputText value="{!firstName}" id="firstName" disabled="false" />
        <apex:outputLabel style="font-weight:bold;"  value="Client Last Name" ></apex:outputLabel>
        <apex:inputText value="{!lastName}" id="lastName" disabled="false"  />
     </apex:panelGrid>
    <!-- End of panelgrid -->
    <!-- Div to position the commandbutton appropriately -->
        <div style="position:relative;left:75px;">
             <apex:commandButton value="Search" action="{!contactsearch}" reRender="theBlock"/>
        </div>
    <!-- End of div -->

 

 

 

 

Hi People,

I have an apex class & visualforce page tab working perfectly well on Admin users.But when a standard user clicks on the visualforce tab, he keeps getting the following error: Insufficient privileges,You do not have the level of access necessary to perform the operation you requested. Please contact the owner of the record or your administrator if access is necessary.

On the security of both the apex class & visualforce page i have enabled both profiles.I have checked almost everything regarding profile accessibility & everything looks fine.Kindly guide me on what could be the problem that i have overlooked.


I have a controller which redirects a user to different visualforce pages depending on the picklist value selected.However, its not working exactly as expected. The 'Add to contact' option appears as the default value thus when i select on 'Add to Associate' , it opens the 'Addtocontact' page rather than opening 'Addtoassociate' page.

How do i set a default picklist value something like 'Select option to Add to' ,then get the 'Add to contact' & 'Add to Associate' working properly as expected.

Below is my controller and part of the visualforce page.

 

public class redirectonthebasisofpicklist
 {

public list<selectoption>item{get;set;}

public string picklistvalue{get;set;}

public redirectonthebasisofpicklist()
{
    item=new list<selectoption>();
    item.add(new selectoption('Addtocontact','Add to contact'));
    item.add(new selectoption('AddtoAssociate','Add to Associate'));

}
public pagereference redirect()
{
    PageReference pageRef= new PageReference('/apex/'+picklistvalue);
    pageRef.setredirect(true);
    return pageRef;

}
}

 

 

 

<apex:page controller="redirectonthebasisofpicklist" >
 <Apex:form >
     <apex:selectList value="{!picklistvalue}" size="1" >

     <Apex:selectOptions value="{!item}"/>

    <apex:actionSupport event="onchange" action="{!redirect}" />    

     </apex:selectList>

 </Apex:form>
</apex:page>

 

is there any way to get the recent viewed records on a visualforce page?