Custom Action Column - Workaround

1. Create a formula field with the help of HYPERLINK() in the related list object.

Sample formula field with the help of HYPERLINK() in the related list object:


2. Add this field to the related list.

3. Create a Visualforce page and Controller for the required manupulation.

Sample Visualforce page:

<apex:page controller="EquipmentListController">
<apex:form >
    <apex:pageBlock rendered="{!equipmentBool}">
        <apex:pageBlockButtons location="top">
            <apex:commandButton value="New Equipment" action="{!newEquipment}"/>
        </apex:pageBlockButtons>
        <apex:pageBlockTable value="{!listEquipment}" var="eq">
            <apex:column value="{!eq.Name}"/>
            <apex:column value="{!eq.Delivery_Date__c}"/>
        </apex:pageBlockTable>
    </apex:pageBlock>
    <apex:pageBlock rendered="{!newEquipmentBool}">
        <apex:pageBlock >
            <apex:pageBlockSection >
                <apex:inputField value="{!equipment.Name}"/>
                <apex:inputField value="{!equipment.Delivery_Date__c}"/>
            </apex:pageBlockSection>
            <apex:pageBlockButtons >
                <apex:commandButton value="Save" action="{!insertEquipment}"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:pageBlock>
</apex:form>

</apex:page>

Sample Controller:

public class EquipmentListController {
    Id intId;
    public Boolean newEquipmentBool {get;set;}
    public Boolean equipmentBool {get;set;}
    public list<Equipment__c> listEquipment {get;set;}
    public Equipment__c equipment {get;set;}
    
    public EquipmentListController(){
        newEquipmentBool = false;
        equipmentBool = true;
        listEquipment = new list<Equipment__c>();
        equipment = new Equipment__c();
        intId = ApexPages.CurrentPage().getParameters().get('intId');        
        fetchEquipment();
    }
    
    public void newEquipment(){
        newEquipmentBool = true;
        equipmentBool = false;
    }
    
    public void insertEquipment(){
        newEquipmentBool = false;
        equipmentBool = true;
        equipment.Interest__c = intId;
        insert equipment;
        equipment = new Equipment__c();
        fetchEquipment();
    }
    
    public void fetchEquipment(){
        listEquipment = [SELECT Name, Delivery_Date__c FROM Equipment__c WHERE Interest__c = : intId];
    }

}

Output:





No comments:

Post a Comment