1

Similar to this question: Update on account is not working

I am trying to change the value of a record's field by whatever the user inputs on a visualforce page. The visualforce page is written in HTML.

Visualforce Page:

<apex:page controller="RepricingController" sidebar="false">

<script>
function checkForNAeBay(id, partslink, store) {
    var a = "http://google.com";
    if (id === "NA" || id === null || id === "") {
        a = "http://stores.ebay.com/" + store + "?_dmd=2&_nkw=" + partslink;
    } else {
        a = "http://www.ebay.com/itm/" + id;
    }
    return a;
}

function getURL(){
    return "http://www.google.com";
}
</script>

<apex:form >
    <apex:actionFunction name="updateAll" action="{!updateAll}"/>
</apex:form>

<html>
    <head>
        <title>Repricing Table</title>
    </head>
    <body>
        <table border="1" align="">
            <apex:repeat value="{!repricing_objects}" var="repricing" id="main_repeat">
                <tr>
                    <td>
                        <div class="dropdown" style="display:{!If(repricing.PDI_Repricing__Our_eBay_ID_Depot__c != null,'','none')}">
                            <p class="clickablefont">
                                {!repricing.PDI_Repricing__Our_eBay_Price_Depot__c}
                            </p>
                            <div class="dropdown-content">
                                <p>Shipping: {!repricing.PDI_Repricing__Our_eBay_Shipping_Depot__c}</p>
                                <a href="javascript:window.open(checkForNAeBay('{!repricing.PDI_Repricing__Our_eBay_ID_Depot__c}', '{!repricing.PDI_Repricing__Linked_Product__r[$Setup.PDI_Repricing__Repricing_Settings__c.PDI_Repricing__Partslink_Field__c]}', '{!$Setup.PDI_Repricing__Repricing_Settings__c.PDI_Repricing__HeadlightsDepot_Store_Label__c}'));">
                                View Product
                                </a>
                                <a href="javascript:window.open(getURL());" target="_blank">TEST</a>
                            </div>
                        </div>
                        <div class="dropdown" style="display:{!If(repricing.PDI_Repricing__Our_eBay_ID_Depot__c == null,'','none')}">
                            <img src="http://icons.iconarchive.com/icons/custom-icon-design/mono-general-1/512/alert-icon.png" width="20" height="20" class="clickable"/>
                            <div class="dropdown-content">
                                <p>No Item ID found!</p>

                                <input value="{!repricing.PDI_Repricing__Our_eBay_ID_Depot__c}"/>

                                <button type="button" onclick="updateAll()">
                                    Update
                                </button>

                                <a href="javascript:window.open(checkForNAeBay('{!repricing.PDI_Repricing__Our_eBay_ID_Depot__c}', '{!repricing.PDI_Repricing__Linked_Product__r[$Setup.PDI_Repricing__Repricing_Settings__c.PDI_Repricing__Partslink_Field__c]}', '{!$Setup.PDI_Repricing__Repricing_Settings__c.PDI_Repricing__HeadlightsDepot_Store_Label__c}'));">
                                Find ID
                                </a>
                        </div>
                    </td>
                </tr>
            </apex:repeat>
        </table>
    </body>
</html>
</apex:page>

Controller:

public List<PDI_Repricing__Repricing_Info__c> repricing_objects {get;set;}



public RepricingController(){
    this.repricing_objects = get_repricing_info();
}

public PageReference updateAll() {
    System.debug('UPDATING: ');
    for (PDI_Repricing__Repricing_Info__c o : repricing_objects){
        System.debug(o.PDI_Repricing__Our_eBay_ID_Depot__c);
    }
    update repricing_objects;
    return null;
}

After a value is placed in the input box and the 'update' button is clicked, the page refreshes and the value of the field in Pricing Info does not change. I also have page messages on the page and no errors appear in the console.

I'm only showing relevant code, so if you need more code please ask.

So any ideas why my record is not being updated? Nothing is being updated, in fact.

EDIT:

Debug:

11:57:17:037 USER_DEBUG [101]|DEBUG|UPDATING:

11:57:17:039 USER_DEBUG [103]|DEBUG|370924410604 //note this was already here, not put in by the user

11:57:17:040 USER_DEBUG [103]|DEBUG|null

11:57:17:041 USER_DEBUG [103]|DEBUG|null

11:57:17:042 USER_DEBUG [103]|DEBUG|null

11:57:17:043 USER_DEBUG [103]|DEBUG|null

11:57:17:044 USER_DEBUG [103]|DEBUG|null

  • is that entire page given? what's inside JS method updateAll()? Does that really call controller method? – kurunve Jun 22 '16 at 15:47
  • Edited. The entire page is not given (only like 5% of it is), added the JS method, sorry. The updateAll() in the controller runs properly, and it does print the debug information, but the objects are not updated (the value from the input box is never seen on the debug console) – Konnor McDowell Jun 22 '16 at 15:48
  • Change your HTML <button> to <apex:commandButton value="Update" action="{!updateAll}" /> – dBeltowski Jun 22 '16 at 15:51
  • @DougB the button is wrapped in html and is outside of any apex forms or page blocks, and would require me to wrap it in an apex form, does that matter? – Konnor McDowell Jun 22 '16 at 15:52
  • Yes, the button should be in the <apex:form /> tag. – dBeltowski Jun 22 '16 at 15:55
3

Instead of

<input value="{!pricing.Our_ID__c}"/>

you can try,

<apex:inputField value="{!pricing.Our_ID__c}"/>

And should be inside the form tag.

Hope this helps :)

  • This worked (I had to wrap the whole HTML in a form)! Thank you! – Konnor McDowell Jun 22 '16 at 17:06

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.