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
Dhananjaya BulugahamulleDhananjaya Bulugahamulle 

How to display output text after click on saving button?

HI, I have a Auto number field ({!Product_Brief__c.Name}). It will generate number after saving the page. If i put this field in my page before saving it will break my page. So i want show this output text field after saving, but i could not use rerendering option. Coz I already used it for editing the page. If i combine with it, it will not work is there any way i can do this. Thanks. 
<apex:page standardController="Product_Brief__c" sidebar="true" showHeader="true" extensions="gibco">
<apex:form id="theForm">
<apex:pageBlock id="myPanel">
<apex:pageBlockSection collapsible="false" title="Section 1: Custom Media Information (Required)" id="thePageBlockSection">
              
     <apex:outputText value="{!Product_Brief__c.Name}"></apex:outputText>
               
    <apex:inputField value="{!Product_Brief__c.Opportunity__r.Account.Name}" rendered="{!bEditMode}"/>
    <apex:outputField value="{!Product_Brief__c.Opportunity__r.Account.Name}" rendered="{!NOT(bEditMode)}"/>
    <apex:inputField value="{!Product_Brief__c.Customer_Number__c}" rendered="{!bEditMode}"/>
    <apex:outputField value="{!Product_Brief__c.Customer_Number__c}" rendered="{!NOT(bEditMode)}"/>
    <apex:inputField value="{!Product_Brief__c.Billing_Address__c}" rendered="{!bEditMode}"/>
    <apex:outputField value="{!Product_Brief__c.Billing_Address__c}" rendered="{!NOT(bEditMode)}"/>
    <apex:outputField value="{!Product_Brief__c.CreatedBy.Name}" rendered="{!NOT(bEditMode)}"/>
    <apex:inputField value="{!Product_Brief__c.Shipping_Address__c}" rendered="{!bEditMode}"/>
    <apex:outputField value="{!Product_Brief__c.Shipping_Address__c}" rendered="{!NOT(bEditMode)}"/></apex:pageBlockSection>

<apex:pageblockButtons >
   <apex:commandButton action="{!doToggleEditMode}" value="Edit" reRender="myPanel" rendered="{!NOT(bEditMode)}"/>
   <apex:commandButton action="{!doSave}" value="Save" reRender="myPanel" rendered="{!bEditMode}"/>
   <apex:commandButton value="Save" action="{!save}" id="c2" rendered="{!NOT(bEditMode)}"/>
   <apex:commandButton value="Print" onclick="window.print();" rendered="{!NOT(bEditMode)}"/>
   <apex:commandButton value="Cancel" action="{!Cancel}" rendered="{!NOT(bEditMode)}"/>
</apex:pageblockButtons>

Extention

public class gibco {
    
    public Product_Brief__c pb {get;set;}
    public User u {get;set;}
    
    private ApexPages.StandardController controller {get;set;}
    public boolean bUpdate {get;set;}
    public string loggedinUserId = UserInfo.getUserId();
    public User u2 = [Select ContactId From User where Id =: '005R0000001Y6h4'];
    
    public String ctId{
        get {
         //   if (ctId==null){
         //   if (bUpdate){
                  ctId = u2.ContactId;
         //       }
              return ctId;
         //   }
        }
        set;
    }
         
    Contact ct = [SELECT AccountId FROM Contact WHERE id=:ctId];
    public string getacct(){
        Account acct = [SELECT Name FROM Account WHERE id=:ct.AccountId];  
        return acct.Name;
        return null;
        }
         
    Opportunity opp = [SELECT Id FROM Opportunity WHERE AccountId=:ct.AccountId LIMIT 1];
    
/* *************** Edit Sec. ************************     */ 
    public Boolean bEditMode {
    get {
      if(bEditMode == null) {
          bEditmode = false;
          }
          return bEditMode;
      }
      set;
    }

    public PageReference doToggleEditMode() {
         bEditMode = !bEditMode;
            return null;
    }
    
    public PageReference doSave() {
        try {
        // Do your stuff to save your record
        controller.save();
        doToggleEditMode();
        }
        catch(Exception ex) {
        // Handle error
        }
    
        return null;
        }


Thanks
Best Answer chosen by Dhananjaya Bulugahamulle
Fahad-AkhtarFahad-Akhtar
Hi Dhananjaya,
Try this, my bad i missed a bracket.
 
<apex:outputPanel rendered="{!IF(Product_Brief__c.id != null, true,false)}"> 
    <b><apex:outputText value="{!Product_Brief__c.Name}"></apex:outputText></b>
</apex:outputPanel>


Thanks,
Fahad Akhtar

All Answers

Fahad-AkhtarFahad-Akhtar
HI Dhananjaya,
Please see the code below, you can do something like this 

<apex:outputPanel rendered={!IF(Product_Brief__c.id != null, true,false}>
   <b><apex:outputText value="{!Product_Brief__c.Name}"></apex:outputText></b>
</apex:outputPanel>
 
<apex:page standardController="Product_Brief__c" sidebar="true" showHeader="true" extensions="gibco">
<apex:form id="theForm">
<apex:pageBlock id="myPanel">
<apex:pageBlockSection collapsible="false" title="Section 1: Custom Media Information (Required)" id="thePageBlockSection">
      <apex:outputPanel rendered={!IFProduct_Brief__c.id != null, true,false}> 
        <b><apex:outputText value="{!Product_Brief__c.Name}"></apex:outputText></b>
      </apex:outputPanel>
               
    <apex:inputField value="{!Product_Brief__c.Opportunity__r.Account.Name}" rendered="{!bEditMode}"/>
    <apex:outputField value="{!Product_Brief__c.Opportunity__r.Account.Name}" rendered="{!NOT(bEditMode)}"/>
    <apex:inputField value="{!Product_Brief__c.Customer_Number__c}" rendered="{!bEditMode}"/>
    <apex:outputField value="{!Product_Brief__c.Customer_Number__c}" rendered="{!NOT(bEditMode)}"/>
    <apex:inputField value="{!Product_Brief__c.Billing_Address__c}" rendered="{!bEditMode}"/>
    <apex:outputField value="{!Product_Brief__c.Billing_Address__c}" rendered="{!NOT(bEditMode)}"/>
    <apex:outputField value="{!Product_Brief__c.CreatedBy.Name}" rendered="{!NOT(bEditMode)}"/>
    <apex:inputField value="{!Product_Brief__c.Shipping_Address__c}" rendered="{!bEditMode}"/>
    <apex:outputField value="{!Product_Brief__c.Shipping_Address__c}" rendered="{!NOT(bEditMode)}"/></apex:pageBlockSection>

<apex:pageblockButtons >
   <apex:commandButton action="{!doToggleEditMode}" value="Edit" reRender="myPanel" rendered="{!NOT(bEditMode)}"/>
   <apex:commandButton action="{!doSave}" value="Save" reRender="myPanel" rendered="{!bEditMode}"/>
   <b><apex:commandButton value="Save" action="{!save}" id="c2" rendered="{!NOT(bEditMode)}"/></b>
   <apex:commandButton value="Print" onclick="window.print();" rendered="{!NOT(bEditMode)}"/>
   <apex:commandButton value="Cancel" action="{!Cancel}" rendered="{!NOT(bEditMode)}"/>
</apex:pageblockButtons>

Extention

public class gibco {
    
    public Product_Brief__c pb {get;set;}
    public User u {get;set;}
    
    private ApexPages.StandardController controller {get;set;}
    public boolean bUpdate {get;set;}
    public string loggedinUserId = UserInfo.getUserId();
    public User u2 = [Select ContactId From User where Id =: '005R0000001Y6h4'];
    
    public String ctId{
        get {
         //   if (ctId==null){
         //   if (bUpdate){
                  ctId = u2.ContactId;
         //       }
              return ctId;
         //   }
        }
        set;
    }
         
    Contact ct = [SELECT AccountId FROM Contact WHERE id=:ctId];
    public string getacct(){
        Account acct = [SELECT Name FROM Account WHERE id=:ct.AccountId];  
        return acct.Name;
        return null;
        }
         
    Opportunity opp = [SELECT Id FROM Opportunity WHERE AccountId=:ct.AccountId LIMIT 1];
    
/* *************** Edit Sec. ************************     */ 
    public Boolean bEditMode {
    get {
      if(bEditMode == null) {
          bEditmode = false;
          }
          return bEditMode;
      }
      set;
    }

    public PageReference doToggleEditMode() {
         bEditMode = !bEditMode;
            return null;
    }
    
    public PageReference doSave() {
        try {
        // Do your stuff to save your record
        controller.save();
        doToggleEditMode();
        }
        catch(Exception ex) {
        // Handle error
        }
    
        return null;
        }

 
Dhananjaya BulugahamulleDhananjaya Bulugahamulle
@Fahad-KK Thanks for the reply. but it gives me a error. First error is no bracket. When i put the bracket it gives me this error called 
Error: Syntax error. Extra ','

 
<apex:outputPanel rendered="{!IFProduct_Brief__c.id != null, true,false}"> 
    <b><apex:outputText value="{!Product_Brief__c.Name}"></apex:outputText></b>
</apex:outputPanel>

 
Fahad-AkhtarFahad-Akhtar
Hi Dhananjaya,
Try this, my bad i missed a bracket.
 
<apex:outputPanel rendered="{!IF(Product_Brief__c.id != null, true,false)}"> 
    <b><apex:outputText value="{!Product_Brief__c.Name}"></apex:outputText></b>
</apex:outputPanel>


Thanks,
Fahad Akhtar
This was selected as the best answer
Dhananjaya BulugahamulleDhananjaya Bulugahamulle
@ Fahad-KK Thank you very much. it works now.