• Praveen Bonalu
  • NEWBIE
  • 10 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 11
    Questions
  • 23
    Replies
Hi ,

I have written a visual force page and a controller  to search the records dynamically when the string is given in the box. 
I am not pretty much sure how to write a test class for it.

Here is the controller :
 
public with sharing class TW_SearchEngineController{
    
    public String selectedObject{get;set;}
    
    public pagereference retrieveObjName() {
        
        return null;
    }
    
    public String testresult{get; set; }

    private String queryFields_position = 'Branch__c,Department__c,Id,Name,Recruiter__c,Region__c,Status__c ';
    
    private String queryFields_applicant = 'City__c,Email__c,First_Name__c,Id,Last_Name__c,Position__c,Progess__c,Province__c ';
    
    private String queryFields_recruiting = 'Id,Confidential_Posting__c,Location__c,Name__c,Notes__c ';
    
    //Retrieve Applicant fields
    public String a_fName{get; set;}
    public String a_lName{get; set;}
    public String a_province{get; set;}
    
    //Retrive Position fields
    public String p_Title {get;set;}
    public String p_Dept  {get;set;}
    public String p_reg   {get;set;}
    
    //Retrive the Recruiting Resource fields
    public String r_ResName {get;set;}
    public String  r_ResLoc {get;set;}
    
    
    public pageReference retrieveApplicants() {
        system.debug('Applicant Entered');
        selectedObject = 'Applicant';
        runQuery();
        return null;
    }
      public pageReference retrievePositions() {
          system.debug('title: '+p_Title+' Dept: '+p_Dept+' region: '+p_reg);
          system.debug('Position Entered');
          selectedObject = 'Position';
          runQuery();
          return null;
    }
    
      public pageReference retrieveRecruitingResources() {
          system.debug('Recruiting Resources Entered');
          selectedObject = 'Recruiting Resources';
          runQuery();
          return null;
    }
    
    
    // get locations picklist values locations from recruiting Resources
    public List<SelectOption> getlocations() {
        List<SelectOption> options = new List<SelectOption>();
        
        Schema.DescribeFieldResult fieldResult = Job_Posting_Site__c.Location__c.getDescribe();
        List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
        
        for( Schema.PicklistEntry f : ple) {
            options.add(new SelectOption(f.getLabel(), f.getValue()));
        }       
        return options;
    }   
    
    // get regions picklist values from positions
    public List<SelectOption> getRegions() {
        List<SelectOption> options = new List<SelectOption>();
        
        Schema.DescribeFieldResult fieldResult = Position__c.Region__c.getDescribe();
        List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
        
        for( Schema.PicklistEntry f : ple) {
            options.add(new SelectOption(f.getLabel(), f.getValue()));
        }       
        return options;
    }
    
    // get regions picklist values from positions
    public List<SelectOption> getbranches() {
        List<SelectOption> options = new List<SelectOption>();
        
        Schema.DescribeFieldResult fieldResult = Position__c.Branch__c.getDescribe();
        List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
        
        for( Schema.PicklistEntry f : ple) {
            options.add(new SelectOption(f.getLabel(), f.getValue()));
        }       
        return options;
    }    
    
    //get department picklist values from position
    public List<SelectOption> getDepartments() {
        List<SelectOption> options = new List<SelectOption>();
        
        Schema.DescribeFieldResult fieldResult = Position__c.Department__c.getDescribe();
        List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
        
        for( Schema.PicklistEntry f : ple) {
            options.add(new SelectOption(f.getLabel(), f.getValue()));
        }       
        return options;
    }
    
    //get Type picklist values from Recruting Resources
    //
     public List<SelectOption> getRecRes() {
        List<SelectOption> options = new List<SelectOption>();
        
        Schema.DescribeFieldResult fieldResult = Job_Posting_Site__c.Type__c.getDescribe();
        List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
        
        for( Schema.PicklistEntry f : ple) {
            options.add(new SelectOption(f.getLabel(), f.getValue()));
        }       
        return options;
    }
    
    
    public List<Job_Posting_Site__c> rList {get; set;}
    public List<Candidate__c> aList {get; set;}
    public List<Position__c> pList {get; set;}
    
    
    public void runQuery() {
        system.debug('Entered runQuery');
        rList = new List<Job_Posting_Site__c>();
        aList = new List<Candidate__c>();
        pList = new List<Position__c>();
        system.debug('*****'+selectedObject);
        if(selectedObject == '--None--') {
            system.debug('None entered');
            if(aList != null)aList.clear();
            if(pList != null)pList.clear();
            if(rList != null)rList.clear();
        } else if(selectedObject == 'Applicant') {
            system.debug('Applicant entering');
            if(String.isEmpty(a_fName) && String.isEmpty(a_lName) && String.isEmpty(a_province)) return;
            system.debug('****'+(String.isEmpty(a_fName) || String.isEmpty(a_lName) || String.isEmpty(a_province)));
            setCon = null;
            //aList = Database.query('select '+queryFields_applicant + ' from Candidate__c limit 20');
            aList = (List<Candidate__c>) setCon.getRecords();
            
            if(pList != null)pList.clear();
            if(rList != null)rList.clear();
        } else if (selectedObject == 'Position'){
            system.debug('position entering1');
            system.debug('title: '+p_Title +' Dept: '+p_Dept+' Region: '+p_reg);
            if(String.isEmpty(p_Title) && String.isEmpty(p_Dept) && String.isEmpty(p_reg)) return;
            system.debug('position entering2');
            setCon = null;
            pList = (List<Position__c>) setCon.getRecords();
            //pList = Database.query('select '+queryFields_position + ' from Position__c limit 20');
            if(aList != null)aList.clear();
            if(rList != null)rList.clear();
        } else if (selectedObject == 'Recruiting Resources'){
            system.debug('Recruiting Resources entering');
            if(String.isEmpty(r_ResName) && String.isEmpty(r_ResLoc)) return;
            setCon = null;
            rList = (List<Job_Posting_Site__c>) setCon.getRecords();
            //rList = Database.query('select '+queryFields_recruiting + ' from Job_Posting_Site__c limit 20');
            if(pList != null)pList.clear();
            if(aList != null)aList.clear();
        }
        if(aList != null) system.debug('applicant records retrieved'+ aList.size());
        if(rList != null) system.debug('recruiting records retrieved'+ rList.size());
        if(pList != null) system.debug('position records retrieved'+ pList.size());
    }
     
    
    private String prepareQuery(String obj, String fields, String[] fieldNames, String[] fieldValues) {
        String str = '';
        Integer a = fieldNames.size();
        Integer b = fieldValues.size();
        if(a == b){
            str += 'Select '+fields+ ' from '+obj+' where ';
            for(Integer i = 0; i < a; i++){
                str += fieldNames[i] + ' like \''+fieldValues[i]+'%\' ';
                if(i != a-1) str+= ' and ';
            }
        }        
        return str;
    }
    
    
    
    public ApexPages.StandardSetController setCon {
    
        get {
            String soql = '';
            List<String> selectedFields = new List<String>();
            List<String> fieldValues = new List<String>();
            if(selectedObject == 'Applicant'){
                selectedFields = new String[]{'First_Name__c','Last_Name__c', 'Province__c'};
                fieldValues = new String[]{a_fName,a_lName,a_province};
                soql = prepareQuery('Candidate__c', queryFields_applicant, selectedFields, fieldValues);  
                system.debug('Applicant'+soql);
            } else if(selectedObject == 'Position') {
                selectedFields = new String[]{'name','Department__c', 'Region__c'};
                if(p_reg!= null) p_reg = p_reg.contains('None') ? '' : p_reg;
                if(p_Dept!= null) p_Dept = p_Dept.contains('None') ? '' : p_Dept;
                fieldValues = new String[]{p_Title,p_Dept,p_reg};
                soql = prepareQuery('Position__c', queryFields_position, selectedFields, fieldValues);                
            } else if(selectedObject == 'Recruiting Resources') {           
                selectedFields = new String[]{'Name__c'};
                fieldValues = new String[]{r_ResName};
                soql = prepareQuery('Job_Posting_Site__c', queryFields_recruiting, selectedFields, fieldValues);                
            }

            if(setCon == null) {
                try{
                    system.debug('soql prepared: '+soql);
                    setCon = new ApexPages.StandardSetController(Database.getQueryLocator(soql));  
                    setCon.setPageSize(5);
                } catch (Exception e){
                    system.debug(e.getMessage());
                }
            }
            return setCon;
        }
        set;
    }      
       
    // returns the first page of records
     public void first() {
         setCon.first();
         if (selectedObject == 'Position')pList = setCon.getRecords();
         else if (selectedObject == 'Recruiting Resources')rList = setCon.getRecords();
         else if (selectedObject == 'Applicant')aList = setCon.getRecords();
     }

     // returns the last page of records
     public void last() {
         setCon.last();
         if (selectedObject == 'Position')pList = setCon.getRecords();
         else if (selectedObject == 'Recruiting Resources')rList = setCon.getRecords();
         else if (selectedObject == 'Applicant')aList = setCon.getRecords();
     }

     // returns the previous page of records
     public void previous() {
         setCon.previous();
         if (selectedObject == 'Position')pList = setCon.getRecords();
         else if (selectedObject == 'Recruiting Resources')rList = setCon.getRecords();
         else if (selectedObject == 'Applicant')aList = setCon.getRecords();
     }

     // returns the next page of records
     public void next() {
         setCon.next();
         if (selectedObject == 'Position')pList = setCon.getRecords();
         else if (selectedObject == 'Recruiting Resources')rList = setCon.getRecords();
         else if (selectedObject == 'Applicant')aList = setCon.getRecords();
     }

    public list<Schema.Picklistentry> getEntries(){
        return Position__c.fields.Region__c.getDescribe().getpicklistvalues();
    }
 
}


 
Hi every one,

I am not able to get the code coverage for the following test class.

Can anyone please help me  in code coverage.

I am not sure where i am doing wrong.

Please see below test class i have written for the Email services inbound handler.
@isTest
public class ProcessJobApplicantEmail_Test {
    
  
    static testMethod  void TestApplicant()
    {
         // Create a new email and envelope Object
        Messaging.InboundEmail email = new Messaging.InboundEmail();
        Messaging.InboundEnvelope env = new Messaging.InboundEnvelope();
        
        //setup the data for the email 
        email.subject='Test Job Application';
        email.fromname='Mike Villo';
        email.fromAddress='Test@gmail.com';
        
        //add an attachment 
        
        Messaging.InboundEmail.binaryAttachment attachment = new Messaging.InboundEmail.binaryAttachment();
        attachment.body=blob.valueOf('Test Job Application');
        attachment.filename='testfile.pdf';
        attachment.mimeTypeSubType = 'text/plain';
        
        email.binaryAttachments = new Messaging.inboundEmail.BinaryAttachment[] { attachment };
        
        ProcessJobApplicantEmail emailProcess = new ProcessJobApplicantEmail();
        emailProcess.handleInboundEmail(email, env);
  
             
        Candidate__c can =[select id, First_Name__c, Last_Name__c, Email__c from Candidate__c
         where First_Name__c = 'Mike' and Last_Name__c = 'Villo' and Email__c='Test@gmail.com' and Province__c='Ontario'];
        
        System.assertEquals(can.First_Name__c,'Mike');
        System.assertEquals(can.Last_Name__c,'Villo'); 
        System.assertEquals(can.Email__c,'Test@gmail.com');
        
        Attachment a = [select name from attachment where parentId = :can.id];
        System.assertEquals(a.name,'testfile.pdf');
    }

}

 
Hi Everyone,

I have a custom Object (Candidate ) with the status picklist values 

Possible candidate
Forwarded to manager
Phone screen
Interview
References
Medical Assessment
Background Check
Offer
Hired
Declined Offer


I would like to have the horizontail Time line with all this values in the visual force page. that depend on the Status picklist value

(EX: By default the satus of the candidate would be "possible candidate" and when the status is changed to "forwarded to manager" the image should move to that status on the time line.)

I would like to use Jquery or javascritp to achive this feature .or please provide me the resourses

If anyone has an idea how to achive this function .

Horizontal Time Line
I Have tried to Access the Account Team Members from the contact record and i am not able to achieve it.
How would I Query the AccountTeamMembers from the Contact Object

MY VF:
 
<apex:page controller="MyProfilePageController">  
    <apex:form id="theForm"> 
           <apex:pageBlock title="{!$Label.site.my_profile}">
            <apex:pageBlockSection columns="1" title="My Team">
                <apex:pageBlockTable value="{!myTeam}" var="r">
                    <apex:column value="{!r.Account.Name}"/>
                    <apex:column value="{!r.Phone}"/>
                    <apex:column value="{!r.Email}"/>
                </apex:pageBlockTable>
            </apex:pageBlockSection>
           </apex:pageBlock>
     </apex:form>

Controller 
 
public class MyProfilePageController {

    private User user;
    public List<Contact> myTeam { get; set; }

	public User getUser() {
        return user;
    }

    public MyProfilePageController() {
        user = [SELECT id, email, username, usertype,firstname, lastname, phone, title,
                street, city, country, postalcode, state, localesidkey, mobilephone, extension, fax,
                WHERE id = :UserInfo.getUserId()];
       myTeam = [Select Id, Account.Name, FirstName, LastName, Title, Phone, Email from Contact where AccountId=:user.Contact.AccountId  ORDER BY Name ASC];
        
        
    }

    }

 
Hi ,

I would like to retrive the Account team members for an account and display in the visual force page .I need to access this information from the contact record .

Can any one help me with this requirement .

Thanks
Praveen 
Hi,

I need to display the graphical  reports  in the community portal,where i need to pass the dynamic filters to pull the information and show it on portal .when the user see the report he should be able to view only his Account  information reports to which he belongs to .

I have tried :
 
apex:page standardController="Account">
<apex:image title="Reports" url="{!$Resource.Report_Image}" width="50" height="50" / ><br/><br/><br/>
    <analytics:reportChart cacheResults="false" reportId="00OM0000000h0E0"
        filter="[{column:'ACCOUNT_ID',operator:'equals',value:'{!Id}'}]"
        size="tiny">
    </analytics:reportChart>
</apex:page>

But shows no results.Can any one please let me know how to write a visual force page to expose the reports (In visual ).

Thanks
Praveen 
Hi ,

My user running his mobile Salesforce1 then showing this Error.

"There's a problem saving this record. You might not have permission to edit, or might have been deleted or archived."

​I also checked his profile, he is Salesforce 1 User. How can help this user to edit/ Save  via Salesforce1 on the case ?
Hi experts,

I have 5 phone fileds 

1)home phone
2)cellphone
3)work phone
4)reference1phone
5)reference 2 phone.

None of the filelds should have the same number .Is it possible to display the error through the validation rule if the fileds have same number 


Thanks
Praveen
Hi ,

I have written a javascript button to create a record on salesforce .when the user clicks once on the button the record is created .but he clicks again on the button another record is created.

I just dont want the user to click the button again and create a duplicate record.Is there any other way to disable the button after the user clicks once or else if the record is already created .he needs to be prompted  that  the record is already exixts.
 
{!requireScript("/soap/ajax/26.0/connection.js")} 

var req = new sforce.SObject("Candidate__c"); 
req.Id = "{!Candidate__c.Id}"; 
req.Job_Application__c="True"; 
req.Recruiting_Status__c="Possible Candidate" 
var aResult = sforce.connection.update([req]); 
if (aResult[0].getBoolean("success")) { 
console.log("Candidate Update Successful"); 
} 
var newJob = new sforce.SObject("Job_Application__c"); 
newJob.Candidate__c= "{!Candidate__c.Id}"; 
newJob.Position__c= "{!Candidate__c.PositionId__c}"; 
newJob.Status__c="open"; 

var cResult = sforce.connection.create([newJob]); 
if ( cResult[0].getBoolean( "success" ) ) 
{ 
alert("Candidate Created Sucessfully "); 
window.location.reload(); 
} 

else 
{ 
alert( cResult[0].errors.message); 
}

 
Here is my requirement

1)In a day we have 2 sessions.In the morning session once click on[clock IN Button] Time starts counting.

2)In the lunch time if i click on [click Pause button] it should stop recording the time.

3)On a Click of log out at evening[click logout button] . On the same click of logout button insert the record taking difference of duration and also use user info to identify the User in a custom object

So that we can calculate the Employees productive hours of working.

How can i Achieve this Functionality in salesforce

Please Share the Ideas.
1) I have an HTML Form that post all the gathered information(I.e when the user enters the details and clicks on submit )it will post to the to the Php file for processing

2) The problem is when i am not passing any value to the date Fields I am getting the below error.

Errors: For date fields: is not a valid value for the type xsd:date

How can i make my Post to accept the Null value for the fields and have a successfully submit.

Form.html
<html xmlns="http://www.w3.org/1999/xhtml">

<body>
    <form class="form-horizontal" action="CandidateCreationPage.php" method="post" enctype="multipart/form-data">
        <!-- INFORMATION -->
        <div style="width:100%;background:#193b80;color:#fff;">
            <label style="padding:5px 0 0 15px">Information</label>
        </div>
        <div class="container">
            <div class="col-lg-6 col-md-6">
                <table class="form-table">
                    <tbody>
                        <tr>
                            <td class="label-cell"><label>First Name <span class="required-input letters-only">*</span></label></td>
                            <td>
                                <input class="required-field letters-only" type="text" name="firstname" id="first-name" maxlength="25" />
                            </td>
                        </tr>
                        <tr>
                            <td class="label-cell"><label>Last Name <span class="required-input">*</span></label></td>
                            <td>
                                <input class="required-field letters-only" type="text" name="lastname" id="last-name" maxlength="30" />
                            </td>
                        </tr>
                        <tr>
                            <td class="label-cell"><label>How Did You Learn of This Opportunity? <span class="required-input">*</span></label></td>
                            <td>
                                <select class="required-field" id="hear-this-opportunity" name="hearthisopportunity">
                                    <option value="">--None--</option>
                                    <option value="Kijiji">Kijiji</option>
                                    
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td class="label-cell"><label>Please Specify (If Applicable) <span id="please-specify-asterisk" class="required-input hide">*</span></label></td>
                            <td>
                                <input class="letters-only" type="text" name="pleasespecify" id="please-specify" maxlength="50" />
                            </td>
                        </tr>
                        <tr>
                            <td class="label-cell"><label>Status</label></td>
                            <td>
                                <select id="status" name="status">
                                    <option value="">--None--</option>
                                    <option value="Full-time">Full-time</option>
                                    <option value="Part-time">Part-time</option>
                                    
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td class="label-cell"><label>Have You Worked With Us Before?</label></td>
                            <td>
                                <select id="worked-previously" name="workedpreviously">
                                    <option value="">--None--</option>
                                    <option value="Yes">Yes</option>
                                    <option value="No">No</option>
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td class="label-cell"><label>When (If Applicable)</label></td>
                            <td>
                                <input type="date" name="workedpreviouslywhen" id="worked-previously-when" />
                            </td>
                        </tr>
                        <tr>
                            <td class="label-cell"><label>Available to Start</label></td>
                            <td>
                                <input type="date" name="availabletostart" id="available-to-start" />
                            </td>
                        </tr>
                        <tr>
                            <td class="label-cell"><label>Position <span class="required-input">*</span></label></td>
                            <td>
                                <select class="required-field" id="position" name="position">
                                    <option value="">--None--</option>
                                    <option value="driver">Driver</option>
                                    <option value="technician">Technician</option>
                                </select>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>
            <div class="col-lg-6 col-md-6">
                <table class="form-table">
                    <tbody>
                        <tr>
                            <td class="label-cell"><label>Primary Contact Number <span class="required-input">*</span></label></td>
                            <td>
                                <input class="required-field" type="tel" name="primarycontactnumber" id="primary-contact-number" maxlength="15" />
                            </td>
                        </tr>
                        <tr>
                            <td class="label-cell"><label>Secondary Contact Number</label></td>
                            <td>
                                <input type="text" name="secondarycontactnumber" id="secondary-contact-number" maxlength="15" />
                            </td>
                        </tr>
                        <tr>
                            <td class="label-cell"><label>Email</label></td>
                            <td>
                                <input type="email" name="email" id="email" maxlength="30" />
                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>
        <!-- ADDRESS INFORMATION -->
        <div style="width:100%;background:#193b80;color:#fff;">
            <label style="padding:5px 0 0 15px">Address Information</label>
        </div>

        <div class="container">
            <div class="col-lg-6 col-md-6">
                <table class="form-table">
                    <tbody>
                        <tr>
                            <td class="label-cell"><label>Street Address 1</label></td>
                            <td>
                                <input type="text" name="streetaddressone" id="street-address-one" maxlength="30" />
                            </td>
                        </tr>
                        <tr>
                            <td class="label-cell"><label>Street Address 2</label></td>
                            <td>
                                <input type="text" name="streetaddresstwo" id="street-address-two" maxlength="30" />
                            </td>
                        </tr>
                        <tr>
                            <td class="label-cell"><label>Province <span class="required-input">*</span></label></td>
                            <td>
                                <input class="required-field letters-only" type="text" name="province" id="province" maxlength="25" />
                            </td>
                        </tr>
                        <tr>
                            <td class="label-cell"><label>City <span class="required-input">*</span></label></td>
                            <td>
                                <input class="required-field letters-only" type="text" name="city" id="city" maxlength="50" />
                            </td>
                        </tr>
                        <tr>
                            <td class="label-cell"><label>Country</label></td>
                            <td>
                                <input type="text" name="country" id="country" maxlength="50" />
                            </td>
                        </tr>
                        <tr>
                            <td class="label-cell"><label>Postal Code</label></td>
                            <td>
                                <input type="text" name="postalcode" id="postal-code" maxlength="7" />
                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>
        <!-- WORK EXPERIENCE -->
        <div style="width:100%;background:#193b80;color:#fff;">
            <label style="padding:5px 0 0 15px">Work Experience</label>
        </div>
        <div class="container">
            <div class="col-lg-6 col-md-6">
                <table class="form-table">
                    <tbody>
                        <tr>
                            <td class="label-cell"><label>Currently Employed?</label></td>
                            <td>
                                <input type="checkbox" name="currentlyemployed" id="currently-employed" />
                            </td>
                        </tr>
                        <tr>
                            <td class="label-cell"><label>Currently Employer</label></td>
                            <td>
                                <input type="text" name="currentemployer" id="current-employer" maxlength="50" />
                            </td>
                        </tr>
                        <tr>
                            <td class="label-cell"><label>Start Date</label></td>
                            <td>
                                <input type="date" name="startdateone" id="start-date-one" />
                            </td>
                        </tr>
                        <tr id="end-date-row">
                            <td class="label-cell"><label>End Date</label></td>
                            <td>
                                <input type="date" name="enddateone" id="end-date-one" />
                            </td>
                        </tr>
                        <tr>
                            <td class="label-cell"><label>Rate of Pay</label></td>
                            <td>
                                <input type="number" name="rateofpayone" id="rate-of-pay-one" maxlength="20" />
                            </td>
                        </tr>
                    </tbody>
                </table>

                <table class="form-table" style="padding-top:25px;">
                    <tbody>
                        <tr>
                            <td class="label-cell"><label>Previous Employer</label></td>
                            <td>
                                <input type="text" name="previousemployertwo" id="previous-employer-two" maxlength="50" />
                            </td>
                        </tr>
                        <tr>
                            <td class="label-cell"><label>Start Date</label></td>
                            <td>
                                <input type="date" name="startdatetwo" id="start-date-two" />
                            </td>
                        </tr>
                        <tr>
                            <td class="label-cell"><label>End Date</label></td>
                            <td>
                                <input type="date" name="enddatetwo" id="end-date-two" />
                            </td>
                        </tr>
                        <tr>
                            <td class="label-cell"><label>Rate of Pay</label></td>
                            <td>
                                <input type="number" name="rateofpaytwo" id="rate-of-pay-two" maxlength="20" />
                            </td>
                        </tr>
                        <tr>
                            <td class="label-cell"><label>Reason for Leaving</label></td>
                            <td>
                                <textarea name="reasonforleavingtwo" id="reason-for-leaving-two" maxlength="100"></textarea>
                            </td>
                        </tr>
                    </tbody>
                </table>

                <table class="form-table" style="padding-top:25px;">
                    <tbody>
                        <tr>
                            <td class="label-cell"><label>Previous Employer</label></td>
                            <td>
                                <input type="text" name="previousemployerthree" id="previous-employer-three" maxlength="50" />
                            </td>
                        </tr>
                        <tr>
                            <td class="label-cell"><label>Start Date</label></td>
                            <td>
                                <input type="date" name="startdatethree" id="start-date-three" />
                            </td>
                        </tr>
                        <tr>
                            <td class="label-cell"><label>End Date</label></td>
                            <td>
                                <input type="date" name="enddatethree" id="end-date-three" />
                            </td>
                        </tr>
                        <tr>
                            <td class="label-cell"><label>Rate of Pay</label></td>
                            <td>
                                <input type="number" name="rateofpaythree" id="rate-of-pay-three" maxlength="20" />
                            </td>
                        </tr>
                        <tr>
                            <td class="label-cell"><label>Reason for Leaving</label></td>
                            <td>
                                <textarea name="reasonforleavingthree" id="reason-for-leaving-three" maxlength="100"></textarea>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>
        <!-- EDUCATION/QUALIFICATIONS -->
        <div style="width:100%;background:#193b80;color:#fff;">
            <label style="padding:5px 0 0 15px">Education / Qualifications</label>
        </div>
        <div class="container">
            <div class="col-lg-6 col-md-6">
                <table class="form-table">
                    <tbody>
                        <tr>
                            <td class="label-cell"><label>Highest level of Education Obtained</label></td>
                            <td>
                                <select id="higher-education" name="highereducation">
                                    <option value="">--None--</option>
                                    <option value="University Degree">University Degree</option>
                                    <option value="College Diploma">College Diploma</option>
                                    <option value="Post-Grad Degree">Post-Grad Degree</option>
                                    <option value="High School">High School</option>
                                </select>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>
            <div class="col-lg-6 col-md-6">
                <table class="form-table">
                    <tbody>
                        <tr>
                            <td class="label-cell"><label>Licenses & Certifications</label></td>
                            <td>
                                <select id="licenses-and-certs" name="licensesandcerts" multiple="multiple">
                                    <optgroup label="Available">
                                        <option value="Forklift License">Forklift License</option>
                                        <option value="Technician License">Technician License</option>
                                        <option value="Apprentice">Apprentice</option>
                                        <option value="Valid Driver's License">Valid Driver's License</option>
                                        <option value="First Aid Training">First Aid Training</option>
                                    </optgroup>
                                </select>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>

candidate.PHP
 
<?php
define("TOKEN_URL", "");
define("USERNAME", "");
define("PASSWORD", "");
define("SECURITY_TOKEN", "");
define("CLIENT_ID","");
define("CLIENT_SECRET","");
require_once ('soapclient/SforcePartnerClient.php');
$mySforceConnection = new SforcePartnerClient();
$mySforceConnection->createConnection("Partner.xml");
$mySforceConnection->login(USERNAME, PASSWORD.SECURITY_TOKEN);
 
			
	$params = "grant_type=password&client_id=".CLIENT_ID

        . "&client_secret=" .CLIENT_SECRET . "&username=" . USERNAME
        . "&password=" . PASSWORD . SECURITY_TOKEN;
        //Get Access token
        $ch = curl_init(TOKEN_URL);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_HEADER, false);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $params);

        $json_response = curl_exec($ch);

        $status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
        curl_close($ch);

        $response = json_decode($json_response, true);
        $access_token = $response['access_token'];
        $instance_url = $response['instance_url'];
		//var_dump($access_token);
		//var_dump( $instance_url);
		
?>
<div id="wrapper">
	<div id="page">
		<div id="page-bgtop">
			<div id="page-bgbtm">
				<div id="content">
					<div class="post">
						<div style="clear: both;">&nbsp;</div>
						<div class="entry">
								<a href="javascript:void(0);">							
								</a>							
								<?php
session_start();
if(isset($_POST["captcha"])&&$_POST["captcha"]!=""&&$_SESSION["code"]==$_POST["captcha"])
{
$query = "SELECT Id,Name,Status__c FROM Position__c WHERE  Name='".$_POST['position']."' LIMIT 1";
$response = $mySforceConnection->query($query);
$queryResult = new QueryResult($response);
if(isset($_POST['submit']))
{
try{
$fields = array (
'First_Name__c' => $_POST['firstname'],
'Last_Name__c' => $_POST['lastname'],
'Primary_contact_number__c'=>$_POST['primarycontactnumber'],
'Secondary_contact_number__c'=>$_POST['secondarycontactnumber'],
'Email__c'=> $_POST['email'],
'How_did_you_learn_of_this_Opportunity__c'=>$_POST['hearthisopportunity'],
'Please_Specify__c'=>$_POST['pleasespecify'],
'Status__c'=>$_POST['status'],
'Have_you_worked_with_us_before__c'=>$_POST['workedpreviously'],
'When__c'=>$_POST['workedpreviouslywhen'],
'Available_to_start__c'=>$_POST['availabletostart'],
'Position__c'=>$queryResult->records[0]->Id[0],									
'Street_Address_1__c'=>$_POST['streetaddressone'],
'Street_Address_2__c'=>$_POST['streetaddresstwo'],
'Province__c'=>$_POST['province'],
'City__c'=>$_POST['city'],
'Country__c'=>$_POST['country'],
'Postal_Code__c'=>$_POST['postalcode'],
'Currently_Employed__c'=>intval($_POST['currentlyemployed']),
'Current_Employer__c'=>$_POST['currentemployer'],
'Start_Date_Work_Exp1__c'=>$_POST['startdateone'],
'End_Date_Work_EXP_End1__c'=>$_POST['enddateone'],
'Rate_of_Pay_1__c'=>$_POST['rateofpayone'],
'Previous_Employer__c'=>$_POST['previousemployertwo'],
'Start_Date_Prev_Work_1__c'=>$_POST['startdatetwo'],
'End_Date_Prev_Wor_END_1__c'=>$_POST['enddatetwo'],
'Rate_of_Pay_2__c'=>$_POST['rateofpaytwo'],
'Reason_for_Leaving__c'=>$_POST['reasonforleavingtwo'],
'Previous_Employer_1__c'=>$_POST['previousemployerthree'],
'Start_Date_Prev_Work_2__c'=>$_POST['startdatethree'],
'End_Date_Prev_Wor_END_2__c'=>$_POST['enddatethree'],
'Rate_of_Pay_3__c'=>$_POST['rateofpaythree'],
'Reason_for_Leaving_1__c'=>$_POST['reasonforleavingthree'],
'Higher_Education__c'=>$_POST['highereducation'],
'Licenses_Certfications__c'=>$_POST['licensesandcerts'],												
	);
															
						
var_dump($fields);
 $sObject = new SObject();
 $sObject->fields = $fields;
 $sObject->type = 'Candidate__c';
 echo "**** Creating the following:\r\n";
 $createResponse = $mySforceConnection->create(array($sObject));
										 // print_r($createResponse);

} catch (Exception $e) {
echo $mySforceConnection->getLastRequest();
echo $e->faultstring;
	}
//Get the record id from last insert call and use that to make attachment call
$recordid = $createResponse[0]->id;

 
Any one can suggest any PDF or Example on Web Services and Salesforce Integration?
i am going through few PDF's and links but not able to get hands on practise  properly how to use SOAP, REST,WSDL step by step?
Is any Practical example step by step?
Hi Everyone,

I have a custom Object (Candidate ) with the status picklist values 

Possible candidate
Forwarded to manager
Phone screen
Interview
References
Medical Assessment
Background Check
Offer
Hired
Declined Offer


I would like to have the horizontail Time line with all this values in the visual force page. that depend on the Status picklist value

(EX: By default the satus of the candidate would be "possible candidate" and when the status is changed to "forwarded to manager" the image should move to that status on the time line.)

I would like to use Jquery or javascritp to achive this feature .or please provide me the resourses

If anyone has an idea how to achive this function .

Horizontal Time Line
I Have tried to Access the Account Team Members from the contact record and i am not able to achieve it.
How would I Query the AccountTeamMembers from the Contact Object

MY VF:
 
<apex:page controller="MyProfilePageController">  
    <apex:form id="theForm"> 
           <apex:pageBlock title="{!$Label.site.my_profile}">
            <apex:pageBlockSection columns="1" title="My Team">
                <apex:pageBlockTable value="{!myTeam}" var="r">
                    <apex:column value="{!r.Account.Name}"/>
                    <apex:column value="{!r.Phone}"/>
                    <apex:column value="{!r.Email}"/>
                </apex:pageBlockTable>
            </apex:pageBlockSection>
           </apex:pageBlock>
     </apex:form>

Controller 
 
public class MyProfilePageController {

    private User user;
    public List<Contact> myTeam { get; set; }

	public User getUser() {
        return user;
    }

    public MyProfilePageController() {
        user = [SELECT id, email, username, usertype,firstname, lastname, phone, title,
                street, city, country, postalcode, state, localesidkey, mobilephone, extension, fax,
                WHERE id = :UserInfo.getUserId()];
       myTeam = [Select Id, Account.Name, FirstName, LastName, Title, Phone, Email from Contact where AccountId=:user.Contact.AccountId  ORDER BY Name ASC];
        
        
    }

    }

 
Hi ,

I would like to retrive the Account team members for an account and display in the visual force page .I need to access this information from the contact record .

Can any one help me with this requirement .

Thanks
Praveen 
Hi,

I need to display the graphical  reports  in the community portal,where i need to pass the dynamic filters to pull the information and show it on portal .when the user see the report he should be able to view only his Account  information reports to which he belongs to .

I have tried :
 
apex:page standardController="Account">
<apex:image title="Reports" url="{!$Resource.Report_Image}" width="50" height="50" / ><br/><br/><br/>
    <analytics:reportChart cacheResults="false" reportId="00OM0000000h0E0"
        filter="[{column:'ACCOUNT_ID',operator:'equals',value:'{!Id}'}]"
        size="tiny">
    </analytics:reportChart>
</apex:page>

But shows no results.Can any one please let me know how to write a visual force page to expose the reports (In visual ).

Thanks
Praveen 
Hi ,

I have written a javascript button to create a record on salesforce .when the user clicks once on the button the record is created .but he clicks again on the button another record is created.

I just dont want the user to click the button again and create a duplicate record.Is there any other way to disable the button after the user clicks once or else if the record is already created .he needs to be prompted  that  the record is already exixts.
 
{!requireScript("/soap/ajax/26.0/connection.js")} 

var req = new sforce.SObject("Candidate__c"); 
req.Id = "{!Candidate__c.Id}"; 
req.Job_Application__c="True"; 
req.Recruiting_Status__c="Possible Candidate" 
var aResult = sforce.connection.update([req]); 
if (aResult[0].getBoolean("success")) { 
console.log("Candidate Update Successful"); 
} 
var newJob = new sforce.SObject("Job_Application__c"); 
newJob.Candidate__c= "{!Candidate__c.Id}"; 
newJob.Position__c= "{!Candidate__c.PositionId__c}"; 
newJob.Status__c="open"; 

var cResult = sforce.connection.create([newJob]); 
if ( cResult[0].getBoolean( "success" ) ) 
{ 
alert("Candidate Created Sucessfully "); 
window.location.reload(); 
} 

else 
{ 
alert( cResult[0].errors.message); 
}

 

Hi All,

 

I want to create a custom field whose field label is very long. I do not know how to increase the field label size. I checked custom label. but in the help it says we can access custom label throgh Apex or VisualForce. If anyone has an idea how to have longer field labels please help me. Your help is greatly appreciated.

 

Thank you,

Assh

  • August 02, 2010
  • Like
  • 0