1

I am trying to create an inline visual force page very similar look and feel and the same functionality as of a child object.

I am stuck in mid-way if anyone has already had a requirement like this or had worked on it can help me out.

I have added New Button (Which should take me to the Item Creation page, this is achieved but I am not able to pass the account id (from parent to the child) to the Item page.

I have Edit CommandLink (Edit-Button) but when I click on edit nothing is happening.

Also I have Delete CommandLink (which Delete-Button) but when I click on edit nothing is happening.

Below is my VF Page Code:-

<apex:page StandardController="Account" extensions="ItemInlinevf" tabStyle="account">
 <apex:form >

 <apex:pageBlock >
 <apex:pageBlockButtons location="top">      
    <apex:commandbutton value="New" action="{!URLFOR($Action.Item__c.New)}"/>
</apex:pageBlockButtons>

    <apex:pageBlockSection columns="1" >    

       <apex:pageBlockTable value="{!itemlist}" var="c">   
<apex:column headerValue="Action" >
<apex:inputCheckbox value="{!c.Name}" selected="true"/>

<apex:commandLink action="{!editItem}" id="editLink" value="Edit">
<apex:param name="cid" value="{!c.id}" assignTo="{!edidtItem}"/>
</apex:commandLink>

<apex:commandLink value="Del" onclick="return confirm('Are you sure?');" action="{!URLFOR($Action.Item__c.Delete)}"/> 

</apex:column>
           <apex:column value="{!c.Name}" headerValue="Item Name"/>
          <apex:column value="{!c.Status__c}" headerValue="Status"/>
           <apex:column value="{!c.Actual_Close_Date__c}" headerValue="Actual Close Date"/>
            <apex:column value="{!c.Open_Date__c}" headerValue="Open Date"/>
        </apex:pageBlockTable>  
      </apex:pageBlockSection>
      </apex:pageBlock> 
 </apex:form>
</apex:page>

Apex Controller Class:

public class ItemInlinevf{
public string ids {get;set;}
    public ItemInlinevf(ApexPages.StandardController controller) {
      ids=ApexPages.currentPage().getParameters().get('id');
    }
public String ecid {get;set;} 
public String dcid {get;set;} 
public Item__c[] getitemlist(){
     try {     
         item__c[] itemlist=[select id, 
                                    name,
                                    Status__c,
                                    Actual_Close_Date__c,
                                    Open_Date__c,
                                    Supplier_Name__c 
                                    from Item__c 
                                    where Supplier_Name__c =:ids 
                                    and status__c='Open' 
                                    order by createddate desc];                                     
             return itemlist;
      } catch (QueryException e)

{
             ApexPages.addMessages(e);   
             return null;
      }
    }
public Pagereference editItem()
   {
       Pagereference newpage = new Pagereference ('/a0C25000000OSET/e?retURL=%2F0012500000BJcmk');
       newpage.setRedirect(True);
       return newpage; 
   }
 }

Child Object create by Master-Detail Relationship

Inline Visual Force Page created on Account Object similar to Child Object

1 Answer 1

4

You can get current record id by making few changes to your constructor. Use below to get current record id in your controller.

Id accId ;
public ItemInlinevf(ApexPages.StandardController controller) {
  Account acc = (Account)controller.getRecord();
  accId = acc.Id ;
}
3
  • Hello Sneha Thanks for your prompt response. But can you help me out in achieving the Edit and Delete Commanding button functionality.
    – user23858
    Aug 11, 2015 at 16:56
  • Hello Sneha, The above code is not working, I am not able to get the Account Id in the Item Creation page when I am trying to create Item by clicking on New button.
    – user23858
    Aug 12, 2015 at 4:45
  • Id will be in accId variable and you can use this either on your controller or in VF page be declaring get;set property of this variable and also by declaring this to public. Aug 12, 2015 at 6:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .