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
mahendermahender 

i have written solution for milestone issue#!7 but i am getting visualforce error

InboundRequestpage


<apex:page controller="DependentObjects" id="UseCaseDisplay" label="FeatureCategoryReport" >

  <apex:form >
  <apex:pageBlock title="Send Request" mode="edit" id="thePageBlock" >

      <apex:pageBlockSection columns="1">

        <apex:pageBlockSectionItem >
        <apex:outputLabel value="Request Name" />
        <apex:inputText value="{!taskName}" />
        </apex:pageBlockSectionItem>
        
        <apex:pageblockSectionItem >
        <apex:outputLabel value="Select Project:" for="project"/>
        <apex:selectList value="{!project}" size="1" id="project">
        <apex:selectOptions value="{!projects}"/>
        <apex:actionSupport event="onchange" rerender="milestone"/>
        </apex:selectList>
        </apex:pageblockSectionItem>
        
        <apex:pageBlockSectionItem >
        <apex:outputLabel value="Select MileStone" for="milestones"/>
        <apex:selectList value="{!milestone}" size="1" id="milestone">
         <apex:selectOptions value="{!milestones}"/>
        </apex:selectList>
        </apex:pageBlockSectionItem>
                    
        <apex:pageBlockSectionItem >
        <apex:outputLabel value="Task Description" />
        <apex:inputTextarea value="{!description}"/>
        </apex:pageBlockSectionItem>
        
        <apex:pageBlockSectionItem >
        <apex:outputLabel value="Due Date" />
        <apex:inputText value="{!dueDate}"/>
        </apex:pageBlockSectionItem>
        </apex:pageBlockSection>
      
      <apex:pageBlockButtons >
      <apex:commandButton value="send request" action="{!save}"/>
     </apex:pageBlockButtons>
    </apex:pageBlock>
     </apex:form></apex:page>


DependentObjects apex class:


public class DependentObjects {
  String project;
    String milestone;
    String taskName;
    String description;
    String status='New';
    String dueDate;
    
    public String getProject() { return this.project; }

    public void setProject(String s) { this.Project = s; }

    public String getMilestone() { return this.Milestone; }

    public void setMileStone(String s) { this.MileStone = s; }
    
    public void setTaskName(String s) { this.taskName = s; }
    
    public String getTaskName() { return this.taskName; }

    public void setDescription(String s) { this.Description = s; }
    
    public String getDescription() { return this.Description; }
        
    public void setStatus(String s) { this.status = s; }
    
    public String getStatus() { return this.Status; }
            
    public void setDueDate(String s) { this.dueDate = s; }
    
    public String getDueDate() { return this.dueDate; }

    public List<SelectOption> getProjects() {

      List<SelectOption> optionList = new List<SelectOption>();
      optionList.add(new SelectOption('','-empty-'));
      for (my24X7PayTmA__Milestone1_Project__c pr : [select id,Name from my24X7PayTmA__Milestone1_Project__c     order by Name])
      {

        optionList.add(new SelectOption(pr.id,pr.Name));

      }
      return optionList;    
    }

    public List<SelectOption> getMilestones() {

      List<SelectOption> optionList = new List<SelectOption>();

      optionList.add(new SelectOption('', '- None -'));

          if(project!=null)
           {
            for (my24X7PayTmA__Milestone1_Milestone__c m : [select id,Name from my24X7PayTmA__Milestone1_Milestone__c where Project__c=:project])
            {

            optionList.add(new SelectOption(m.id,m.Name));

            }

           }

      return optionList;

    }
    public PageReference save()
    {
   my24X7PayTmA__MilestoneProjectRequest__c  pr=new my24X7PayTmA__MilestoneProjectRequest__c(Name=taskName,my24X7PayTmA__Detail__c=description,my24X7PayTmA__Project__c=project,my24X7PayTmA__Milestone__c=milestone,my24X7PayTmA__Status__c=status);
    insert pr;
    return page.InboundRequestpage;
    }
}



RecevingRequest page:


<apex:page controller="RequestList" sidebar="false" showHeader="false">
<font size="8">List of open requests</font>
<center>
<apex:form >
<apex:dataTable value="{!lst}" var="list" cellpadding="5" border="2" Bgcolor="orange">
<apex:column >
<apex:facet name="header">Related Project</apex:facet>
<apex:outputField value="{!list.name}" />
</apex:column>
<apex:column >
<apex:facet name="header">Related Project</apex:facet>
<apex:outputField value="{!list.Project__c}"/>
</apex:column>
<apex:column >
<apex:facet name="header">Related Milestone</apex:facet>
<apex:outputField value="{!list.Milestone__c}"/>
</apex:column>
<apex:column >
<apex:facet name="header">Description</apex:facet>
<apex:outputField value="{!list.Detail__c}"/>
</apex:column>
<apex:column >
<apex:selectList value="{!action}" size="1">
<apex:selectOption itemLabel="Accept" itemValue="{!list.id}" ></apex:selectOption>
<apex:selectOption itemLabel="Reject" itemValue="{!list.id}" ></apex:selectOption>

</apex:selectList>
<apex:commandButton value="Do Action" action="{!doit}" reRender="out"> 
<apex:param name="Name" value="{!list.name}" 
assignTo="{!Name}"/> 
</apex:commandButton> 
</apex:column>
</apex:dataTable>
</apex:form>
</center>
<apex:outputPanel id="outing">
the id value is:<apex:outputText value="{!action}" id="out"></apex:outputText>
</apex:outputPanel>
</apex:page>


RequestList Apex class:


public class RequestList{
List<my24X7PayTmA__MilestoneProjectRequest__c   > lst;
String id;
public String action;
public void setAction(String data){this.action=data;}
public String getAction(){return this.action;}
public String getId(){return id;}
public List<my24X7PayTmA__MilestoneProjectRequest__c    > getLst(){
lst=[select id,my24X7PayTmA__Project__c,my24X7PayTmA__Milestone__c,Name,my24X7PayTmA__Detail__c from my24X7PayTmA__MilestoneProjectRequest__c   where my24X7PayTmA__Status__c='New'];
return lst;
}

public  void doit(){
List<my24X7PayTmA__MilestoneProjectRequest__c> lst=[select my24X7PayTmA__Project__c,my24X7PayTmA__Milestone__c,Name,my24X7PayTmA__Detail__c,my24X7PayTmA__Status__c from my24X7PayTmA__MilestoneProjectRequest__c where ID=:id];
lst[0].my24X7PayTmA__Status__c='Accepted';
Milestone1_Task__c task=new Milestone1_Task__c(Name=lst[0].Name,my24X7PayTmA__Description__c=lst[0].my24X7PayTmA__Detail__c,my24X7PayTmA__Project_Milestone__c=lst[0].my24X7PayTmA__Milestone__c);
update lst;
insert task;
}
}

 hi 

i have written one visualforce page i.e inboundRequestPage any user can send request and for this page i developed apex class and

i wrote another page for adminstrator to accept those tasks in this page two options provided one is Accept and one Reject when admin select  Accept and when click DoAction button then automatically doIt() will ececte and the particuler task should assign to particuler milestone ..

 

 

where i am getting probem is when i click DoAction button it is calling doIt() methiod but i am geeting visualforce error i.e

 

Visualforce Error

System.ListException: List index out of bounds: 0 

Class.my24X7PayTmA.RequestList.doit: line 15, column 5 External entry point

 

but when i gave the task name that task converting as a task but when i wrote an id i am getting above mentioned error

 

would you please help me........

 

ReidCReidC

Am curious to hear more about why you are using a VF page and a controller.  Is this something that can't be done using standard functionality?  Could we simplify it to use standard functionality?