• Aditya Rayavarapu 5
  • NEWBIE
  • 30 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 11
    Questions
  • 10
    Replies
Hello, 
In my controller, I have:

public Contact c {get; set;}
public Contact cont {get; set;}
Public String acc3{get;set;}
Public String acc2{get;set;}

public controller(){

 acc3 = ApexPages.currentPage().getParameters().get('Master_Id__c'); 
           if(acc3 != null)        
            {
                this.c= [   SELECT  Master_Id__c
                              FROM    Contact
                              WHERE   Master_Id__c = : acc3 ];  
            }
              else
            {this.c= new Contact  ();} 

 acc2 = ApexPages.currentPage().getParameters().get('LastName'); 
           if(acc2 != null)        
            {
                this.cont= [   SELECT  LastName
                              FROM    Contact
                              WHERE   LastName = : acc2 ];  
            }
               else
            {this.cont=  new Contact(ReportsTo=new contact(Master_Id__c='xxxx')); } 
}


For string acc2, in the else statement, I have hardcoded the value to 'xxxx'. However, I want that value to be the same as the string in acc3 (which is an input field in my VF page). So it would look something like (Master_Id__c='!acc3')); 
However, I can't seem to get the syntax for it correctly.
Any suggestions on how to correctly reference the string acc3?
Thanks
Hello,
Please take a look at my controller (Public string acc4). In the else statement, I have hardcoded the value 'xxxx', but I want it to take the value of the string acc3 (which is an input field in the VF page). I've tried a few different ways for this, but can't seem to figure it out. Any suggestions?
Thanks


Part of VF Page:

 <apex:inputField value="{!c.Lastname}" />
 <apex:inputField value="{!c.Master__c}" />
  <apex:inputField value="{!cont.Lastname}" />

  <apex:commandButton action="{!save}" value="Save"/>


Part of CONTROLLER:

public Contact c {get; set;}
Public Contact cont{get;set;}
Public String accId{get;set;}
Public String acc2{get;set;}
Public String acc3{get;set;}
Public String acc4{get;set;}
public controller(){

        accId = ApexPages.currentPage().getParameters().get('LastName'); 
           if(accId != null)        
            {
                this.c= [   SELECT  LastName
                              FROM    Contact
                              WHERE   LastName = : accId ];  
            }
            
             else
            {this.c= new Contact  ();} 
            
            acc3 = ApexPages.currentPage().getParameters().get('Master__c'); 
           if(acc3 != null)        
            {
                this.c= [   SELECT  Master__c
                              FROM    Contact
                              WHERE   Master__c = : acc3 ];  
            }
            
             else
            {this.c= new Contact  ();} 
            
            acc2 = ApexPages.currentPage().getParameters().get('LastName'); 
           if(acc2 != null)        
            {
                this.cont= [   SELECT  LastName
                              FROM    Contact
                              WHERE   LastName = : acc2 ];  
            }
            
             else
            {this.cont=  new Contact(); } 
            
            acc4 = ApexPages.currentPage().getParameters().get('Master__c'); 
           if(acc4 != null)        
            {
                this.cont= [   SELECT  Master__c
                              FROM    Contact
                              WHERE   Master__c = : acc3 ];  
            }
            
             else
            {this.cont=  new Contact(ReportsTo=new Contact(Master__c='xxxx'); } 
            
            }

 public PageReference save() {
insert c;
insert cont;
Hello,
I have a lookup relationship between Contact (Master) and Dependant__c (Child). The lookup field is called Primary__c.
I have a VF page where you can enter the contact details, and also the dependant details. When you click 'Save', both the contact and dependant save. However, I want the dependant to have a lookup relation to this specific contact.  How can I achieve this? I have tried to get the record ID of the contact before inserting the dependant, but I cannot get the getting the Id part of the code right.

VF PAGE (simplified) :

<apex:page controller="customcontroller">
<apex:form>
           <apex:inputfield value="{!c.LastName}" />
           <apex:inputfield value="{!d.Name__c}"/>

        <apex:commandButton action="{!save}" value="Save"/>
</apex:form>
</apex:page>

CONTROLLER:

public class CustomController {

public Contact c {get; set;}
public Dependant__c d {get;set;}

public void save(){
    
        insert c;
Primary__c=('Select Name from Contact') //unclear about getting the Contact record ID for this part
insert d;
}
}
       
       
        Thanks,
Adi
Hello,
I have a self lookup relationship in my Contact object, called 'Primary Sub'.

I want a VF page where you can enter two contacts. The second contact would have to be a child of the first contact.
To simplify my page, this is what the code looks like:

<apex:page controller="CustomController">
<apex:form >
 
            <apex:inputField value="{!c.lastname}" />
           
            <apex:inputField value="{!c.lastname}" />
            <apex:inputField value="{!c.Primary_Sub__c}" />
            
            <apex:commandButton action="{!save}" value="Save"/>
            </apex:form>
</apex:page>


And the controller:

public class CustomController {

public Contact c{get; set;}
Public String accId{get;set;}
Public String acc3{get;set;}

 public CustomController(){
        accId = ApexPages.currentPage().getParameters().get('LastName'); 
           if(accId != null)        
            {
                this.c= [   SELECT  LastName
                              FROM    Contact
                              WHERE   LastName = : accId ];  
            }
            else
            {this.c= new Contact();}  
            
            acc3 = ApexPages.currentPage().getParameters().get('Primary_Sub__c'); 
           if(acc3 != null)        
            {
                this.c= [   SELECT  Primary_Sub__c
                              FROM    Contact
                              WHERE   Primary_Sub__c = : acc3 ];  
            }
            else
            {this.c= new Contact();}          
    
}

public pagereference  save(){
    
        insert this.c;
         c.Primary_sub__c=accId;
         insert this.c;
        
        PageReference reRend = new PageReference('/apex/Thankyou'); 
        reRend.setRedirect(true);
                return reRend;
             
}
}


I'm trying to workout the logic where the lookup field for the second field can be populated with the first contact, and then Inserted.
Any suggestions?
Thanks
Adi
Hello,
I have an output field in a VF page. When the page is loaded, if the output field is empty, then javascript must output a text value of "Anonymous". I can get the output to generate when the page is loaded, but it is not considering whether the output field is null or not. I tried using ".value" at the end of var x, but it doesn't work. Any help? Thanks

<apex:outputfield id="first" value="{!c.FirstName__c}"/>
           
            <output id="firstname"></output>

<script>
 
  var x = document.getElementById('{!$Component.first}');
 
window.onload = function(){
     
if ( x !== undefined ) {
   document.getElementById('firstname').value="Anonymous";
     
}
   }
</script>

Hi, I created a VF page where we can search for a case using the case number. 

However, in the result, I also want to display the Open Activites related to the Case.
I am able to reference the Case object fields in the page, but cannot figure out how to do that with the Open Activites fields (Status, Priority, Subject)

Controller:

public class casesearchcontroller {
     public list <case> cas {get;set;}
    public casesearchcontroller(ApexPages.StandardController controller) {
    
    }
    
   public string searchstring {get;set;}  
    
   public void search(){  
     string searchquery='select casenumber,Email__c,Category__c,SubCategory__c,(Select  ActivityDate, Status, Priority,Subject FROM OpenActivities)from case where CaseNumber like \'%'+searchstring+'%\' Limit 30';  
     cas= Database.query(searchquery);  
   }  
   public void clear(){  
   cas.clear();  
   }  
 }


Page:

<apex:page standardController="Case" extensions="caseextension" showheader="false" >
 <apex:form >  
 <apex:inputText value="{!searchstring}" label="Input"/>   
  <apex:commandButton value="Find Case" action="{!search}"/>  
  <apex:commandButton value="Clear Search" action="{!search}"/>  
   <apex:pageBlock title="Search Result">  
    <apex:pageblockTable value="{!cas}" var="c">  
      
     <apex:column value="{!c.CaseNumber}"/>  
     <apex:column value="{!c.Email__c}"/>
      <apex:column value="{!c.Category__c}"/>
    <apex:column value="{!c.SubCategory__c}"/>
    
     
    </apex:pageblocktable>
          </apex:pageBlock> 
     </apex:form> 
</apex:page>

Any help?

Thanks!

Hi,
I'm trying to create a VF page where we can enter the Case Number or the Email address provided in the case.
Upon clicking submit, the record matching the case number is retreived and selected fields should be displayed on the page.

Can anyone point me in the right direction of how I could achieve this?
Thanks
Hi, I created a visualforce page to create a case. Users can enter their name, email, etc, and click 'Submit case' which will create the case and also redirect to a new Thank You page which will provide them with the Case Number. 

I have been able to do this successfully, except for the final step of displaying the Case Number.

public pageReference save()
    {
        insert case;
         
        PageReference reRend = new PageReference('/apex/thankyoupage'); 
        reRend.setRedirect(false);
        return reRend;

Thanks!
Hello,
I have two VF pages and would like to pass info from the first page to the second.

If the field was an inputTEXT field, then I pass the info using:

Page:
<apex:page controller="xxxx">
    <a href="/apex/page2?MyVariable=25">Click Me</a>
            <apex:pageblockButtons >
             <apex:commandButton value="click Me" action="{!Transfer}" />
            </apex:pageblockButtons>
                  <apex:inputText value="{!Value2Pass}" />
     </apex:page>

Controller:
public class xxxx {
    public String Value2Pass { get; set; }
    public PageReference Transfer() {
        PageReference newPAge = page.page2;
        newPage.getParameters().put('MyVariable1', Value2Pass);
        return newPage; 
        }


And then using the corresponding code on page 2 to get these values as an OutputText:

<apex:page controller="yyyy">
            <apex:Outputtext value="{!Var01}" />
 </apex:page>

Controller:
public class yyyy {
    public String Var01 { get; set; }
    public yyyy() {
        Var01 = Apexpages.currentPage().getParameters().get('MyVariable1');
          }
}
HOWEVER, how would I achieve the same thing if I wanted to have an InputField in the first page (Case_FirstName__c) and transfer the information in this field as an OutputField in page 2?
I've tried using the standard controller for Case, but it does not work with.

Thanks!

Hello,
 

I have 2 VF pages to use for Web to Case.
On the first page, the user enters their name, email, problem, and uploads an image.
 

Then they click 'Review Data', which then takes them to the 2nd VF page called 'Summary'.
On this page, the user should be able to see their info (name, email, problem), without being able to edit it.

For the 'Review Data' button on the first page, I used 

public PageReference openSecondPage(){
    return Page.Summary.setRedirect(false);
      }


Could anyone help me with displaying the user info as output fields on the second page?
Thanks!

Hi,
So basically when you want to attach an article to a case, it takes you to the search page where you can search for all your articles, and filter it by article type or language.

I have a custom field on the case object called "Case Category" and when I click on find article, I want the search window to only show articles that are related to the case category. Is there a way I can do this? 

Thanks,
Adi
Hello, 
In my controller, I have:

public Contact c {get; set;}
public Contact cont {get; set;}
Public String acc3{get;set;}
Public String acc2{get;set;}

public controller(){

 acc3 = ApexPages.currentPage().getParameters().get('Master_Id__c'); 
           if(acc3 != null)        
            {
                this.c= [   SELECT  Master_Id__c
                              FROM    Contact
                              WHERE   Master_Id__c = : acc3 ];  
            }
              else
            {this.c= new Contact  ();} 

 acc2 = ApexPages.currentPage().getParameters().get('LastName'); 
           if(acc2 != null)        
            {
                this.cont= [   SELECT  LastName
                              FROM    Contact
                              WHERE   LastName = : acc2 ];  
            }
               else
            {this.cont=  new Contact(ReportsTo=new contact(Master_Id__c='xxxx')); } 
}


For string acc2, in the else statement, I have hardcoded the value to 'xxxx'. However, I want that value to be the same as the string in acc3 (which is an input field in my VF page). So it would look something like (Master_Id__c='!acc3')); 
However, I can't seem to get the syntax for it correctly.
Any suggestions on how to correctly reference the string acc3?
Thanks
Hello,
Please take a look at my controller (Public string acc4). In the else statement, I have hardcoded the value 'xxxx', but I want it to take the value of the string acc3 (which is an input field in the VF page). I've tried a few different ways for this, but can't seem to figure it out. Any suggestions?
Thanks


Part of VF Page:

 <apex:inputField value="{!c.Lastname}" />
 <apex:inputField value="{!c.Master__c}" />
  <apex:inputField value="{!cont.Lastname}" />

  <apex:commandButton action="{!save}" value="Save"/>


Part of CONTROLLER:

public Contact c {get; set;}
Public Contact cont{get;set;}
Public String accId{get;set;}
Public String acc2{get;set;}
Public String acc3{get;set;}
Public String acc4{get;set;}
public controller(){

        accId = ApexPages.currentPage().getParameters().get('LastName'); 
           if(accId != null)        
            {
                this.c= [   SELECT  LastName
                              FROM    Contact
                              WHERE   LastName = : accId ];  
            }
            
             else
            {this.c= new Contact  ();} 
            
            acc3 = ApexPages.currentPage().getParameters().get('Master__c'); 
           if(acc3 != null)        
            {
                this.c= [   SELECT  Master__c
                              FROM    Contact
                              WHERE   Master__c = : acc3 ];  
            }
            
             else
            {this.c= new Contact  ();} 
            
            acc2 = ApexPages.currentPage().getParameters().get('LastName'); 
           if(acc2 != null)        
            {
                this.cont= [   SELECT  LastName
                              FROM    Contact
                              WHERE   LastName = : acc2 ];  
            }
            
             else
            {this.cont=  new Contact(); } 
            
            acc4 = ApexPages.currentPage().getParameters().get('Master__c'); 
           if(acc4 != null)        
            {
                this.cont= [   SELECT  Master__c
                              FROM    Contact
                              WHERE   Master__c = : acc3 ];  
            }
            
             else
            {this.cont=  new Contact(ReportsTo=new Contact(Master__c='xxxx'); } 
            
            }

 public PageReference save() {
insert c;
insert cont;
Hello,
I have a lookup relationship between Contact (Master) and Dependant__c (Child). The lookup field is called Primary__c.
I have a VF page where you can enter the contact details, and also the dependant details. When you click 'Save', both the contact and dependant save. However, I want the dependant to have a lookup relation to this specific contact.  How can I achieve this? I have tried to get the record ID of the contact before inserting the dependant, but I cannot get the getting the Id part of the code right.

VF PAGE (simplified) :

<apex:page controller="customcontroller">
<apex:form>
           <apex:inputfield value="{!c.LastName}" />
           <apex:inputfield value="{!d.Name__c}"/>

        <apex:commandButton action="{!save}" value="Save"/>
</apex:form>
</apex:page>

CONTROLLER:

public class CustomController {

public Contact c {get; set;}
public Dependant__c d {get;set;}

public void save(){
    
        insert c;
Primary__c=('Select Name from Contact') //unclear about getting the Contact record ID for this part
insert d;
}
}
       
       
        Thanks,
Adi
Hello,
I have a self lookup relationship in my Contact object, called 'Primary Sub'.

I want a VF page where you can enter two contacts. The second contact would have to be a child of the first contact.
To simplify my page, this is what the code looks like:

<apex:page controller="CustomController">
<apex:form >
 
            <apex:inputField value="{!c.lastname}" />
           
            <apex:inputField value="{!c.lastname}" />
            <apex:inputField value="{!c.Primary_Sub__c}" />
            
            <apex:commandButton action="{!save}" value="Save"/>
            </apex:form>
</apex:page>


And the controller:

public class CustomController {

public Contact c{get; set;}
Public String accId{get;set;}
Public String acc3{get;set;}

 public CustomController(){
        accId = ApexPages.currentPage().getParameters().get('LastName'); 
           if(accId != null)        
            {
                this.c= [   SELECT  LastName
                              FROM    Contact
                              WHERE   LastName = : accId ];  
            }
            else
            {this.c= new Contact();}  
            
            acc3 = ApexPages.currentPage().getParameters().get('Primary_Sub__c'); 
           if(acc3 != null)        
            {
                this.c= [   SELECT  Primary_Sub__c
                              FROM    Contact
                              WHERE   Primary_Sub__c = : acc3 ];  
            }
            else
            {this.c= new Contact();}          
    
}

public pagereference  save(){
    
        insert this.c;
         c.Primary_sub__c=accId;
         insert this.c;
        
        PageReference reRend = new PageReference('/apex/Thankyou'); 
        reRend.setRedirect(true);
                return reRend;
             
}
}


I'm trying to workout the logic where the lookup field for the second field can be populated with the first contact, and then Inserted.
Any suggestions?
Thanks
Adi
Hello,
I have an output field in a VF page. When the page is loaded, if the output field is empty, then javascript must output a text value of "Anonymous". I can get the output to generate when the page is loaded, but it is not considering whether the output field is null or not. I tried using ".value" at the end of var x, but it doesn't work. Any help? Thanks

<apex:outputfield id="first" value="{!c.FirstName__c}"/>
           
            <output id="firstname"></output>

<script>
 
  var x = document.getElementById('{!$Component.first}');
 
window.onload = function(){
     
if ( x !== undefined ) {
   document.getElementById('firstname').value="Anonymous";
     
}
   }
</script>

Hi, I created a VF page where we can search for a case using the case number. 

However, in the result, I also want to display the Open Activites related to the Case.
I am able to reference the Case object fields in the page, but cannot figure out how to do that with the Open Activites fields (Status, Priority, Subject)

Controller:

public class casesearchcontroller {
     public list <case> cas {get;set;}
    public casesearchcontroller(ApexPages.StandardController controller) {
    
    }
    
   public string searchstring {get;set;}  
    
   public void search(){  
     string searchquery='select casenumber,Email__c,Category__c,SubCategory__c,(Select  ActivityDate, Status, Priority,Subject FROM OpenActivities)from case where CaseNumber like \'%'+searchstring+'%\' Limit 30';  
     cas= Database.query(searchquery);  
   }  
   public void clear(){  
   cas.clear();  
   }  
 }


Page:

<apex:page standardController="Case" extensions="caseextension" showheader="false" >
 <apex:form >  
 <apex:inputText value="{!searchstring}" label="Input"/>   
  <apex:commandButton value="Find Case" action="{!search}"/>  
  <apex:commandButton value="Clear Search" action="{!search}"/>  
   <apex:pageBlock title="Search Result">  
    <apex:pageblockTable value="{!cas}" var="c">  
      
     <apex:column value="{!c.CaseNumber}"/>  
     <apex:column value="{!c.Email__c}"/>
      <apex:column value="{!c.Category__c}"/>
    <apex:column value="{!c.SubCategory__c}"/>
    
     
    </apex:pageblocktable>
          </apex:pageBlock> 
     </apex:form> 
</apex:page>

Any help?

Thanks!

Hi,
So basically when you want to attach an article to a case, it takes you to the search page where you can search for all your articles, and filter it by article type or language.

I have a custom field on the case object called "Case Category" and when I click on find article, I want the search window to only show articles that are related to the case category. Is there a way I can do this? 

Thanks,
Adi