• HIRAL PUROHIT
  • NEWBIE
  • 10 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 7
    Replies
Hello,
I created table in my custom object.But now I want to add new row to add more records.Though I created it with 'AddRow' button.
But when I click on that button it's showing no change. Please help with this.
Here I am posting my code:
<apex:page standardController="Student__c" extensions="addFunction">
<apex:form >
   
   <apex:sectionHeader title="Student Edit" subtitle="New Student"/>
  <apex:pageBlock mode="edit" >
  <apex:pageBlockButtons >
  <apex:commandButton action="{!Save}" value="Save"/>
  <apex:commandButton action="{!Cancel}" value="Cancel"/>
  </apex:pageBlockButtons>
   <apex:pageBlockSection title="Student Details" columns="1" >
   
     
     <apex:inputField value="{!Student__c.Student_Id__c}"/>
     <apex:inputField value="{!Student__c.Name}"/>
     <apex:inputField value="{!Student__c.Last_Name__c}"/>
     <apex:inputField value="{!Student__c.Contact_Number__c}" />
     <apex:inputField value="{!Student__c.Email_Id__c}"/>
     <apex:inputField value="{!Student__c.Address__c}"/>
     <apex:inputField value="{!Student__c.Degree__c}"/>
     <apex:inputField value="{!Student__c.Department__c}"/>
     
  </apex:pageBlockSection>
  

   <apex:pageBlockSection title="Course Details" id="hp">
   <apex:pageMessages />
 <apex:variable var="rowNumber" value="{!0}"/>
 
 
   
   
   <apex:pageBlockTable value="{!Student__c}" var="stu">
   <apex:column headerValue="No." style="width:20px; text-align:center;" headerClass="centertext">
 <apex:outputText value="{0}" style="text-align:center;"> 
 <apex:param value="{!rowNumber+1}" /> 
 </apex:outputText>
 </apex:column> 
 
      
      <apex:column headerValue="Courses"  >
      <apex:inputField value="{!stu.Courses__c}" />
      </apex:column>
      <apex:column headerValue="Professor" >
      <apex:inputField value="{!stu.Professor__c}"/>
      </apex:column>
      <apex:column headerValue="Final Grade" >
      <apex:inputField value="{!stu.Final_Grade__c}" />
      </apex:column>
      <apex:column headerValue="Action" >
 <apex:commandButton value="Delete" action="{!deleteRow}" reRender="hp">
 <apex:param name="rowIndex" value="{!rowNumber}"/>
 </apex:commandButton>
 <apex:variable var="rowNumber" value="{!rowNumber+1}"/>
 </apex:column> 
 
      
    
   
      
      
</apex:pageBlockTable>

<apex:commandButton action="{!addRow}" value="Add Course" reRender="hp"/>

 

</apex:pageBlockSection>


    </apex:pageBlock>
   </apex:form>
</apex:page>
Controller Code:
public class addFunction {

    
     public Student__c s;
 public Student__c del;
 public List<Student__c> addcourseList {get;set;}
 public List<Student__c> delcourseList {get;set;}
 public List<Student__c> courseList {get;set;}
 public Integer totalCount {get;set;}
 public Integer rowIndex {get;set;}
 
 public List<Student__c> delCourse {get; set;} 
 public addFunction(ApexPages.StandardController controller) {

    
 
 s = (Student__c)controller.getRecord();
 courseList = [Select Courses__c ,Professor__c,Final_Grade__c from Student__c  ];
 totalCount = courseList.size();
 
 delcourseList = new List<Student__c>();
 delCourse = new List<Student__c>();
 }
 
 public void addRow(){
 addcourseList = new List<Student__c>();
 courseList.add(new Student__c ());
 }
 
 public PageReference Save(){
 
 upsert courseList;
 delete delcourseList;
 return (new ApexPages.StandardController(s)).view();
 } 
 public void deleteRow(){
 
 rowIndex = Integer.valueOf(ApexPages.currentPage().getParameters().get('rowIndex'));
 System.debug('rowbe deleted ' + rowIndex );
 System.debug('rowm to be deleted '+courseList[rowIndex]);
 del = courseList.remove(rowIndex);
 delcourseList.add(del);
 }
 }
Error:
Visualforce Error
Help for this Page
System.DmlException: Upsert failed. First exception on row 0 with id a033600000RQRQjAAP; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Courses]: [Courses]
Error is in expression '{!Save}' in component <apex:commandButton> in page student_details_1: Class.addFunction.Save: line 32, column 1
Class.addFunction.Save: line 32, column 1

 
Hello,
I have created app related to university.In this for Student object I need to show some information in one table with 4 columns.So I created table.But now I want to show this table to my Students tab(Object:Student).I created a section named course details on Student object,in this section I want to show this table.So how can I use my visualforce code there?

I tried overriding by using  'Buttons, Links, and Actions' but then it's come up with just a one section(only VF code).
I have two section in my tab  (1. Student Detail ,2.Course Detail) . And I want to replace this Course Details section  with my VF code. And want to keep Student Detail section as it is.
Please guide.
Thanks.

 
 
I have created app related to university.In this for Student object I need to show some information in one table with 4 columns.
Please guide me how to create table in custom object using Visualforce.

Here I am posting my code which I tried.

<apex:page Controller="Student">
   <apex:pageBlock title="Course Details">
     <apex:pageBlockTable value="{!Student_c}" var="stu">
      <apex:column value="{!stu.Sr_no__c}"/>
      <apex:column value="{!stu.Course_1__c}"/>
      <apex:column value="{!stu.Professor__c}"/>
      <apex:column value="{!stu.Final_Grade__c}"/>
</apex:pageBlockTable>

      </apex:pageBlock>
</apex:page>
----------------------------------------------------------------------
Error: Unknown property 'String.Sr_no__c'



Thanks.

Hello,I am preparing for administration certification.And for that I am following TRAILHEAD.Can you guide me TRAILHEAD follows which release or it isin general for learing purpose?
Hello,
I created table in my custom object.But now I want to add new row to add more records.Though I created it with 'AddRow' button.
But when I click on that button it's showing no change. Please help with this.
Here I am posting my code:
<apex:page standardController="Student__c" extensions="addFunction">
<apex:form >
   
   <apex:sectionHeader title="Student Edit" subtitle="New Student"/>
  <apex:pageBlock mode="edit" >
  <apex:pageBlockButtons >
  <apex:commandButton action="{!Save}" value="Save"/>
  <apex:commandButton action="{!Cancel}" value="Cancel"/>
  </apex:pageBlockButtons>
   <apex:pageBlockSection title="Student Details" columns="1" >
   
     
     <apex:inputField value="{!Student__c.Student_Id__c}"/>
     <apex:inputField value="{!Student__c.Name}"/>
     <apex:inputField value="{!Student__c.Last_Name__c}"/>
     <apex:inputField value="{!Student__c.Contact_Number__c}" />
     <apex:inputField value="{!Student__c.Email_Id__c}"/>
     <apex:inputField value="{!Student__c.Address__c}"/>
     <apex:inputField value="{!Student__c.Degree__c}"/>
     <apex:inputField value="{!Student__c.Department__c}"/>
     
  </apex:pageBlockSection>
  

   <apex:pageBlockSection title="Course Details" id="hp">
   <apex:pageMessages />
 <apex:variable var="rowNumber" value="{!0}"/>
 
 
   
   
   <apex:pageBlockTable value="{!Student__c}" var="stu">
   <apex:column headerValue="No." style="width:20px; text-align:center;" headerClass="centertext">
 <apex:outputText value="{0}" style="text-align:center;"> 
 <apex:param value="{!rowNumber+1}" /> 
 </apex:outputText>
 </apex:column> 
 
      
      <apex:column headerValue="Courses"  >
      <apex:inputField value="{!stu.Courses__c}" />
      </apex:column>
      <apex:column headerValue="Professor" >
      <apex:inputField value="{!stu.Professor__c}"/>
      </apex:column>
      <apex:column headerValue="Final Grade" >
      <apex:inputField value="{!stu.Final_Grade__c}" />
      </apex:column>
      <apex:column headerValue="Action" >
 <apex:commandButton value="Delete" action="{!deleteRow}" reRender="hp">
 <apex:param name="rowIndex" value="{!rowNumber}"/>
 </apex:commandButton>
 <apex:variable var="rowNumber" value="{!rowNumber+1}"/>
 </apex:column> 
 
      
    
   
      
      
</apex:pageBlockTable>

<apex:commandButton action="{!addRow}" value="Add Course" reRender="hp"/>

 

</apex:pageBlockSection>


    </apex:pageBlock>
   </apex:form>
</apex:page>
Controller Code:
public class addFunction {

    
     public Student__c s;
 public Student__c del;
 public List<Student__c> addcourseList {get;set;}
 public List<Student__c> delcourseList {get;set;}
 public List<Student__c> courseList {get;set;}
 public Integer totalCount {get;set;}
 public Integer rowIndex {get;set;}
 
 public List<Student__c> delCourse {get; set;} 
 public addFunction(ApexPages.StandardController controller) {

    
 
 s = (Student__c)controller.getRecord();
 courseList = [Select Courses__c ,Professor__c,Final_Grade__c from Student__c  ];
 totalCount = courseList.size();
 
 delcourseList = new List<Student__c>();
 delCourse = new List<Student__c>();
 }
 
 public void addRow(){
 addcourseList = new List<Student__c>();
 courseList.add(new Student__c ());
 }
 
 public PageReference Save(){
 
 upsert courseList;
 delete delcourseList;
 return (new ApexPages.StandardController(s)).view();
 } 
 public void deleteRow(){
 
 rowIndex = Integer.valueOf(ApexPages.currentPage().getParameters().get('rowIndex'));
 System.debug('rowbe deleted ' + rowIndex );
 System.debug('rowm to be deleted '+courseList[rowIndex]);
 del = courseList.remove(rowIndex);
 delcourseList.add(del);
 }
 }
Error:
Visualforce Error
Help for this Page
System.DmlException: Upsert failed. First exception on row 0 with id a033600000RQRQjAAP; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Courses]: [Courses]
Error is in expression '{!Save}' in component <apex:commandButton> in page student_details_1: Class.addFunction.Save: line 32, column 1
Class.addFunction.Save: line 32, column 1

 
Hello,
I have created app related to university.In this for Student object I need to show some information in one table with 4 columns.So I created table.But now I want to show this table to my Students tab(Object:Student).I created a section named course details on Student object,in this section I want to show this table.So how can I use my visualforce code there?

I tried overriding by using  'Buttons, Links, and Actions' but then it's come up with just a one section(only VF code).
I have two section in my tab  (1. Student Detail ,2.Course Detail) . And I want to replace this Course Details section  with my VF code. And want to keep Student Detail section as it is.
Please guide.
Thanks.

 
 
I have created app related to university.In this for Student object I need to show some information in one table with 4 columns.
Please guide me how to create table in custom object using Visualforce.

Here I am posting my code which I tried.

<apex:page Controller="Student">
   <apex:pageBlock title="Course Details">
     <apex:pageBlockTable value="{!Student_c}" var="stu">
      <apex:column value="{!stu.Sr_no__c}"/>
      <apex:column value="{!stu.Course_1__c}"/>
      <apex:column value="{!stu.Professor__c}"/>
      <apex:column value="{!stu.Final_Grade__c}"/>
</apex:pageBlockTable>

      </apex:pageBlock>
</apex:page>
----------------------------------------------------------------------
Error: Unknown property 'String.Sr_no__c'



Thanks.

Hello,I am preparing for administration certification.And for that I am following TRAILHEAD.Can you guide me TRAILHEAD follows which release or it isin general for learing purpose?