0

I have a pageblock table and I enabled InlineEditingSupport. However, everytime I edit it and click quick save, the last row is the only record that is being updated. I tried making my own method but I don't think I am getting it right. enter image description here

VF PAGE

    <apex:pageBlock title="Tiers">
        <p style="font-size: 150%;"><b>Quote Number:</b>&nbsp;&nbsp;{!SBQQ__Quote__c.Name}</p><br/><br/>
        <apex:pageBlockTable value="{!existingTiers}" var="tiers">
            <apex:column headerValue="Tier Start" value="{!tiers.Tier_Start__c}"/>
            <apex:column headerValue="Tier End" value="{!tiers.Tier_End__c}"/>
            <apex:column headerValue="PMPM" value="{!tiers.Price__c}"/>
            <apex:inlineEditSupport/>
        </apex:pageBlockTable>
             <apex:commandButton value="Quick Save" Action="{!Quicksave}"/>
    </apex:pageBlock>




    <apex:pageBlock title="Add Tiers">
        <table>
            <tr>
                <th>Tier Start</th>
                <th>Tier End</th>
                <th>PMPM</th>
            </tr>
            <apex:repeat value="{!listTier}" var="Addtier">
                <tr>
                    <td class="withborder" style="width: 15%;"><apex:inputField value="{!Addtier.Tier_Start__c}" /></td>
                    <td class="withborder" style="width: 15%;"><apex:inputField value="{!Addtier.Tier_End__c}" /></td>
                    <td class="withborder" style="width: 30%;"><apex:inputField value="{!Addtier.Price__c}" /></td>
                </tr>
            </apex:repeat>
        </table>
        <apex:commandButton value="Add" Action="{!add}"/>
        <apex:commandButton value="Save" Action="{!Save}"/>
        <apex:commandButton value="Cancel" Action="{!cancel}"/>
    </apex:pageBlock>
</apex:form>

CONTROLLER

public class Quote_AdditionalTiersController {
ApexPages.StandardController sController;
public SBQQ__Quote__c getQuote{get; set;}
public Additional_Tier__c setAT{get; set;}
public List<Additional_Tier__c> listTier{get; set;}
public List<Additional_Tier__c> existingTiers{get; set;}


public Quote_AdditionalTiersController(ApexPages.StandardController sc){
    sController = sc;
    this.getQuote = (SBQQ__Quote__c)sc.getRecord();
    setAT = new Additional_Tier__c();

    listTier = new List<Additional_Tier__c>{
        new Additional_Tier__c(Quote__c = getQuote.Id)
            };

                existingTiers = [SELECT Id, Quote__c, Tier_Start__c, Tier_End__c, Price__c FROM Additional_Tier__c WHERE Quote__c =: getQuote.Id];

}

public void add(){
    listTier.add(new Additional_Tier__c(Quote__c = getQuote.Id));
}

public PageReference save() {
    // setAT.Quote__c= getQuote.Id;
    List<Additional_Tier__c> newTier = new List<Additional_Tier__c>();
    for(Additional_Tier__c tier: listTier){
        if(tier.Tier_Start__c != null && tier.Tier_End__c != null && tier.Price__c != null ){
            newTier.add(tier);
        }
    }
    insert newTier;
    return new PageReference ('/'+getQuote.Id);
}

public PageReference Quicksave(){
    sController.save();
    PageReference pr = new PageReference('/apex/Quote_AdditionalTiers?id='+sController.getId());
    pr.setRedirect(true);
    return pr;
}

}

  • could you highlight exactly what part of your code does not seem to work as you expect? – glls Apr 26 '19 at 18:21
  • I think it has something to do with my Quicksave constructor – Reina Apr 26 '19 at 19:01
0

I already resolve this by modifying my vf page

<apex:page standardController="SBQQ__Quote__c" extensions="Quote_AdditionalTiersController" >
<apex:form >        
    <apex:pageBlock title="Tiers">
        <p style="font-size: 150%;"><b>Quote Number:</b>&nbsp;&nbsp;{!SBQQ__Quote__c.Name}</p><br/><br/>
        <apex:pageBlockTable value="{!existingTiers}" var="tiers" >              
            <apex:column >
                <apex:outputField value="{!tiers.Tier_Start__c}" id="TierStart" /> 
                <apex:facet name="header">Tier Start</apex:facet>
            </apex:column>
            <apex:column >
                <apex:outputField value="{!tiers.Tier_End__c}" id="TierEnd" /> 
                <apex:facet name="header">Tier End</apex:facet>
            </apex:column>
            <apex:column >
                <apex:outputField value="{!tiers.Price__c}" id="Price" /> 
                <apex:facet name="header">PMPM</apex:facet>
            </apex:column>   
            <apex:inlineEditSupport />
        </apex:pageBlockTable>
        <apex:pageBlockButtons location="Bottom">
            <apex:commandButton value="Quick Save" Action="{!Quicksave}" id="saveBtn"/>
        </apex:pageBlockButtons>                 
    </apex:pageBlock>        
    <apex:pageBlock title="Add Tiers">
        <table>
            <tr>
                <th>Tier Start</th>
                <th>Tier End</th>
                <th>PMPM</th>
            </tr>
            <apex:repeat value="{!listTier}" var="Addtier">
                <tr>
                    <td class="withborder" style="width: 15%;"><apex:inputField value="{!Addtier.Tier_Start__c}" /></td>
                    <td class="withborder" style="width: 15%;"><apex:inputField value="{!Addtier.Tier_End__c}" /></td>
                    <td class="withborder" style="width: 30%;"><apex:inputField value="{!Addtier.Price__c}" /></td>
                </tr>
            </apex:repeat>
        </table>
        <apex:commandButton value="Add" Action="{!add}"/>
        <apex:commandButton value="Save" Action="{!Save}"/>
        <apex:commandButton value="Cancel" Action="{!cancel}"/>
    </apex:pageBlock>
</apex:form>

I had to separate each by using opening and closing indent and use to display the fields.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.