• Vennila
  • NEWBIE
  • 34 Points
  • Member since 2013

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 17
    Replies

I'm new to VF and created my first VF extension:

 

public class LeadSalesActH {
    
    private final Lead ld;
    
    public LeadSalesActH(ApexPages.StandardController stdController) {
        this.ld = (Lead)stdController.getRecord();
    }

    public String getName() {
        return 'LeadSalesActH';
    }
        
    public Lead getLead() {
        return [select id, name, ownerid,
                    (select subject, whatid, whoid, activitydate, LVM__c, ownerid, lastmodifieddate from ActivityHistories 
                     where ownerid not in ('00530000000vpI1') order by activitydate DESC ) //filter out marketing actvities 
                from Lead
                where id = :ApexPages.currentPage().getParameters().get('id')];
    }

}

 I started on my test class but I'm getting stuck on the getLead() tests. Can someone put me in the right direction?

 

Test Class:

 

@isTest
private class ExtendObjectTest {

    static testmethod void constructorTest() {
        // set up some test data to work with
        Lead ld = new Lead(LastName='Test', Company='Test1', Status='New');
        insert ld;

        // start the test execution context
        Test.startTest();

        // set the test's page to your VF page (or pass in a PageReference)
        Test.setCurrentPage(Page.leadsales);

        // call the constructor
        LeadSalesActH controller = new LeadSalesActH(new ApexPages.StandardController(ld));

        // stop the test
        Test.stopTest();
    }

}

 

 

Hi ,

Please help me to resolve this below issue. its urgent.

I want to create case, after the lead is created from marketo.

For this, i wrote a trigger in after insert for lead.

The lead is successfully created from marketo. but the case is not created.

It is displaying this exception,Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, No selected contact: Contact ID: [ContactId].

But the same trigger is working fine and creating case for manually creating a lead and creating a lead through visualforce page.

And also, If i hardcoded the contactid in the trigger, its creating a case successfully. But Contact id is not a required field for case.

The only thing,it is not working for lead came from Maketo.

Thanks in Advance!






Hi,

 

I want to update the object field label through Apex and Visualforce page. 

 

Please help me. Thanks in Advance

  • September 30, 2013
  • Like
  • 0
Hi ,

Please help me to resolve this below issue. its urgent.

I want to create case, after the lead is created from marketo.

For this, i wrote a trigger in after insert for lead.

The lead is successfully created from marketo. but the case is not created.

It is displaying this exception,Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, No selected contact: Contact ID: [ContactId].

But the same trigger is working fine and creating case for manually creating a lead and creating a lead through visualforce page.

And also, If i hardcoded the contactid in the trigger, its creating a case successfully. But Contact id is not a required field for case.

The only thing,it is not working for lead came from Maketo.

Thanks in Advance!






Hi,

 

I'm trying to do an VF form using the folliwng code, however, the label of the inoput field is showing fine, but the field itself isn't, so there's nowehere to input text....

 

Any ideas?

 

<apex:page standardController="User">
<br/>
<apex:form >
<apex:pageBlock mode="edit">
<apex:pageBlockSection title="New Quote" columns="5">
<apex:inputField value="{!User.Name}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>

</apex:page>

Filed name:status date--Data type --dateime....i want to update this field -current date.. when i set formula -  today () or datimevalue(today()) or ... it shows error..incompitable datatype.........how to convert date time to date format....please help me

  • October 08, 2013
  • Like
  • 0

HI all,

I have created a VF page which have many sections. When ever the page is reloaded, the focus goes to the first section instead of the current section.

How to fix this issue?

Thanks in advance...

Hi all ,

 I have vf page with inputText ,selectlist,checkBoxes,selectRadio controlls now I need to disable or make readonly in single shot .( I mean if you want to disble a controll set disble = true , but in this case I need to have disable option in every controll )

 

Is there any other way to disable everything conditionally in single shot

I'm new to VF and created my first VF extension:

 

public class LeadSalesActH {
    
    private final Lead ld;
    
    public LeadSalesActH(ApexPages.StandardController stdController) {
        this.ld = (Lead)stdController.getRecord();
    }

    public String getName() {
        return 'LeadSalesActH';
    }
        
    public Lead getLead() {
        return [select id, name, ownerid,
                    (select subject, whatid, whoid, activitydate, LVM__c, ownerid, lastmodifieddate from ActivityHistories 
                     where ownerid not in ('00530000000vpI1') order by activitydate DESC ) //filter out marketing actvities 
                from Lead
                where id = :ApexPages.currentPage().getParameters().get('id')];
    }

}

 I started on my test class but I'm getting stuck on the getLead() tests. Can someone put me in the right direction?

 

Test Class:

 

@isTest
private class ExtendObjectTest {

    static testmethod void constructorTest() {
        // set up some test data to work with
        Lead ld = new Lead(LastName='Test', Company='Test1', Status='New');
        insert ld;

        // start the test execution context
        Test.startTest();

        // set the test's page to your VF page (or pass in a PageReference)
        Test.setCurrentPage(Page.leadsales);

        // call the constructor
        LeadSalesActH controller = new LeadSalesActH(new ApexPages.StandardController(ld));

        // stop the test
        Test.stopTest();
    }

}

 

 

 

I posted this in the Apex Code Board and didn't get an answer.
Maybe this is a more appropriate board for the question.

I have a simple visual force page listing case numbers with some details.

I have spent days searching for a way to let the user resort the columns on the page.

I found many discussions and lots of code attempting to do the same.

My question is:

Why can't I use the existing tools in SF? When in SF looking at cases in queves I can sort ascending and descending on columns.

I saw developers uploading up and down arrows images. Why do we need to do that if those images already exist in Sales Force?

Is there anyway to use the code and the images  that SF uses to resort columns in a visual page using apex?

 

if not can someone help me with this issue?

thanks.

Haya

  • October 03, 2013
  • Like
  • 0

Hi,

 

I have a picklist value (Asset ,opportunity) and also want that when asset is selescted beside that  i should get the Asset lookup .

This also goes for Opportunity.

 

For clarity you can refer the standard Task Object Field::RELATED TO:

 

The same way i want it.

 

Tahnks in Advance

  • October 03, 2013
  • Like
  • 0

I have a VF page which has a date field, i have a validation on it but its working in a standard way but its not working in VF page with class even after using page messages functionality.

Hi,

 

I am working on a requirement in which I am trying to insert a child record while creating the parent record.

 

My parent object is the Case Object and my child object is a Custom Object called People__c. Through the use of a Custom button, I would like to create a People__c record. Basically, when the user clicks the button on the case record, the user will be taken to the People__c object, all the necessary details can be filled in and once the people record is saved, the user will be redirected back to the case record that has not still been saved to the database.

 

I have never worked on a requirement like this before. Any suggestions or sample code would greatly help me out.

 

Thanks!

i created a picklist in visualforcepage with all the values of a mutilpicklist field from Course__c.

this is my code:

statusOptions = new List<SelectOption>();
        // Use DescribeFieldResult object to retrieve status field.
        Schema.DescribeFieldResult statusFieldDescription = Course__c.Year_Block__c.getDescribe();
        // For each picklist value, create a new select option
        for (Schema.Picklistentry picklistEntry: statusFieldDescription.getPicklistValues()) {
            statusOptions.add(new SelectOption( pickListEntry.getValue(),pickListEntry.getLabel()));
            // obtain and assign default value
            if (picklistEntry.defaultValue){
                course.Year_Block__c = pickListEntry.getValue();
            }  
        }     

 i want to show in the picklist only the multipicklist values of one record.

example:

all multipicklist field values= 1, 2, 3, 4, 5

one record: name=Test ; multipicklist values=1, 3, 5

how can i show only 1,3,5 in the created picklist in vfpage?

 

 

 

  • September 27, 2013
  • Like
  • 0

Hello All,

 

I have a requirement where I want to hide some fields from Edit layout of an object , while I want to display them in Detail Page. These fields will be populated by Trigger, but user should also have option to Edit some of the values if needed.

 

Thanks in Advance.

  • September 17, 2013
  • Like
  • 0

hi...

 

 I want to Create a Custom Lookup field for Account and fo Contact ,

  • After Selecting Account from 1st lookup field ,
  • when i click the 2nd lookup field for Selecting Contact it should display those contacts only related to the Account Selected .
  • if No account is being selected it should display all the Contacts ..

how to write Visualforce and controller for this ?

 

please help ..

 

email - sfdh1026@gmail.com

skype - sfdh1026

  • September 12, 2013
  • Like
  • 0

Hi there, 

 

I have a scenario in my org to Override the standard New Account creation page with a custom VF Page for certain record types. 

The VF Page should only appear for a set of record types and should not appear for the rest. For the rest of the record types the standard New Account page should appear. 

 

Please could you advise me on the design strategy I should go about in doing this? 

 

At the moment I am overriding the standard 'New' button in Account 

 

using the following VF Page

 

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

 

VF Code

<apex:pagetitle="New Account"standardController="Account"tabStyle="Account"extensions="New_Account_Controller"action="{!pullToPage}">

 

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Controller

 

public PageReference pullToPage(){

     PageReference pageRef;

     selectedRecordTypeId = ApexPages.currentPage().getParameters().get('RecordType');

     User currentUser = [SELECT Id, Name, UserRole.Name, Profile.Name FROM User WHERE Id =: UserInfo.getUserId() limit 1];

        

     if(selectedRecordTypeId == null){

          if(currentUser.Profile.Name.contains('GV')) {

                 accountRecTypeName='MY Account RT';

                 selectedRecordTypeId = [SELECT Id, Name FROM RecordType WHERE Name =: accountRecTypeName limit 1].Id;                

          }

     }else{

            accountRecTypeName = [SELECT Id,Name FROM RecordType WHERE Id =: selectedRecordTypeId limit 1].Name;

     }   

            

        if (accountRecTypeName == 'MY Account RT'){

            pageRef = null;

        }else if(selectedRecordTypeId != null){

            pageRef = new PageReference('/001/e?');

            pageRef.getParameters().put('RecordType', selectedRecordTypeId);

            pageRef.getParameters().put('nooverride', '1');

        }else{

            pageRef = new PageReference('/001/e?');

            pageRef.getParameters().put('nooverride', '1');

        }

        return pageRef;

    }

 

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

 

This seesms to work fine but given that I am working with a huge user base, this strategy seems to considerably reduce the preformance of other record type users.

Everytime a different recordtype other than MY Account RT is used, salesforce has to execute the above controller and then the user is redirected to the original standard page.

This is time consuming and seems to be an over kill given that we have to just override one record type among many.

 

Please could you suggest an alternative solution to this?

 

Many Thanks in Advance

 

Hello All,

 

I am currently working on a page which displays the Name of the payer and the payee details.

This is my VF Page code:

 

<apex:page controller="newExpenditureController" >
  
  <apex:pageBlock >
  <p>Welcome, <b>{!$User.FirstName} {!$User.LastName}</b></p>
  <p>Please select any following options to proceed</p>
  </apex:pageBlock>
  <!-- Section containing all the Action Buttons -->
  <apex:form >
  <apex:pageBlock title="Select Choice">
  <apex:pageBlockSection >
      <apex:commandButton action="{!addExpend}" value="Add Expenditure" disabled="{!b_addexp}"></apex:commandButton>
      <apex:commandButton action="{!closeAll}" value="Close All" disabled="{!b_cloall}"></apex:commandButton>
  </apex:pageBlockSection>
  </apex:pageBlock>
  </apex:form>
  
  <apex:pageBlock title="Create New Expenditure" mode="edit" rendered="{!addexp}">
  <apex:pageMessages />
  <apex:form >
  <apex:pageBlockSection columns="1">
  <apex:inputField value="{!bb.Date__c}"/>
  </apex:pageBlockSection>
  
  <apex:pageBlockSection columns="2" >
  <apex:inputField value="{!bb.Payed_By__c}" required="true" />
  <apex:inputField value="{!bb.Payed_For__c}" required="true" />
  </apex:pageBlockSection>
  
  <apex:pageBlockSection columns="2">
  <apex:inputField value="{!bb.Amount__c}"/>
  <apex:inputField value="{!bb.Description__c}" required="true"/>
  </apex:pageBlockSection>
  
  <apex:pageBlockSection >
  
  </apex:pageBlockSection>
  
  <!-- SAVE Option -->
  <center>
  <apex:pageBlockSection columns="1" showHeader="true">
  <apex:commandButton value="Save" action="{!save}"/>
  </apex:pageBlockSection>
  </center>
  
  </apex:form>
  </apex:pageBlock>
  <apex:form >
  <apex:pageBlock title="Current Details" mode="edit">
      <apex:dataTable value="{!Bill_Book}" var="bbc" width="100%">
      <apex:detail /> 
        <apex:column ><apex:facet name="header"><b>Payed By</b></apex:facet> {!bbc.Payed_By__c}</apex:column>
        <apex:column ><apex:facet name="header"><b>Payed For</b></apex:facet> {!bbc.Payed_For__c}</apex:column>
        <apex:column ><apex:facet name="header"><b>Amount</b></apex:facet> {!bbc.Amount__c}</apex:column>
        <apex:column ><apex:facet name="header"><b>Date</b></apex:facet> {!bbc.Date__c}</apex:column>
        <apex:column ><apex:facet name="header"><b>Description</b></apex:facet> {!bbc.Description__c}</apex:column>
        </apex:dataTable>
        </apex:pageBlock>
  </apex:form>
  
  
</apex:page>

 

And the following is my controller code:

 

public class newExpenditureController
{

    //Object Definition        
    public Boolean addexp {get; set;}
    public Boolean b_addexp {get; set;}
    public Boolean b_cloall {get; set;}
    public Bill_Book__c bb {get; set;}
    private final String RedirectUrl = 'https://c.ap1.visual.force.com/apex/New_Expenditure?sfdc.tabName=01r900000001gV7';
    ID id = null;   
    
    
    
    //Constructor    
    public newExpenditureController() 
    {
        Id id = ApexPages.currentPage().getParameters().get('id');    
        addexp = false;
        b_addexp = false;
        b_cloall = true;
        
        //object bb creation
        bb = new Bill_Book__c();       
    }
    
    public List<Bill_Book__c> getBill_Book()
    {
        return [SELECT
                    Payed_By__c,
                    Payed_For__c,
                    Amount__c,
                    Date__c,
                    Description__c
                    
                    FROM
                    
                    Bill_Book__c
                    
                    ORDER BY LastModifiedDate DESC LIMIT 10];
    }
    
    //Toggle Button
    public PageReference addExpend() 
    {
        //Page Access
        addexp = true;
        
        //Button access
        b_addexp = true;
        b_cloall = false;
       
        return null;
    }

    public Bill_Book__c getAccount() 
    {
        return bb;
    }
    
    public PageReference save() 
    {
        bb.Status__c = 'P';   
        try
        {
            upsert(bb);
        }
        catch(System.DMLException e) 
        {
            ApexPages.addMessages(e);
            return null;
        }
        return (redirectTab());
    }
    
    
    
    public PageReference closeAll() 
    {
        addexp = false;
                
        //Button access
        b_addexp = false;
        b_cloall = true;
        return null;
    }
    
    public String getName(String id)
    {    
        String name = null;
        name = [SELECT Name, Age__c FROM Person__c WHERE ID=:id].Name;
        return name;
    }
    
      
    public PageReference redirectTab()
    {          
       PageReference newPage = new PageReference(RedirectUrl);          
       newPage.setRedirect(true);  
       return newPage;  
    } 
        
}

 

This Object (Bill_Book__c ) has 2 lookup fields Payed_By__c and Payed_For__c, which link to another object Person__c through local relationship.

 

Currently this code provides me only the ID of the Payed By and Payed For details.

What I require is to display the First Name of these fields.

(First Name is a field of Person__c object)

 

Please help in this issue. Thanks.......... :)

I am trying to clone attachments from opportunities to a custom object.

Once I create the custom object from the opportunity page I would like to have all the attachments from the opportunity cloned in the new related record.

 

Any idea or sample code for this?

 Thank you!!!