2

I have the following basic VF page to update fields of an Asset object from a Case page:

<apex:page standardController="Case" >

<apex:form >
    <apex:pageBlock title="Update Asset Firmware" mode="edit">

        <apex:pageBlockButtons >
            <apex:commandButton value="Save" action="{!save}"/>
            <apex:commandButton value="Cancel" action="{!cancel}"/>
        </apex:pageBlockButtons>

        <apex:pageBlockSection columns="1">
                <apex:outputField value="{!case.AssetId}"/>
                <apex:inputField value="{!case.Asset.FW_version__c}"/>
                <apex:inputField value="{!case.Asset.FW_Confirmed_Date__c}"/>
        </apex:pageBlockSection>

    </apex:pageBlock>
</apex:form>

Everything is displayed as I would expect, but clicking the Save button does not actually save the updates made to the records.

Sorry for the very basic question - but looking at the example code on salesforce.com, It seems that this should work. What am I missing?

2
  • You are trying to update values on the Asset object through a relationship, which is not permissible. You can only save fields on the Case.
    – ScottW
    Commented Sep 16, 2014 at 17:27
  • 1
    Ok - this set me on the right path. I changed the StandardController to Asset and then appending the AssetID to button URL. Now it works! Thanks!
    – AaronC
    Commented Sep 16, 2014 at 17:39

2 Answers 2

2

I don't think there is anything wrong with the way you are calling the Save method. My guess is that there is an error somewhere when it is trying to save (maybe a validation rule or a required field missing). If you add the tag <apex:pageMessages/> to your page, I am guessing it will show you what the error is.

Try adding that tag like below

<apex:page standardController="Case" >
<apex:pageMessages/>
<apex:form >
0

Here is the solution:

<apex:page standardController="Asset" >

<apex:form >
    <apex:pageBlock title="Update Asset Firmware" mode="edit">

        <apex:pageBlockButtons >
            <apex:commandButton value="Save" action="{!save}"/>
            <apex:commandButton value="Cancel" action="{!cancel}"/>
        </apex:pageBlockButtons>

        <apex:pageBlockSection columns="1">
                <apex:outputField value="{!Asset.Name}"/>
                <apex:inputField value="{!Asset.FW_version__c}"/>
                <apex:inputField value="{!Asset.FW_Confirmed_Date__c}"/>
        </apex:pageBlockSection>

    </apex:pageBlock>
</apex:form>

Then reference the Asset ID in the button URL on the Case page:

https://xxx.salesforce.com/apex/Update_Firmware?id={!Case.AssetId}

Now working like a charm!

You must log in to answer this question.

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