Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8367223
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:06:20+00:00 2026-06-09T13:06:20+00:00

I have a commandbutton, When click I want it to save a phonecall record

  • 0

I have a commandbutton, When click I want it to save a phonecall record and redirect to the record page, after that open a new page in a new window which shows the editing page of a new case related to the call.

I am doing it like this:

//Pseudocode
public PageReference saverecord(){
   create a new phone call record;
   insert record;
   if(createnewcase)
      create case;
      insert case;
      create editcaseURL;
   return phonerecord page;
}

on the client side, In the commandbutton, I use <apex:param name="newcase" value="true" assignTo="{!createNewCase}"/> to set the createnewcase to true. and oncomplete javascript to open the popup window. I have test the phonerecord and caserecord seperately and succeeded. but when I put them in one class, the case was never created. and in the visualforce view state window. I can’t even find the boolean createnewcase.

please help.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T13:06:22+00:00Added an answer on June 9, 2026 at 1:06 pm

    It is easy to implement with Apex / JavaScript:

    The apex code:

    // Defining two variables for the both records (case and phone)
    public String caseId { get; set; }
    public String phoneId { get; set; }
    
    // Defining a boolean to render the JavaScript panel after saving
    punlic Boolean redirectNow { get; set; }
    
    public PageReference saverecord(){
        // Create a new phone call record;
        insert record;
    
        // Now reading a phone record id
        phoneId = record.id;
    
        if(createnewcase){
            create case;
            insert case;
    
            // Now reading a case id
            caseId = case.id;
        }
    
        // If case and phone are OK -> set this flag to true
        redirectNow = true;
    
        // We do not need to return a real page reference 
        // because we will redirecting with javascript
        return null;
    }
    

    And the Visualforce page with JavaScript:

    <!-- A command button, that rerenders a panel with JavaScript -->
    <apex:commandButton value="Save" action="{!saverecord}" reRender="doAfterSave"/>
    
    <!-- This panel renders only after you will save the new records -->
    <apex:outputPanel id="doAfterSave">
        <apex:outputPanel rendered="{!redirectNow}">
            <script>
                // First reading the id's
                var newCaseId = '{!caseId}';
                var newPhoneId = '{!phoneId}';
    
                if(newCaseId != '' && newPhoneId != '')
                {
                    // Now opening a new window with case in edit mode
                    window.open('/' + newCaseId + '/e');
    
                    // And then redirecting the main page to the new phone record
                    window.location = '/' + phoneId;
                }
            </script>
        </apex:outputPanel>
    </apex:outputPanel>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following layout in my page (simplified) <h:form> <h:commandButton action=#{bean.save} value=Save/> <rich:tabPanel
I have a commandButton in JSF 2.0 with a actionvalue that I want to
In my JSF 1.2 webapp I have a page with a <h:commandButton> that invokes
I have a two tab page, one tab is the record list, click on
I have an a4j:commandButton which looks like this <a4j:commandButton id=stopBtn type=button reRender=lastOp action=#{MyBacking.stop} value=Stop
I have an inputText and a commandButton in a JSF page. The user inputs
I have something like: <h:commandButton> <h:ajax event=click listener=#{controller.onLog} onchange=onLogProcess /> .... </h:commandButton> I send
I have a Facelets Composite component that includes, among other things, a commandButton: <?xml
Suppose i have JSF page <h:body> <h:form id=formID prependId=false> <h:outputText id=randomID value=#{randomNumber.random}/> <h:commandButton id=buttonID
I have a .doc with a command button (cmdStart) which opens a form. After

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.