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
Girbson Bijou 8Girbson Bijou 8 

Multiple Child Records from Parent Related List: Url No longer exist

I need to create Multiple Child Records from Parent Related List but i get the Error: "URL No Longer Exists" but the data saved in the database. Also, it seem that the Parent Id does not populate autonmatically so, i have to add it manually. I want to notice that I add the child page as a related list of the parent. The Parent Obejct is Devery__c, the child is Item_Distributed__c Here is my code:
public class AddOrderItem {

    public String Delivery { get; set; }
Id DeliveryId;
public List<Item_Distributed__c> listOrderItem {get;set;}
public Integer rowNum{get;set;}

public AddOrderItem(ApexPages.StandardController controller){
   Id OrderItemId = ApexPages.currentPage().getParameters().get('OrderItemId');
    DeliveryId=ApexPages.currentPage().getParameters().get('DeliveryId');
    listOrderItem = new List<Item_Distributed__c>();
    listOrderItem.add(new Item_Distributed__c());

}

public pagereference insertOrderItem(){
    insert listOrderItem;
    Pagereference page=new pagereference('/'+DeliveryId);
    Return page;
}

public void insertRow(){
    listOrderItem.add(new Item_Distributed__c());
}

public void delRow(){
    rowNum = 
Integer.valueof(apexpages.currentpage().getparameters().get('index'));
    listOrderItem.remove(rowNum);
}
}

//VF Page

<apex:page StandardController="Delivery__c"  Extensions="AddOrderItem" showHeader="false" sidebar="false" >
<apex:form >
    <apex:variable var="rowNum" value="{!0}" />
    <apex:pageBlock >
        <apex:variable var="rowNum" value="{!0}" />
        <apex:PageBlockTable value="{!listOrderItem}" var="int">
        <apex:facet name="footer">
            <apex:commandLink value="Add" action="{!insertRow}"/>
            </apex:facet>
            <apex:column headerValue="Quantity">
                <apex:inputField value="{!int.Quantity__c}"/>                                      
            </apex:column>
            <apex:column headerValue="Product">
            <apex:inputField value="{!int.Product__c}"/> 
            </apex:column>
         <apex:column headerValue="Product">
            <apex:inputField value="{!int.Delivery__c}"/> 
            </apex:column>  
             <apex:column headerValue="Delete">
            <apex:commandLink style="font-size:15px; font-weight:bold; text-align:center;color:red;" value="X" action="{!delRow}">
                <apex:param value="{!rowNum}" name="index"/>
                </apex:commandLink>
                <apex:variable var="rowNum" value="{!rowNum+1}"/>
            </apex:column>
        </apex:PageBlockTable>
    <apex:pageBlockButtons >
        <apex:commandButton value="Save" action="{!insertOrderItem}"/>
        </apex:pageBlockButtons>
    </apex:pageBlock>

  </apex:form>
</apex:page>

User-added image
Syed Insha Jawaid 2Syed Insha Jawaid 2
Hi Girbson

Could you check the value of 'DeliveryId'.It may not contain any value.

Cheers!!!