function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
amritamrit 

how to get the ID of a case to a visual force page call Survey

Hi

 

I have a visual force page called Survey,which is a related list with case standard object

<apex:page standardController="Survey__c" extensions="Survey" sidebar="false">
 <apex:form style="background-color:#FFFFFF;"> 
    <style type="text/css">
        body {font-family:Arial Unicode MS;font-size:12px;}
        P{background-color:#006400;HEIGHT:20PX;font-size:12px;font-weight:bold;color:#FFFFFF;}
    </style>

 <apex:pageBlock title="Survey Form">
 <apex:pageBlockSection title="Please enter the details" collapsible="true"  columns="2" showHeader="true" onmouseover="hover">
 <apex:panelGrid columns="4" width="900px">
 
 <apex:outputText value="Survey Name:" style="width:50px">
 </apex:outputText><apex:inputField value="{!Survey__c.Name}"/>
 
 <apex:outputText value="How was the Case handling power:" style="width:50px">
 </apex:outputText><apex:inputField value="{!Survey__c.How_was_the_Case_handling_power__c}"/>
 
 <apex:outputText value="How was the feedback:" style="width:50px">
 </apex:outputText><apex:inputField value="{!Survey__c.How_was_the_feedback__c}"/>
  
  <apex:outputText value="Case" style="width:50px">
 </apex:outputText><apex:inputField value="{!Survey__c.Case__c}"/>
 
 </apex:panelGrid>
 </apex:pageBlockSection>
 <center><apex:commandButton value="Save" action="{!Survey}"/>
 <apex:commandButton value="Cancel" action="{!Cancel}"/> </center>
 </apex:pageBlock> 

 </apex:form> 
</apex:page>
               

 

.I have a scenario over here like when ever a case is closed an email is send to the contact telling that ur case has been closed and it gives the link for the Survey.When the user click the survey ,the survey visual force page opens where the user put the survey details and when he saves it, the challenge is that survey record should go and sit with the same case no.

 

 

Below is the visual for page.

 

The controller below is

 

public  class Survey {
  public Survey__c sur;
  public Case cs;
  public integer n;
  public Id cid;
  public ApexPages.StandardController a;

    public Survey(ApexPages.StandardController controller) {
       this.sur = (Survey__c)Controller.getRecord();
        System.debug('nasir:' +sur);
      
    }
     public PageReference Survey() {
        cs = new Case();
        sur = new  Survey__c();
        cs = [Select CaseNumber,id from Case Limit 1];
        System.debug('sana:' + cs);
        
        sur.Case__c = cs.CaseNumber;
      upsert sur;
        return null;
    }
}

 

how can i achieve this..plz give some input thanks

 

sandersensandersen

Since you are sending the email from the case action, you could include the case id in the URL to the visualforce page. Then pull the case id off the querystring and use that id in your case lookup when you create the survey.

 

Something like:

 

 

ApexPages.currentPage().getParameters().get('id')

 

 

amritamrit

Actually the suggession what u have given is fine,but i am facing the problem out here is like when ever a case is created ,so related to that case there is no Survey record.So it is getting null.How can i handel that.

bryan.revelant1.36697709739127bryan.revelant1.36697709739127

Did you find out the answer, I was looking for the same