• Manidipa
  • NEWBIE
  • 0 Points
  • Member since 2011

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

Hi All,


I am having a requirement where I need to get the input field values from a visualforce page to a standard new/edit page on click of a button.I have created a visualforce page with a button,and on that button click I am redirecting it to new object page.But I am not able to get the input fields from the visualforce page to the create new record page.Can you please help on this.

 

 

On click of the button New Donor it should redirect to the new Donor Creation page and the Donor Name and Email values should be auto populated.Please find the code below.


<apex:page standardController="Donor_Aarthi__c" extensions="DonorSearchAarthiController" sidebar="false">

      <apex:pageMessages /> <!-- Used to display all error messages -->
 
      <apex:pageBlockSection id="section" >
      
        <!--Input fields for name and email -->
        <apex:pageBlockSectionItem id="item1" >
          <apex:outputLabel for="searchText">Donor Name</apex:outputLabel>
          <apex:panelGroup >
          <apex:inputText id="searchText" value="{!searchText}"/>
          <br /> <br />
          </apex:panelGroup>
        </apex:pageBlockSectionItem><br />
        
        <apex:pageBlockSectionItem id="item2" >
          <apex:outputLabel for="searchText1">Email</apex:outputLabel>
          <apex:panelGroup id="panel" >
          <apex:inputText id="searchText1" value="{!searchText1}"/>
          <br /> <br />
          <br /> <br />
           
          <!--Command buttons for search and reset -->
          <apex:commandButton value="Search"  id="searchbtn" action="{!search}" rerender="block" status="status"/>
          <apex:commandButton value="Reset" action="{!reset}" rerender="block" status="status"/>
          <apex:commandButton value="New Donor" onclick="window.open('/a0U/e?retURL=%2Fa0U%2Fo');" rerender="block" status="status"/>

 

Hi

I have created an object called travel request and created 2 validation rules on that object.I am using one VF page and 1 controller for it.When we are creating 1 record the validations are working fine and we are getting the error messages on the VF page,but when we are cloning the record the error messages are not showing on the page,though the validation rules are working because it is not saving the record and it is styaing in the same page.We cannot write custom validations on the apex class because the requirement is to use the standard validations strictly.Please help,it is  really urgent ..I am posting the VF code and the apex class code below:

 

The VF page

 

<apex:page standardController="Travel_Request__c" id="page1"  extensions="TravelRequest_SaveExt">
    <apex:form >
   
          <apex:pageBlock title="Travel Request Edit" mode="edit" id="pb1">
            <apex:pageBlockButtons location="top">
                <apex:commandButton action="{!save}" value="Save"/>
                <apex:commandButton action="{!cancel}" value="Cancel"/>
            </apex:pageBlockButtons>
            <apex:pageBlockButtons location="bottom">
                <apex:commandButton action="{!save}" value="Save"/>
                <apex:commandButton action="{!cancel}" value="Cancel"/>
            </apex:pageBlockButtons>
             <apex:pageBlockSection title="Request Details" columns="2">
                <apex:inputField value="{!TRInfo.Travel_Type__c}" required="true"/>
                <apex:inputField value="{!TRInfo.Traveling_To_Remote_Office__c}" required="true"/>
                <apex:inputField value="{!TRInfo.Reason_Code__c}" required="true"/>
                <apex:inputField value="{!TRInfo.Travel_Legs__c}" required="true"/>
            </apex:pageBlockSection>
                <apex:pageBlockSection title="Traveler's Details" columns="2" id="pgs1">
                  <apex:inputField id="textFld" value="{!TRInfo.Traveler_s_Name__c}" required="true"/>
                <apex:inputField value="{!TRInfo.Departure_Date__c}" required="true"/>
            </apex:pageBlockSection>
            <apex:pageBlockSection title="Other Details" columns="2">
                <apex:inputField value="{!TRInfo.NVIDIA_Employees_Traveling_with_You__c}" required="true"/>
                <apex:inputField value="{!TRInfo.Trip_Reason__c}" required="true"/>
                <apex:inputField value="{!TRInfo.Comments__c}"/>
                <apex:inputField value="{!TRInfo.Reason_for_Late_Booking__c}"/>
            </apex:pageBlockSection>
            <apex:pageBlockSection title="Itinerary Details" columns="1">
                <apex:inputField value="{!TRInfo.Total_Air_Fare__c}" required="true"/>
                <apex:outputField value="{!TRInfo.Air_Fare_Currency__c}"/><br/>
                Please enter the rate in USD using the following <apex:outputLink value="http://www.xe.com/" id="theLink" target="blank"><b>Currency Convertor</b></apex:outputLink>
            </apex:pageBlockSection>
        </apex:pageBlock>
         
    </apex:form>
</apex:page>

 

The apex class:

 

public class TravelRequest_SaveExt {
    
    public Travel_Request__c TRInfo {get;set;}
    public boolean showErrors{get;set;}
    String strId;
    public TravelRequest_SaveExt(ApexPages.StandardController controller) {
        TRInfo = new Travel_Request__c();
        TRInfo.Traveler_s_Name__c=userinfo.getUserId();
        system.debug('+++ID+++++'+ApexPages.currentPage().getParameters().get('Id'));
        try{
        if(ApexPages.currentPage().getParameters().get('Id') != null)
        {
            strId = ApexPages.currentPage().getParameters().get('Id');
            TRInfo = null;
            TRInfo = [Select Travel_Type__c,Traveling_To_Remote_Office__c,Reason_Code__c,Travel_Legs__c,
            Traveler_s_Name__c,Departure_Date__c,NVIDIA_Employees_Traveling_with_You__c,Trip_Reason__c,
               Comments__c,Reason_for_Late_Booking__c,Total_Air_Fare__c,Air_Fare_Currency__c From Travel_Request__c Where Id = :strId];
         }
       }
       catch(Dmlexception e){
       }  
    }
 
    public  pageReference save()
    {
        Database.UpsertResult resultObj = null;
        Database.SaveResult resObj = null;
        String clone = ApexPages.currentPage().getParameters().get('clone');
        PageReference pageRef;
    
        if(clone!=null && clone!='' && clone=='1')
        {
          Travel_Request__c TRInfo1= createTravelRequest(TRInfo);
         
           
            resObj=database.insert(TRInfo1);
            System.debug('Info from TravelRequest Object'+TRInfo1);
            pageRef=new PageReference('/'+resObj.getId());
           
            }
        
        else
        {
            try{
            resultObj=database.upsert(TRInfo);  
            pageRef=new PageReference('/'+resultObj.getId());
            }catch(exception e){
            }   
         }
            return pageRef;
     }
    public Travel_Request__c createTravelRequest(Travel_Request__c TRInfo)
    {
 
    Travel_Request__c TRInfo1 = new Travel_Request__c();
   
        TRInfo1.Travel_Type__c= TRInfo.Travel_Type__c;
        TRInfo1.Traveling_To_Remote_Office__c=TRInfo.Traveling_To_Remote_Office__c;
        TRInfo1.Reason_Code__c=TRInfo.Reason_Code__c;
        TRInfo1.Travel_Legs__c=TRInfo.Travel_Legs__c;
        TRInfo1.Traveler_s_Name__c=TRInfo.Traveler_s_Name__c;
        TRInfo1.Departure_Date__c=TRInfo.Departure_Date__c;
        TRInfo1.NVIDIA_Employees_Traveling_with_You__c=TRInfo.NVIDIA_Employees_Traveling_with_You__c;
        TRInfo1.Trip_Reason__c=TRInfo.Trip_Reason__c;
        TRInfo1.Comments__c=TRInfo.Comments__c;
        TRInfo1.Reason_for_Late_Booking__c=TRInfo.Reason_for_Late_Booking__c;
        TRInfo1.Total_Air_Fare__c=TRInfo.Total_Air_Fare__c;
        TRInfo1.Air_Fare_Currency__c=TRInfo.Air_Fare_Currency__c;
    
        return TRInfo1;
   }
}

 

 

 

 

 

Hi

I have created an object called travel request and created 2 validation rules on that object.I am using one VF page and 1 controller for it.When we are creating 1 record the validations are working fine and we are getting the error messages on the VF page,but when we are cloning the record the error messages are not showing on the page,though the validation rules are working because it is not saving the record and it is styaing in the same page.We cannot write custom validations on the apex class because the requirement is to use the standard validations strictly.Please help,it is  really urgent ..I am posting the VF code and the apex class code below:

 

The VF page

 

<apex:page standardController="Travel_Request__c" id="page1"  extensions="TravelRequest_SaveExt">
    <apex:form >
   
          <apex:pageBlock title="Travel Request Edit" mode="edit" id="pb1">
            <apex:pageBlockButtons location="top">
                <apex:commandButton action="{!save}" value="Save"/>
                <apex:commandButton action="{!cancel}" value="Cancel"/>
            </apex:pageBlockButtons>
            <apex:pageBlockButtons location="bottom">
                <apex:commandButton action="{!save}" value="Save"/>
                <apex:commandButton action="{!cancel}" value="Cancel"/>
            </apex:pageBlockButtons>
             <apex:pageBlockSection title="Request Details" columns="2">
                <apex:inputField value="{!TRInfo.Travel_Type__c}" required="true"/>
                <apex:inputField value="{!TRInfo.Traveling_To_Remote_Office__c}" required="true"/>
                <apex:inputField value="{!TRInfo.Reason_Code__c}" required="true"/>
                <apex:inputField value="{!TRInfo.Travel_Legs__c}" required="true"/>
            </apex:pageBlockSection>
                <apex:pageBlockSection title="Traveler's Details" columns="2" id="pgs1">
                  <apex:inputField id="textFld" value="{!TRInfo.Traveler_s_Name__c}" required="true"/>
                <apex:inputField value="{!TRInfo.Departure_Date__c}" required="true"/>
            </apex:pageBlockSection>
            <apex:pageBlockSection title="Other Details" columns="2">
                <apex:inputField value="{!TRInfo.NVIDIA_Employees_Traveling_with_You__c}" required="true"/>
                <apex:inputField value="{!TRInfo.Trip_Reason__c}" required="true"/>
                <apex:inputField value="{!TRInfo.Comments__c}"/>
                <apex:inputField value="{!TRInfo.Reason_for_Late_Booking__c}"/>
            </apex:pageBlockSection>
            <apex:pageBlockSection title="Itinerary Details" columns="1">
                <apex:inputField value="{!TRInfo.Total_Air_Fare__c}" required="true"/>
                <apex:outputField value="{!TRInfo.Air_Fare_Currency__c}"/><br/>
                Please enter the rate in USD using the following <apex:outputLink value="http://www.xe.com/" id="theLink" target="blank"><b>Currency Convertor</b></apex:outputLink>
            </apex:pageBlockSection>
        </apex:pageBlock>
         
    </apex:form>
</apex:page>

 

The apex class:

 

public class TravelRequest_SaveExt {
    
    public Travel_Request__c TRInfo {get;set;}
    public boolean showErrors{get;set;}
    String strId;
    public TravelRequest_SaveExt(ApexPages.StandardController controller) {
        TRInfo = new Travel_Request__c();
        TRInfo.Traveler_s_Name__c=userinfo.getUserId();
        system.debug('+++ID+++++'+ApexPages.currentPage().getParameters().get('Id'));
        try{
        if(ApexPages.currentPage().getParameters().get('Id') != null)
        {
            strId = ApexPages.currentPage().getParameters().get('Id');
            TRInfo = null;
            TRInfo = [Select Travel_Type__c,Traveling_To_Remote_Office__c,Reason_Code__c,Travel_Legs__c,
            Traveler_s_Name__c,Departure_Date__c,NVIDIA_Employees_Traveling_with_You__c,Trip_Reason__c,
               Comments__c,Reason_for_Late_Booking__c,Total_Air_Fare__c,Air_Fare_Currency__c From Travel_Request__c Where Id = :strId];
         }
       }
       catch(Dmlexception e){
       }  
    }
 
    public  pageReference save()
    {
        Database.UpsertResult resultObj = null;
        Database.SaveResult resObj = null;
        String clone = ApexPages.currentPage().getParameters().get('clone');
        PageReference pageRef;
    
        if(clone!=null && clone!='' && clone=='1')
        {
          Travel_Request__c TRInfo1= createTravelRequest(TRInfo);
         
           
            resObj=database.insert(TRInfo1);
            System.debug('Info from TravelRequest Object'+TRInfo1);
            pageRef=new PageReference('/'+resObj.getId());
           
            }
        
        else
        {
            try{
            resultObj=database.upsert(TRInfo);  
            pageRef=new PageReference('/'+resultObj.getId());
            }catch(exception e){
            }   
         }
            return pageRef;
     }
    public Travel_Request__c createTravelRequest(Travel_Request__c TRInfo)
    {
 
    Travel_Request__c TRInfo1 = new Travel_Request__c();
   
        TRInfo1.Travel_Type__c= TRInfo.Travel_Type__c;
        TRInfo1.Traveling_To_Remote_Office__c=TRInfo.Traveling_To_Remote_Office__c;
        TRInfo1.Reason_Code__c=TRInfo.Reason_Code__c;
        TRInfo1.Travel_Legs__c=TRInfo.Travel_Legs__c;
        TRInfo1.Traveler_s_Name__c=TRInfo.Traveler_s_Name__c;
        TRInfo1.Departure_Date__c=TRInfo.Departure_Date__c;
        TRInfo1.NVIDIA_Employees_Traveling_with_You__c=TRInfo.NVIDIA_Employees_Traveling_with_You__c;
        TRInfo1.Trip_Reason__c=TRInfo.Trip_Reason__c;
        TRInfo1.Comments__c=TRInfo.Comments__c;
        TRInfo1.Reason_for_Late_Booking__c=TRInfo.Reason_for_Late_Booking__c;
        TRInfo1.Total_Air_Fare__c=TRInfo.Total_Air_Fare__c;
        TRInfo1.Air_Fare_Currency__c=TRInfo.Air_Fare_Currency__c;
    
        return TRInfo1;
   }
}

 

 

 

 

 

 

Has anyone setup a visibility scenario like this.

 

 

I Need the Account page to be visible to everyone across the board, just the basic info, which isn't a problem.  However, I need to restrict the phone number to being visible to only the owners and their superiors in the role hierarchy.  Note, this is not record access, but field access.  I am scratching my head a little and could use a fresh perspective, if indeed it is possible.

 

thanks,

  • November 05, 2010
  • Like
  • 0