I have a visualforce page located on the case object that shows a table with assets that are related to that case. From the asset table you can update the asset serial number, click the custom save button and the asset serial number updates and saves.
The issue I am running into is that I added a checkbox to the asset table from the related case. When the checkbox is checked in the asset table and the save button is clicked the checkbox field on the case does not update or save.
Here is my visualforce page code.
<apex:page standardController="Case" extensions="pullEquipmentUpdateAssetClass">
<p></p>
<apex:pageblock id="Assets">
<br/>
<apex:form >
<apex:pageBlockTable value="{!Assets}" var="asset">
<apex:column value="{!asset.Product_Code_Display__c}"/>
<apex:column value="{!asset.Product_Description_Display__c}"/>
<apex:column value="{!asset.Delivery_Address__c}"/>
<apex:column value="{!asset.Serial_Number_Procurement__c}"/>
<apex:column headerValue="Serial Number"><apex:inputText value="{!asset.Serial_Number_Procurement__c}" required="true" /></apex:column>
<!-- this checkbox can be checked, but when the save button is clicked the checkbox field on the case does not update -->
<apex:column headerValue="Equipment has been pulled"><apex:inputCheckbox value="{!asset.Child_Fulfillment_Ticket__r.Equipment_Has_Been_Pulled__c}"/></apex:column>
</apex:pageBlockTable>
<apex:commandButton value="Save" action="{!saveSerialIdNumber}"/>
</apex:form>
</apex:pageblock>
</apex:page>
And here is my apex class:
public class pullEquipmentUpdateAssetClass {
public List<Asset> Assets{get;set;}
public Case Cases {get;set;}
public Case c {get;set;}
//Constructor
public pullEquipmentUpdateAssetClass(ApexPages.StandardController controller) {
c = (Case)controller.getRecord();
Cases = [SELECT id, Equipment_Has_Been_Pulled__c FROM Case WHERE id=: c.id LIMIT 1];
Assets = [SELECT id,Child_Fulfillment_Ticket__r.Equipment_Has_Been_Pulled__c,Serial_Number_Procurement__c,Name,Delivery_Address__c,Product_Code_Display__c,Product_Description_Display__c FROM Asset WHERE Serialized__c = true AND Child_Fulfillment_Ticket__c = :Cases.id];
}
//save button for serial number
public PageReference saveSerialIdNumber(){
update Assets;
update Cases;
Assets = [SELECT id,Child_Fulfillment_Ticket__r.Equipment_Has_Been_Pulled__c,Serial_Number_Procurement__c,Name,Delivery_Address__c,Product_Code_Display__c,Product_Description_Display__c FROM Asset WHERE Serialized__c = true AND Child_Fulfillment_Ticket__c = :Cases.id];
Cases = [SELECT id,Equipment_Has_Been_Pulled__c FROM Case WHERE id=: c.id];
return ApexPages.currentPage();
}
}
I am still fairly new to apex, so I am not super familiar with it
Child_Fulfillment_Ticket__r
pointing to?Child_Fulfillment_Ticket__r
is a lookup field on the asset that points to the case