• 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 people,

I have a scenario whereby am supposed to send an email notification to a contact for interview feedback once the interview end time has passed.How do i set the where clause for Interview_End_Date_Time__c to meet this criteria so that my scheduler will be fired & send the email as well as be able to get the record on which the field should be updated. So far i have the following as my rough trial. The problem with my code is that it seems to hit 'The authorization required page' after insert instead of returning the successful page & my record is not update.However when i use other specific fields with constant value instead of the time field,my record is successfully updated.How do i get the where clause right as well as get to update the right record based on the record id,considering i had a problem including the record id on my site.com url.

 

public with sharing class InterviewFeedbackController {
 
  public InterviewFeedbackController() {
    // blank constructor
  }
  public String intvName = ' ';   
        public Datetime dt = datetime.now(); 
        public List<Interviews_ATS__c> interv = [Select id,Name,Interview_Start_Date_Time__c,Interview_End_Date_Time__c,Client_Name__c,interview_level__c from Interviews_ATS__c where Interview_End_Date_Time__c = :dt];
  		
 public String userInput;
 public String getUserInput() {
 	return userInput;
 }  
 public void setUserInput(String userInp) {
 	this.userInput = userInp;
 }

 public PageReference submit() {  
 	List<Interviews_ATS__c> intv = [Select Id,Name,Interview_Start_Date_Time__c,Interview_End_Date_Time__c,Client_Name__c,interview_level__c from Interviews_ATS__c where Id = :interv[0].id];
 	
      if (!intv.isEmpty()) {
      	Interviews_ATS__c interview = intv[0];
      	
    	intv[0].Interview_Feedback__c = userInput;
    	update interview;
      }
      return Page.Interview_feedback_Note;
 }
 
  public void sendNotification() {    
        for(Integer i=0; i < interv.size(); i++){
            intvName += interv[i].Name +', ';
        }      
        if(interv.size() != 0){
        Messaging.Singleemailmessage email = new Messaging.Singleemailmessage();
        String [] toAddresses = New String[]{'xxx.xxx@xxx.com'};
        email.setSubject('Interview Feedback');
        email.setPlainTextBody('Kindly send me the interview feedback for interview:' +intvName+ 'Click the link https://xxx.sandbox1.cs3.force.com/interviewfeedbacks');
        email.setToAddresses(toAddresses);
        
        //Send the email
        Messaging.sendEmail(New Messaging.Singleemailmessage[]{email}); 
     
        
    }
    }
  
 
 
}

 scheduler class:

 

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

 

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();
	}
}

 

Hello,

I need advice on the available resume parsers,one which is easily integrated with salesforce and preferably one which can offer  API so that i can do the configuration by myself.

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.

 

I need to automate our new candidate creation process for candidates that we have resumes for. We would like to parse name, address,email,phone information from these Word/PDF documents and then pre-populate the relevant salesforce fields when creating new candidates.

Kindly advice me on the best approach to achieve this.

Hello,

Is there a way i can get the message id of emails sent using 'Send Email' Button in salesforce stored under 'Activity History'.I have researched and i can't seem to find any field on the Task object that stores the Message Id of the emails or under what object can i get this id?

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>

 

Hi people,

I have a drop down on my visualforce page with two picklist values(Add to Contact & Add to Associate).I would like each picklist value to redirect to a diffrent visualforce page based on the value selected. i.e If i select 'Add to Contact', it should take me to a visualforce page(/apex/AddToContact) and if i select 'Add to Associate', it should take me to a different visualforce page(/apex/AddToAssociate).

 

I have a controller that helps me in creating a new contact record using values from another custom object. The Contact Email field is supposed to be auto-filled with Emails field from another cutom object based on the If Statement in my controller.Everything works fine since when i create the new contact & leave the Email field blank & click save,the Email field on the newly created record contains the email value.My problem is making this value visible on my visualforce page before clicking save.

Here is a part of my controller & the visualforce pages for both Creating new Contact & my Custom object :

 

  public pageReference newContact() {
            PageReference newContact = new PageReference('/apex/CreateNewContact?id=' +unresolvedEmailId);
            newContact.getParameters().put('id',unresolvedEmailId);       
            newContact.setRedirect(true);
            return newContact;
        }    
    public PageReference saveContact() {
       String unRID = ApexPages.currentPage().getParameters().get('id');
    List<UnresolvedEmail__c> newContEmailAdd = [Select Id, Name,From__c,Assigned_to__c,owner.name FROM UnresolvedEmail__c   where  Id = :unRID ];
      if (newContEmailAdd[0].From__c == user.Email) {
         contact.Email = newContEmailAdd[0].Assigned_To__c;
      }      
     else if(newContEmailAdd[0].From__c != user.Email){      
      contact.Email=newContEmailAdd[0].from__c;
      }       
      insert contact; // inserts the new record into the database
 PageReference newPage = new PageReference('/'+contact.id); return newPage; }

Custom object VisualForce page:

<apex:page controller="UnresolvedEmailsController" >
<apex:form >
  <apex:pageBlock title="Unresolved Emails" mode="edit">
 <apex:pageBlockTable value="{!unresolvedEmails}" var="Emails" >
                 <apex:column >
                        <apex:facet name="header">Subject</apex:facet>
                        <apex:outputlink value="/{!Emails.id}">
                        <apex:outputField value="{!Emails.Name}"/>
                        </apex:outputlink>
                </apex:column>
                <apex:column >
                        <apex:facet name="header">From</apex:facet>
                        <apex:outputField value="{!Emails.From__c}"/>
                </apex:column>
                <apex:column >
                        <apex:facet name="header">Assigned To</apex:facet>
                        <apex:outputField value="{!Emails.Assigned_To__c}"/>
                </apex:column>
                <apex:column >
                        <apex:facet name="header">Owner</apex:facet>
                        <apex:outputField value="{!Emails.owner.name}"/>
                </apex:column>
                 <apex:column >
                        <apex:commandButton value="New Contact" action="{!newContact}" reRender="hiddenBlock">
                            <apex:param name="unresolvedEmailId"
                            value="{!Emails.id}"
                            assignTo="{!unresolvedEmailId}"/>
                        </apex:commandButton>
                        <apex:pageBlock id="hiddenBlock" rendered="false"></apex:pageBlock>               
                  </apex:column>
               </apex:pageBlockTable>
     </apex:pageBlock>
</apex:form>
</apex:page>

Create contact Visualforce page:

<apex:page controller="UnresolvedEmailsController">
  <apex:sectionHeader title="Visualforce Example" subtitle="Create a Contact"/>
   <apex:form >
    <apex:pageMessages /> <!-- this is where the error messages will appear -->
    <apex:pageBlock title="Contact Info">
       <apex:pageBlockButtons >
        <apex:commandButton action="{!saveContact}" value="Save"/>
      </apex:pageBlockButtons>
      <apex:pageBlockSection showHeader="false" columns="2">
        <apex:inputField value="{!contact.firstName}" />
        <apex:inputField value="{!contact.lastName}" />
        <apex:inputField value="{!contact.email}" />
      </apex:pageBlockSection>      
    </apex:pageBlock>
  </apex:form>
</apex:page> 

 How do i make the Contact email value visible when i click on 'Create Contact' button(which is on my Custom object Visualforce page)?

 

Am trying to write a test class for the following controller but i keep on getting this error: Error: Compile Error: Constructor not defined: [ListContactsController].<Constructor>(ApexPages.StandardSetController) at line 33 column 39

 

Below is my controller & the test class:

 

public class ListContactsController {

public List<Contact> contacts;

public ApexPages.StandardSetController setCtrl

    {
        get {
            if(setCtrl == null) {
                setCtrl = new ApexPages.StandardSetController(Database.getQueryLocator([Select Id, LastName,Email FROM Contact Order By LastName]));
                // sets the number of records in each page set
                setCtrl.setPageSize(10);
            }
            return setCtrl;
            
        }
     set;
    } 
    // indicates whether there are more records after the current page set.
    public Boolean hasNext {
        get {
            return setCtrl.getHasNext();
        }
        set;
    }
 
    // indicates whether there are more records before the current page set.
    public Boolean hasPrevious {
        get {
            return setCtrl.getHasPrevious();
        }
        set;
    }
 
    // returns the page number of the current page set
    public Integer pageNumber {
        get {
            return setCtrl.getPageNumber();
        }
        set;
    }
      
    // returns the first page of records
    public void first() {
        setCtrl.first();
    }
 
    // returns the last page of records
    public void last() {
        setCtrl.last();
    }
 
    // returns the previous page of records
    public void previous() {
        setCtrl.previous();
    }
 
    // returns the next page of records
    public void next() {
        setCtrl.next();
    }
 
    // returns the PageReference of the original page, if known, or the home page.
    public void cancel() {
        setCtrl.cancel();
    }
    
    public List<Contact> getContacts()
    {
        return (List<Contact>)setCtrl.getRecords();
    }
 
}

                                                

Test Class:

@IsTest
private class ListContactsTest{

static testMethod void testListContacts() {


 Contact con1 = new Contact(
                Lastname = 'test contact',
                Email = 'test@test.com');
         insert con1;
             
 Contact con2 = new Contact(
                Lastname = 'test contact2',
                Email = 'test@test2.com');
            insert con2;
            
 Contact con3 = new Contact(
                Lastname = 'test contact3',
                Email = 'test@test3.com');
        insert con3;
        
 List<Contact> cont = new List<Contact>();
 cont.add(con1);
 cont.add(con2);
 cont.add(con3);
 
 insert cont;
 
  PageReference pageRef = Page.listcontacts;
        Test.setCurrentPage(pageRef);
             
    ApexPages.StandardSetController ssc = new ApexPages.Standardsetcontroller(cont);
        ListContactsController ctrl = new ListContactsController(ssc); //line 33
        ssc.getHasNext();
        ssc.getHasPrevious();
        ssc.getPageNumber();
        ctrl.first();
        ctrl.getContacts();
        ctrl.last();
        ctrl.next();
        ctrl.previous();
    
  }
  }
 
 
 

 

 


Hi good people,

I have a visualforce page that displays a list of unresolved emails record.However,i would like each user to be able to view only his records i.e owner.name == user.name.Thus only view records that he/she owns.

Below is my visualforce page.

 

<apex:page controller="UnresolvedEmailsController" >
<apex:form >
  <apex:pageBlock title="Unresolved Emails" mode="edit">


 <apex:pageBlockTable value="{!unresolvedEmails}" var="Emails" >
 
                <apex:column >
                        <apex:facet name="header">Subject</apex:facet>
                        <apex:outputlink value="/{!Emails.id}">
                        <apex:outputField value="{!Emails.Name}"/>
                        </apex:outputlink>
                </apex:column>
                <apex:column >
                        <apex:facet name="header">From</apex:facet>
                        <apex:outputField value="{!Emails.From__c}"/>
                </apex:column>
                <apex:column >
                        <apex:facet name="header">Assigned To</apex:facet>
                        <apex:outputField value="{!Emails.Assigned_To__c}"/>
                </apex:column>
                <apex:column >
                        <apex:facet name="header">Owner</apex:facet>
                        <apex:outputField value="{!Emails.owner.name}"/>
                </apex:column>
                 <apex:column >
                        <apex:commandButton value="New Contact" action="{!newContact}" reRender="hiddenBlock">
                                               
                           <apex:param name="unresolvedEmailId"
                            value="{!Emails.id}"
                            assignTo="{!unresolvedEmailId}"/>
                        </apex:commandButton>
                        <apex:pageBlock id="hiddenBlock" rendered="false"></apex:pageBlock>               
                  </apex:column>
        </apex:pageBlockTable>
         
                  <apex:panelGrid columns="4" style="text-align: center; vertical-align: middle;">
                    <apex:commandLink action="{!first}">First</apex:commandlink>
                    <apex:commandLink action="{!previous}" rendered="{!hasPrevious}">Previous</apex:commandlink>
                    <apex:commandLink action="{!next}" rendered="{!hasNext}">Next</apex:commandlink>
                    <apex:commandLink action="{!last}">Last</apex:commandlink>
                </apex:panelGrid>
    </apex:pageBlock>
</apex:form>
</apex:page>

Hi good people,

I have a custom object Unresolvedemails__C which holds emails whose email addresses are not associated with any record in salesforce.I would therefore like a user to have the option of creating a new contact from these unresolved emails by selecting a record under unresolved emails list view.Once the record has been created,the unresolved email record should move from the unresolved emails object and be logged inside the Activity History object of the newly created contact record.

Here is a link with a screenshot of what i need for better understanding.

http://imagebin.org/204380

I have a trigger that inserts a new task to a custom object and one of the fields is the Assigned To field,  Is there a way that i can alter that field or is it READ ONLY.

Thanks..

Which kind of object is MyUnresolved Items?. I have a custom object called Candidates__c which has Main_Email__c as one of the fields, the problem is that when a Salesforce user(User with an account in salesforce) receives an email from a Candidate and the Salesforce user autoforwards the Email to salesforce using the Email to Salesforce generated url, the email is saved under the Unresolved Items, Is it possible to automatically assign the email to the specific custom object 'Candidates__c', lets say using a trigger which gets fired on 'after insert'. Anyone with an idea on how to go about this?!!

I have four custom buttons namely (Send NDA,Send UK NDA,UK Background Authorization & US background Authorization) in one of my custom object of which all their Content source are from visualforce pages. Since they appear to be too many buttons on a page layout, i would like to replace them with a single button namely (Send for Signing) whereby when clicked, it will load a page that will contain the four custom buttons & it is from this page that one can perform the diffrent actions carried out by the individual buttons.

 

Kindly advice me on how this can be achieved.

 



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?