You need to sign in to do that
Don't have an account?

Custom save button on visualforce page not saving all information
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.
I am still fairly new to apex, so I am not super familiar with it
Here is my visualforce page code.
<apex:page standardController="Case" extensions="pullEquipmentUpdateAssetClass"> <p></p> <!--List of Assets. Can update serial number of the asset from this table--> <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, 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; 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]; return ApexPages.currentPage(); } }
I am still fairly new to apex, so I am not super familiar with it
As you have already fetched cases on line 15. So just append below code on line 26.
Line 15 : Line 26:
This will solve your issue.
Do let me know if it helps you and close your query by marking it as solved.
Regards,
Santosh
All Answers
As you have already fetched cases on line 15. So just append below code on line 26.
Line 15 : Line 26:
This will solve your issue.
Do let me know if it helps you and close your query by marking it as solved.
Regards,
Santosh
I got it working, thank you for the help