1

I'm new to vf page I have a requirement to assign a vf page for a specific record type. I'm able to do by through a vf page.

Now my problem is once I select the record type from vf page. I'm not able to assign account name. Already account value is there in URL parameters But I'm not sure why I'm not getting the value

VF page

<apex:page standardController="case" tabStyle="case" extensions="FleetCheck">
   <apex:sectionHeader title="{!$ObjectType.Case.label} Edit" subtitle="New Case" help="Help for this Page"/>
   <apex:form >
   <apex:pageBlock title="Case Edit" mode="edit">
   <apex:pageBlockButtons >
   <apex:commandButton value="Save" action="{!save}"/>
   <apex:commandButton value="Save & Close" action="{!save}"/>
   <apex:commandButton value="Save & New" action="{!save}"/>
   <apex:commandButton value="Cancel" action="{!cancel}"/>
   </apex:pageBlockButtons>
   <apex:pageBlockSection title="Case Information" collapsible="false" columns="1">
   <apex:inputField value="{!case.accountid}"  />
   <apex:inputField value="{!case.contactid}"/>
   <apex:inputfield value="{!case.Date_assigned_to_Fulfillment__c}"/>
   <apex:outputfield value="{!case.Entitlementid}"/>
   </apex:pageBlockSection>
   <apex:pageBlockSection title="Case Details" collapsible="false" columns="2">
   <apex:outputField value="{!case.recordtype.Name}"/>
   </apex:pageBlockSection>
   </apex:pageBlock>
   </apex:form>
</apex:page>

Apex Extension

public with sharing class FleetCheck {
public case cus{get;set;}
public String var{get;set;}
public Boolean edit{get;set;}
private ApexPages.StandardController controller;
public String accountIDdetail {get; set;}
public FleetCheck(ApexPages.StandardController controller) {
accountIDdetail = ApexPages.currentPage().getParameters().get('def_account_id');
if(var!=null)
{
cus=[Select Id from case where Id=:var];
edit=true;
}
else
{
edit=false;
     cus=new case();
     cus.Accountid=accountIDdetail;
}
}
 /*public PageReference save() {
       if(!edit){
       insert cus;
       }
       else{
       update cus;
       }
       PageReference redirectPage =  new PageReference('/'+cus.id);
       redirectPage.setRedirect(true);
       return redirectPage;
    }*/
    }

Please let me know where i missed it

For reference: enter image description here

1

You're not binding your Case object with appropriate variable which declared in your controller. Replace case variable with cus in Visualforce page and your issue will be resolved. Refer below code for your reference:

<apex:pageBlockSection title="Case Information" collapsible="false" columns="1">
   <apex:inputField value="{!cus.accountid}"  />
   <apex:inputField value="{!cus.contactid}"/>
</apex:pageBlockSection>

For additional information, if you want to use case.accountid instead of cus.accountid then in the URL parameter you should append appropriate case id (id=500280000083hmo). Since you're using standard controller, contact and Account Name will get printed automatically.

| improve this answer | |
  • Hey thank you sharing the knowledge – Pavan tej Mar 18 '19 at 8:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.