• Ian Doney
  • NEWBIE
  • 30 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 6
    Replies
I have a visualforce page on the Workorder object that lists out all of the assets on an order. A user will fill out some input fields and click the update button. This saves all of the input fields to the related asset. There are also cases related to the assets that I need to update as well. I am able to show the fields from the related case that is related to the asset on the visualforce page, but I can't figure out how to get my save button to save the info for the related case. So basically the relationship goes WorkOrder > Asset > Case.

Here is my visualforce code:
<apex:form id="theForm"> 
        <apex:pageblock id="Assets">
            
                
                <apex:pageBlockTable rows="" id="pbt0" value="{!WorkOrder.Assets__r}" var="asset">
                
                    <apex:column rendered="{!asset.SBQQ__RequiredByAsset__c == null}" style="width:16.66666666666667%;" headerValue="Product Code"><!-- to take the label dynamically -->
                  		<apex:inputText style="width:94%;" disabled="true" styleClass="setupModelForId" value="{!asset.Product_Code_for_Paperless_Install_Docs__c}"></apex:inputText>
                    </apex:column>
                
                    
                    
                    <apex:column rendered="{!asset.SBQQ__RequiredByAsset__c == null}" style="width:20%;" headerValue="ID Number"><!-- to take the label dynamically -->
                    	<apex:inputText onchange="updateIdNumber(); return false;" style="width:94%;" styleClass="idNumber" value="{!asset.New_Asset_Install_LOC_ID_Number__c}"  />
                    </apex:column>
                    
                    	
                        
                    <apex:column rendered="{!asset.SBQQ__RequiredByAsset__c == null}" style="width:16.66666666666667%;" headerValue="B/W Meter"><!-- to take the label dynamically -->
                    	<apex:inputText required="true" styleClass="bwMeter" style="width:94%;" value="{!asset.New_Asset_Install_B_W_Meter__c}"  />
                    </apex:column>
                    
                    <apex:column rendered="{!asset.SBQQ__RequiredByAsset__c == null}" style="width:16.66666666666667%;" headerValue="Color Meter"><!-- to take the label dynamically -->
                    	<apex:inputText styleClass="colorMeter" style="width:94%;" value="{!asset.New_Asset_Install_Color_Meter__c}"  />
                    </apex:column>
                    
                    <apex:column rendered="{!asset.SBQQ__RequiredByAsset__c == null}" style="width:16.66666666666667%;" headerValue="I.P. Address"><!-- to take the label dynamically -->
                    	<apex:inputText styleClass="ipAddress" style="width:94%;" value="{!asset.New_Asset_Install_Equipment_IP_Address__c}"  />
                    </apex:column>
                    
                    <apex:column style="width:16.66666666666667%;" rendered="{!asset.SBQQ__RequiredByAsset__c == null}" headerValue="Install Date">
                    	<apex:inputField id="installDate" styleClass="installDate" value="{!asset.New_Equipment_Setup_and_Install_Ticket__r.Install_Date__c}"/>
                   	 </apex:column>
                        
                     <apex:column style="width:16.66666666666667%;" rendered="{!asset.SBQQ__RequiredByAsset__c == null}" styleClass="" headerValue=""><!-- to take the label dynamically -->
                            <apex:inputText disabled="true" style="" styleClass="setupIdNumber" value="{!asset.New_Asset_Setup_LOC_ID__c}"  />
                     </apex:column>
                        
                </apex:pageBlockTable>
			
			<apex:pageBlockButtons location="bottom">  
                 
                <apex:commandButton styleClass="verify" id="verify" onclick="verifySerialNumbers(); return false;" value="Verify" />
                
                <apex:commandButton oncomplete="congrats(); return false;" styleClass="update" id="update" disabled="" value="Update" action="{!saveSerialIdNumber}" />
       
            </apex:pageBlockButtons>
			
		</apex:pageBlock>
</apex:form>

And here is my class:
public class installUpdateAssetWorkOrderClass {

    private ApexPages.StandardController controller;
    
    public List<WorkOrderLineItem> WorkOrderLineItems{get;set;}

    public List<WorkOrderLineItem> WorkOrderLineItemsSupplies{get;set;}
    
    public List<Asset> Assets{get;set;}
    
    public List<Case> Cases{get;set;}
    
    public WorkOrder WorkOrders {get;set;} 

    public WorkOrder wo {get;set;} 

     

    //Constructor 

     public installUpdateAssetWorkOrderClass(ApexPages.StandardController controller) {
        this.controller = controller;
    

        wo = (WorkOrder)controller.getRecord();      
         
        WorkOrders = [SELECT id FROM WorkOrder WHERE id=: wo.id LIMIT 1]; 

         Assets = [SELECT id, New_Equipment_Setup_and_Install_Ticket__r.Install_Date__c, Product2.Serialized__c, New_Equipment_Setup_and_Install_Ticket__c, Show_in_MultiMachine_Delivery_Acceptance__c,SerialNumber,Name,Delivery_Address__c,Product_Code_Display__c,Product_Description_Display__c FROM Asset where Work_Order__c = :WorkOrders.id]; 
     
     	Cases = [SELECT id, Cheater_Left_On_Sight__c FROM Case WHERE Work_Order__c = :WorkOrders.id];
     } 
    
    //save button for serial number
    
    public void saveSerialIdNumber() {
        // This will copy the values from custom field to Serial Number field 
		for(Asset assetObj : (list<Asset>) ((WorkOrder) controller.getRecord()).Assets__r){
			assetObj.SerialNumber = assetObj.New_Asset_Install_LOC_Serial_Number__c;
		}
        
        
        update ((WorkOrder) controller.getRecord()).Assets__r;
        // here we call the standard controller's "update"
        controller.save();
        
    }
    
     
}

I know there is nothing in my class telling the save button to save anything on the Case object. But I have tried numerous different things and I can get the class to save.

Any help would be greatly appreciated.

Thank you.
I have a visualforce page where a user inputs serial numbers for an asset (New_Asset_Install_LOC_Serial_Number__c), I need this serial number input field to update the main serial number field on the asset Object (SerialNumber). Currently the New_Asset_Install_LOC_Serial_Number__c field is being updated on the asset, but I also need this value to populate the SerialNumber field on the asset.

Here is my visualforce code:
<apex:page docType="html-5.0" standardController="Case" extensions="installTicketUpdateAssetClass" id="thePage"> 
   
    
    <style>
    .installSerialNumber{
        }
    .setupSerialNumber {
        }
    .setupModel {
        }
    .setupModelForId {
        }
    .verify{
        }
    .update{
        }
    .autoSerialCheck{
        }
    .idNumber{
        }
    .ipAddress{
        }
    .locationRemarks{
        }
    .installNotes{
        }
    .serialDoesntMatch{
        }
    .serialDoesntMatchCheckBoxOnAsset{
        }
   
    </style>
    <p></p>


    <apex:form id="theForm"> 
        <apex:pageblock id="Assets">

            <apex:pageBlockSection id="pbs" columns="1"> <!-- to allow the apex:input to show the label -->
                
                <apex:pageBlockTable rows="1" id="pbt3" value="{!Case.Assets__r}" var="asset">
                
                    <apex:column style="width:12%;" headerValue="Product Code"><!-- to take the label dynamically -->
                         <apex:inputText style="width:80%;" disabled="true" styleClass="setupModelForId" value="{!asset.Product_Code_for_Paperless_Install_Docs__c}"  />
                    </apex:column>
                    
            		<apex:column style="width:11%;" headerValue="ID Number"><!-- to take the label dynamically -->
                        <apex:inputText required="true" style="width:80%;" styleClass="idNumber" value="{!asset.New_Asset_Install_LOC_ID_Number__c}"  />
                    </apex:column>
                    
                    <apex:column style="width:10%;" headerValue="B/W Starting Meter"><!-- to take the label dynamically -->
                        <apex:inputText required="true" styleClass="bwMeter" style="width:80%;" value="{!asset.New_Asset_Install_B_W_Meter__c}"  />
                    </apex:column>
                
               		<apex:column style="width:10%;" headerValue="Color Starting Meter"><!-- to take the label dynamically -->
                        <apex:inputText styleClass="colorMeter" style="width:80%;" value="{!asset.New_Asset_Install_Color_Meter__c}"  />
                    </apex:column>
                
                <apex:column style="width:10%;" headerValue="I.P. Address"><!-- to take the label dynamically -->
                        <apex:inputText styleClass="ipAddress" style="width:90%;" value="{!asset.New_Asset_Install_Equipment_IP_Address__c}"  />
                    </apex:column>
                    
                    <apex:column style="width:.01%;" headerValue=""><!-- to take the label dynamically -->
                        <apex:inputText disabled="true" style="width:.01%;" styleClass="setupIdNumber" value="{!asset.New_Asset_Setup_LOC_ID__c}"  />
                    </apex:column>
                
            </apex:pageBlockTable>
                
                <apex:pageBlockTable id="pbt" value="{!Case.Assets__r}" var="asset">
                                 
                    <apex:column style="width:12%;" headerValue="Product Code"><!-- to take the label dynamically -->
                         <apex:inputText style="width:80%;" disabled="true" styleClass="setupModel" value="{!asset.Product_Code_for_Paperless_Install_Docs__c}"  />
                    </apex:column>
                    
                    <apex:column style="width:12%;" headerValue="Serial Number Install"><!-- to take the label dynamically -->
                        <apex:inputText style="width:80%;" disabled="" styleClass="installSerialNumber" value="{!asset.New_Asset_Install_LOC_Serial_Number__c}"  />
                    </apex:column>
                    
                    <apex:column style="width:6%; text-align:center;" value="{!asset.Serialized__c}"/>
                    
                    <apex:column style="width:13%;" headerValue="I Verified the Serial Number"><!-- to take the label dynamically -->
                        <apex:inputCheckbox styleClass="serialDoesntMatchCheckBoxOnAsset" value="{!asset.I_Verify_the_Serial_Number_is_Correct__c}"/>
                    </apex:column>
                    
                    <apex:column style="width:.01%;" headerValue=""><!-- to take the label dynamically -->
                        <apex:inputText style="width:.01%;" disabled="true" id="pbi" styleClass="setupSerialNumber" value="{!asset.Serial_Number_Service_Setup__c}"  />
                    </apex:column>
                    
                </apex:pageBlockTable>
                </apex:pageBlockSection>
            
            
            
            <apex:pageBlockTable rows="1" id="pbt2" value="{!Case.Assets__r}" var="asset">
                
            		<apex:column style="" headerValue="Location Remarks"><!-- to take the label dynamically -->
                        <apex:inputTextarea styleClass="locationRemarks" style="width:99.45%;" value="{!asset.New_Asset_Install_Equipment_Location__c}"  />
                    </apex:column>
                    
                    <apex:column style="" headerValue="Install Notes"><!-- to take the label dynamically -->
                        <apex:inputTextarea styleClass="installNotes" style="width:99.45%;" value="{!asset.Install_Notes__c}"  />
                    </apex:column>
                
               		<apex:column headerValue="Customer DocuSign Link" >
                        <apex:outputLink target="_blank" style="width:99.45%;" value="{!case.Customer_DocuSign_Link__c}">
                            Customer DocuSign Link
                        </apex:outputLink>
                	</apex:column>
                
            </apex:pageBlockTable>
            
            <apex:pageBlockSection id="pbs2" columns="2">
                <apex:inputField id="cheaterOnSite" onchange="cheaterLeftOnSite(); return false;" value="{!case.Cheater_Left_On_Sight__c}"/>
                <apex:inputCheckbox styleClass="autoSerialCheck" onchange="" id="serialNumberVerified" disabled="" value="{!Case.Serial_Numbers_Verified__c}"/>
                <apex:inputText id="cheaterId" value="{!case.Cheater_ID__c}"/>
				<apex:inputCheckbox onchange="enableUpdateButton(); return false;" id="manualSerialNumberVerification" disabled="" value="{!Case.Manual_Serial_Number_Verification__c}"/>
                <apex:inputCheckbox id="cheaterCheckBox" value="{!case.Cheater_was_used_at_install__c}"/>
                <apex:inputCheckbox id="install" value="{!Case.Install_Complete__c}"/>
                
              
                
            </apex:pageBlockSection>
            <p class="serialDoesntMatch">
                <apex:inputCheckbox id="serialDoesntMatchCheckBox" value="{!Case.Asset.I_Verify_the_Serial_Number_is_Correct__c}"/> 
                The above serial number(s) have been verified by <strong>{!$User.FirstName} {!$User.LastName}.</strong>
                <br/>
                <strong>{!$User.FirstName} {!$User.LastName}</strong> has uploaded a document that verifies the correct serial number
               
            </p>
            <apex:pageBlockButtons location="bottom">  
                 <apex:commandButton styleClass="verify" id="verify" onclick="verifySerialNumbers(); return false;" value="Verify" />
                <apex:commandButton oncomplete="congrats(); return false;" styleClass="update" id="update" disabled="" value="Update" action="{!saveSerialIdNumber}" />
            </apex:pageBlockButtons>
        </apex:pageblock>
    </apex:form>

</apex:page>

And here is my apex class:
public class installTicketUpdateAssetClass {
    private ApexPages.StandardController controller;

    //Constructor 
    public installTicketUpdateAssetClass(ApexPages.StandardController controller) {
        this.controller = controller;
    }

    public void saveSerialIdNumber() {
        // here we use the standard controller's capability of fetching related records to update them ourselves 
        // (Casting is needed because YourChildRelationshipName__r is specific to your case object)
        update ((Case) controller.getRecord()).Assets__r;
        // here we call the standard controller's "update"
        controller.save();
    }
}

​​​​​​​Any help would be greatly appreciated
Hello,

I have a visualforce page on the Case object that lists out assets with accessories related to the case. I have an input field where a setup technician types in the asset serial number along with the accessory serial numbers. After the serial numbers are entered the technician will check a "setup complete" checkbox and click the "Update" button which updates the serial numbers on the asset and checks the checkbox on the case. The issue I am running into is when the technician clicks the "update" button a verification needs to take place looping through the asset and accessories comparing the serial number that the setup technician entered (Serial_Number_Service_Setup__c) and the serial number that was entered when the equipment was pulled (Serial_Number_Procurement__c). If the serial numbers match then the "Serial_Number_Service_Setup__c" field needs to update on the asset with the serial number. If the serial numbers do not match then a screen alert needs to pop up saying the serial number did not match and to re-enter the serial number. After the serial number is entered again then the "Serial_Number_Service_Setup__c" field on the asset needs to update with the serial number that the technician entered. As of right now the the checkbox is being checked on the case and the serial number is being updated on the asset when the "update" button is clicked, but I can't seem to figure out how to get the serial number verification to work. Unfortionatly I only know a little bit when it comes to apex and javascript.

Here is my visual for page:
<apex:page standardController="Case" extensions="pullEquipmentUpdateAssetClass">     
    <p></p>
    <apex:form > 
        <apex:pageblock id="Assets">

            <apex:pageBlockSection columns="1"> <!-- to allow the apex:input to show the label -->
                <apex:pageBlockTable value="{!Case.Assets__r}" 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 id="procurementSerialNumber" value="{!asset.Serial_Number_Procurement__c}"/>
                    <apex:column headerValue="{!$ObjectType.Asset.fields.Serial_Number_Service_Setup__c.label}"><!-- to take the label dynamically -->
                        <apex:inputText id="setupSerialNumber" value="{!asset.Serial_Number_Service_Setup__c}" />
                    </apex:column>
                    <apex:column value="{!asset.Serialized__c}"/>
                </apex:pageBlockTable>

                <apex:inputCheckbox value="{!Case.Setup_Complete__c}"/>
            </apex:pageBlockSection>
            <apex:pageBlockButtons location="bottom">                
                <apex:commandButton id="checkSerial"  value="Update" action="{!saveSerialIdNumber}"/>
            </apex:pageBlockButtons>
        </apex:pageblock>
    </apex:form>
    
    <script>
    
    document.getElementById("checkSerial").onclick = function()
    {checkSerialNumber()};
     function checkSerialNumber(){
        var serialNumberSetup = document.getElementById(setupSerialNumber).value;
        var serialNumberProcurement = document.getElementById(procurementSerialNumber).value;
         document.getElementById("checkSerial").innerHTML =
             for (var i = 0; i < serialNumberSetup.length; i++){
        	if(serialNumberSetup != serialNumberProcurement){
                	alert('Serial numbers do not match');
                }
    
    </script>
</apex:page>
Apex class:
public class setupEquipmentUpdateAssetClass {

    private ApexPages.StandardController controller;
	
    //Constructor 
    public setupEquipmentUpdateAssetClass(ApexPages.StandardController controller) {
        this.controller = controller;
    }

    public void saveSerialIdNumber() {
        
        update ((Case) controller.getRecord()).Assets__r;
        
      
        controller.save();
    }
}
Any help I could get on this would be greatly appreciated!
 
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>
    
<!--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 
I need help writing a test class for my apex code. I really don't know much about apex. But I was able to create a visualforce page and an apex class that extends the standard controller. Everything works perfectly in my sandbox. But I have no idea how to write the test class so that I can push my code into production.

Here is my code for the visualforce page:

<apex:page standardController="WorkOrder" extensions="WorkOrderLineItemsOnWorkOrderClass">     

    <apex:sectionHeader title="Equipment on quote number {! WorkOrder.Workorder_Name__c } for {! WorkOrder.Account.Name }"/>
  
    <p></p>
    
    <apex:pageblock id="WorkOrderLineItemList"> 

         <br/> 

            <apex:pageBlockTable value="{!WorkOrderLineItems}" var="item">                          

                <apex:column value="{!item.Product_Code_Display__c}"/>
                
                <apex:column value="{!item.Description}"/> 
                
                <apex:column value="{!item.Quote_Line_Quantity_Display__c}"/>
                
                <apex:column value="{!item.Quote_Line_Net_Total_Display__c}"/> 
                
                <apex:column value="{!item.Group_Name__c}"/>
               
            </apex:pageBlockTable>     
            
     </apex:pageblock> 

</apex:page>

And here my code for my apex class that extends the standard controller:

public class WorkOrderLineItemsOnWorkOrderClass {

    public List<WorkOrderLineItem> WorkOrderLineItems{get;set;}

    public WorkOrder WorkOrders {get;set;} 

    public WorkOrder wo {get;set;} 

     //Constructor 

    public WorkOrderLineItemsOnWorkOrderClass(ApexPages.StandardController controller) { 

        wo = (WorkOrder)controller.getRecord();      

        WorkOrders = [SELECT id FROM WorkOrder WHERE id=: wo.id LIMIT 1]; 

        WorkOrderLineItems = [SELECT id,Group_Name__c,Product_Code_Display__c,Quote_Line_Quantity_Display__c, Description, Quote_Line_Net_Total_Display__c FROM WorkOrderLineItem WHERE WorkOrderid = :WorkOrders.id ORDER BY Quote_Line__c];     


   
}
 
I have a visualforce page on the Workorder object that lists out all of the assets on an order. A user will fill out some input fields and click the update button. This saves all of the input fields to the related asset. There are also cases related to the assets that I need to update as well. I am able to show the fields from the related case that is related to the asset on the visualforce page, but I can't figure out how to get my save button to save the info for the related case. So basically the relationship goes WorkOrder > Asset > Case.

Here is my visualforce code:
<apex:form id="theForm"> 
        <apex:pageblock id="Assets">
            
                
                <apex:pageBlockTable rows="" id="pbt0" value="{!WorkOrder.Assets__r}" var="asset">
                
                    <apex:column rendered="{!asset.SBQQ__RequiredByAsset__c == null}" style="width:16.66666666666667%;" headerValue="Product Code"><!-- to take the label dynamically -->
                  		<apex:inputText style="width:94%;" disabled="true" styleClass="setupModelForId" value="{!asset.Product_Code_for_Paperless_Install_Docs__c}"></apex:inputText>
                    </apex:column>
                
                    
                    
                    <apex:column rendered="{!asset.SBQQ__RequiredByAsset__c == null}" style="width:20%;" headerValue="ID Number"><!-- to take the label dynamically -->
                    	<apex:inputText onchange="updateIdNumber(); return false;" style="width:94%;" styleClass="idNumber" value="{!asset.New_Asset_Install_LOC_ID_Number__c}"  />
                    </apex:column>
                    
                    	
                        
                    <apex:column rendered="{!asset.SBQQ__RequiredByAsset__c == null}" style="width:16.66666666666667%;" headerValue="B/W Meter"><!-- to take the label dynamically -->
                    	<apex:inputText required="true" styleClass="bwMeter" style="width:94%;" value="{!asset.New_Asset_Install_B_W_Meter__c}"  />
                    </apex:column>
                    
                    <apex:column rendered="{!asset.SBQQ__RequiredByAsset__c == null}" style="width:16.66666666666667%;" headerValue="Color Meter"><!-- to take the label dynamically -->
                    	<apex:inputText styleClass="colorMeter" style="width:94%;" value="{!asset.New_Asset_Install_Color_Meter__c}"  />
                    </apex:column>
                    
                    <apex:column rendered="{!asset.SBQQ__RequiredByAsset__c == null}" style="width:16.66666666666667%;" headerValue="I.P. Address"><!-- to take the label dynamically -->
                    	<apex:inputText styleClass="ipAddress" style="width:94%;" value="{!asset.New_Asset_Install_Equipment_IP_Address__c}"  />
                    </apex:column>
                    
                    <apex:column style="width:16.66666666666667%;" rendered="{!asset.SBQQ__RequiredByAsset__c == null}" headerValue="Install Date">
                    	<apex:inputField id="installDate" styleClass="installDate" value="{!asset.New_Equipment_Setup_and_Install_Ticket__r.Install_Date__c}"/>
                   	 </apex:column>
                        
                     <apex:column style="width:16.66666666666667%;" rendered="{!asset.SBQQ__RequiredByAsset__c == null}" styleClass="" headerValue=""><!-- to take the label dynamically -->
                            <apex:inputText disabled="true" style="" styleClass="setupIdNumber" value="{!asset.New_Asset_Setup_LOC_ID__c}"  />
                     </apex:column>
                        
                </apex:pageBlockTable>
			
			<apex:pageBlockButtons location="bottom">  
                 
                <apex:commandButton styleClass="verify" id="verify" onclick="verifySerialNumbers(); return false;" value="Verify" />
                
                <apex:commandButton oncomplete="congrats(); return false;" styleClass="update" id="update" disabled="" value="Update" action="{!saveSerialIdNumber}" />
       
            </apex:pageBlockButtons>
			
		</apex:pageBlock>
</apex:form>

And here is my class:
public class installUpdateAssetWorkOrderClass {

    private ApexPages.StandardController controller;
    
    public List<WorkOrderLineItem> WorkOrderLineItems{get;set;}

    public List<WorkOrderLineItem> WorkOrderLineItemsSupplies{get;set;}
    
    public List<Asset> Assets{get;set;}
    
    public List<Case> Cases{get;set;}
    
    public WorkOrder WorkOrders {get;set;} 

    public WorkOrder wo {get;set;} 

     

    //Constructor 

     public installUpdateAssetWorkOrderClass(ApexPages.StandardController controller) {
        this.controller = controller;
    

        wo = (WorkOrder)controller.getRecord();      
         
        WorkOrders = [SELECT id FROM WorkOrder WHERE id=: wo.id LIMIT 1]; 

         Assets = [SELECT id, New_Equipment_Setup_and_Install_Ticket__r.Install_Date__c, Product2.Serialized__c, New_Equipment_Setup_and_Install_Ticket__c, Show_in_MultiMachine_Delivery_Acceptance__c,SerialNumber,Name,Delivery_Address__c,Product_Code_Display__c,Product_Description_Display__c FROM Asset where Work_Order__c = :WorkOrders.id]; 
     
     	Cases = [SELECT id, Cheater_Left_On_Sight__c FROM Case WHERE Work_Order__c = :WorkOrders.id];
     } 
    
    //save button for serial number
    
    public void saveSerialIdNumber() {
        // This will copy the values from custom field to Serial Number field 
		for(Asset assetObj : (list<Asset>) ((WorkOrder) controller.getRecord()).Assets__r){
			assetObj.SerialNumber = assetObj.New_Asset_Install_LOC_Serial_Number__c;
		}
        
        
        update ((WorkOrder) controller.getRecord()).Assets__r;
        // here we call the standard controller's "update"
        controller.save();
        
    }
    
     
}

I know there is nothing in my class telling the save button to save anything on the Case object. But I have tried numerous different things and I can get the class to save.

Any help would be greatly appreciated.

Thank you.
I have a visualforce page where a user inputs serial numbers for an asset (New_Asset_Install_LOC_Serial_Number__c), I need this serial number input field to update the main serial number field on the asset Object (SerialNumber). Currently the New_Asset_Install_LOC_Serial_Number__c field is being updated on the asset, but I also need this value to populate the SerialNumber field on the asset.

Here is my visualforce code:
<apex:page docType="html-5.0" standardController="Case" extensions="installTicketUpdateAssetClass" id="thePage"> 
   
    
    <style>
    .installSerialNumber{
        }
    .setupSerialNumber {
        }
    .setupModel {
        }
    .setupModelForId {
        }
    .verify{
        }
    .update{
        }
    .autoSerialCheck{
        }
    .idNumber{
        }
    .ipAddress{
        }
    .locationRemarks{
        }
    .installNotes{
        }
    .serialDoesntMatch{
        }
    .serialDoesntMatchCheckBoxOnAsset{
        }
   
    </style>
    <p></p>


    <apex:form id="theForm"> 
        <apex:pageblock id="Assets">

            <apex:pageBlockSection id="pbs" columns="1"> <!-- to allow the apex:input to show the label -->
                
                <apex:pageBlockTable rows="1" id="pbt3" value="{!Case.Assets__r}" var="asset">
                
                    <apex:column style="width:12%;" headerValue="Product Code"><!-- to take the label dynamically -->
                         <apex:inputText style="width:80%;" disabled="true" styleClass="setupModelForId" value="{!asset.Product_Code_for_Paperless_Install_Docs__c}"  />
                    </apex:column>
                    
            		<apex:column style="width:11%;" headerValue="ID Number"><!-- to take the label dynamically -->
                        <apex:inputText required="true" style="width:80%;" styleClass="idNumber" value="{!asset.New_Asset_Install_LOC_ID_Number__c}"  />
                    </apex:column>
                    
                    <apex:column style="width:10%;" headerValue="B/W Starting Meter"><!-- to take the label dynamically -->
                        <apex:inputText required="true" styleClass="bwMeter" style="width:80%;" value="{!asset.New_Asset_Install_B_W_Meter__c}"  />
                    </apex:column>
                
               		<apex:column style="width:10%;" headerValue="Color Starting Meter"><!-- to take the label dynamically -->
                        <apex:inputText styleClass="colorMeter" style="width:80%;" value="{!asset.New_Asset_Install_Color_Meter__c}"  />
                    </apex:column>
                
                <apex:column style="width:10%;" headerValue="I.P. Address"><!-- to take the label dynamically -->
                        <apex:inputText styleClass="ipAddress" style="width:90%;" value="{!asset.New_Asset_Install_Equipment_IP_Address__c}"  />
                    </apex:column>
                    
                    <apex:column style="width:.01%;" headerValue=""><!-- to take the label dynamically -->
                        <apex:inputText disabled="true" style="width:.01%;" styleClass="setupIdNumber" value="{!asset.New_Asset_Setup_LOC_ID__c}"  />
                    </apex:column>
                
            </apex:pageBlockTable>
                
                <apex:pageBlockTable id="pbt" value="{!Case.Assets__r}" var="asset">
                                 
                    <apex:column style="width:12%;" headerValue="Product Code"><!-- to take the label dynamically -->
                         <apex:inputText style="width:80%;" disabled="true" styleClass="setupModel" value="{!asset.Product_Code_for_Paperless_Install_Docs__c}"  />
                    </apex:column>
                    
                    <apex:column style="width:12%;" headerValue="Serial Number Install"><!-- to take the label dynamically -->
                        <apex:inputText style="width:80%;" disabled="" styleClass="installSerialNumber" value="{!asset.New_Asset_Install_LOC_Serial_Number__c}"  />
                    </apex:column>
                    
                    <apex:column style="width:6%; text-align:center;" value="{!asset.Serialized__c}"/>
                    
                    <apex:column style="width:13%;" headerValue="I Verified the Serial Number"><!-- to take the label dynamically -->
                        <apex:inputCheckbox styleClass="serialDoesntMatchCheckBoxOnAsset" value="{!asset.I_Verify_the_Serial_Number_is_Correct__c}"/>
                    </apex:column>
                    
                    <apex:column style="width:.01%;" headerValue=""><!-- to take the label dynamically -->
                        <apex:inputText style="width:.01%;" disabled="true" id="pbi" styleClass="setupSerialNumber" value="{!asset.Serial_Number_Service_Setup__c}"  />
                    </apex:column>
                    
                </apex:pageBlockTable>
                </apex:pageBlockSection>
            
            
            
            <apex:pageBlockTable rows="1" id="pbt2" value="{!Case.Assets__r}" var="asset">
                
            		<apex:column style="" headerValue="Location Remarks"><!-- to take the label dynamically -->
                        <apex:inputTextarea styleClass="locationRemarks" style="width:99.45%;" value="{!asset.New_Asset_Install_Equipment_Location__c}"  />
                    </apex:column>
                    
                    <apex:column style="" headerValue="Install Notes"><!-- to take the label dynamically -->
                        <apex:inputTextarea styleClass="installNotes" style="width:99.45%;" value="{!asset.Install_Notes__c}"  />
                    </apex:column>
                
               		<apex:column headerValue="Customer DocuSign Link" >
                        <apex:outputLink target="_blank" style="width:99.45%;" value="{!case.Customer_DocuSign_Link__c}">
                            Customer DocuSign Link
                        </apex:outputLink>
                	</apex:column>
                
            </apex:pageBlockTable>
            
            <apex:pageBlockSection id="pbs2" columns="2">
                <apex:inputField id="cheaterOnSite" onchange="cheaterLeftOnSite(); return false;" value="{!case.Cheater_Left_On_Sight__c}"/>
                <apex:inputCheckbox styleClass="autoSerialCheck" onchange="" id="serialNumberVerified" disabled="" value="{!Case.Serial_Numbers_Verified__c}"/>
                <apex:inputText id="cheaterId" value="{!case.Cheater_ID__c}"/>
				<apex:inputCheckbox onchange="enableUpdateButton(); return false;" id="manualSerialNumberVerification" disabled="" value="{!Case.Manual_Serial_Number_Verification__c}"/>
                <apex:inputCheckbox id="cheaterCheckBox" value="{!case.Cheater_was_used_at_install__c}"/>
                <apex:inputCheckbox id="install" value="{!Case.Install_Complete__c}"/>
                
              
                
            </apex:pageBlockSection>
            <p class="serialDoesntMatch">
                <apex:inputCheckbox id="serialDoesntMatchCheckBox" value="{!Case.Asset.I_Verify_the_Serial_Number_is_Correct__c}"/> 
                The above serial number(s) have been verified by <strong>{!$User.FirstName} {!$User.LastName}.</strong>
                <br/>
                <strong>{!$User.FirstName} {!$User.LastName}</strong> has uploaded a document that verifies the correct serial number
               
            </p>
            <apex:pageBlockButtons location="bottom">  
                 <apex:commandButton styleClass="verify" id="verify" onclick="verifySerialNumbers(); return false;" value="Verify" />
                <apex:commandButton oncomplete="congrats(); return false;" styleClass="update" id="update" disabled="" value="Update" action="{!saveSerialIdNumber}" />
            </apex:pageBlockButtons>
        </apex:pageblock>
    </apex:form>

</apex:page>

And here is my apex class:
public class installTicketUpdateAssetClass {
    private ApexPages.StandardController controller;

    //Constructor 
    public installTicketUpdateAssetClass(ApexPages.StandardController controller) {
        this.controller = controller;
    }

    public void saveSerialIdNumber() {
        // here we use the standard controller's capability of fetching related records to update them ourselves 
        // (Casting is needed because YourChildRelationshipName__r is specific to your case object)
        update ((Case) controller.getRecord()).Assets__r;
        // here we call the standard controller's "update"
        controller.save();
    }
}

​​​​​​​Any help would be greatly appreciated
Hello,

I have a visualforce page on the Case object that lists out assets with accessories related to the case. I have an input field where a setup technician types in the asset serial number along with the accessory serial numbers. After the serial numbers are entered the technician will check a "setup complete" checkbox and click the "Update" button which updates the serial numbers on the asset and checks the checkbox on the case. The issue I am running into is when the technician clicks the "update" button a verification needs to take place looping through the asset and accessories comparing the serial number that the setup technician entered (Serial_Number_Service_Setup__c) and the serial number that was entered when the equipment was pulled (Serial_Number_Procurement__c). If the serial numbers match then the "Serial_Number_Service_Setup__c" field needs to update on the asset with the serial number. If the serial numbers do not match then a screen alert needs to pop up saying the serial number did not match and to re-enter the serial number. After the serial number is entered again then the "Serial_Number_Service_Setup__c" field on the asset needs to update with the serial number that the technician entered. As of right now the the checkbox is being checked on the case and the serial number is being updated on the asset when the "update" button is clicked, but I can't seem to figure out how to get the serial number verification to work. Unfortionatly I only know a little bit when it comes to apex and javascript.

Here is my visual for page:
<apex:page standardController="Case" extensions="pullEquipmentUpdateAssetClass">     
    <p></p>
    <apex:form > 
        <apex:pageblock id="Assets">

            <apex:pageBlockSection columns="1"> <!-- to allow the apex:input to show the label -->
                <apex:pageBlockTable value="{!Case.Assets__r}" 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 id="procurementSerialNumber" value="{!asset.Serial_Number_Procurement__c}"/>
                    <apex:column headerValue="{!$ObjectType.Asset.fields.Serial_Number_Service_Setup__c.label}"><!-- to take the label dynamically -->
                        <apex:inputText id="setupSerialNumber" value="{!asset.Serial_Number_Service_Setup__c}" />
                    </apex:column>
                    <apex:column value="{!asset.Serialized__c}"/>
                </apex:pageBlockTable>

                <apex:inputCheckbox value="{!Case.Setup_Complete__c}"/>
            </apex:pageBlockSection>
            <apex:pageBlockButtons location="bottom">                
                <apex:commandButton id="checkSerial"  value="Update" action="{!saveSerialIdNumber}"/>
            </apex:pageBlockButtons>
        </apex:pageblock>
    </apex:form>
    
    <script>
    
    document.getElementById("checkSerial").onclick = function()
    {checkSerialNumber()};
     function checkSerialNumber(){
        var serialNumberSetup = document.getElementById(setupSerialNumber).value;
        var serialNumberProcurement = document.getElementById(procurementSerialNumber).value;
         document.getElementById("checkSerial").innerHTML =
             for (var i = 0; i < serialNumberSetup.length; i++){
        	if(serialNumberSetup != serialNumberProcurement){
                	alert('Serial numbers do not match');
                }
    
    </script>
</apex:page>
Apex class:
public class setupEquipmentUpdateAssetClass {

    private ApexPages.StandardController controller;
	
    //Constructor 
    public setupEquipmentUpdateAssetClass(ApexPages.StandardController controller) {
        this.controller = controller;
    }

    public void saveSerialIdNumber() {
        
        update ((Case) controller.getRecord()).Assets__r;
        
      
        controller.save();
    }
}
Any help I could get on this would be greatly appreciated!
 
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>
    
<!--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 
I need help writing a test class for my apex code. I really don't know much about apex. But I was able to create a visualforce page and an apex class that extends the standard controller. Everything works perfectly in my sandbox. But I have no idea how to write the test class so that I can push my code into production.

Here is my code for the visualforce page:

<apex:page standardController="WorkOrder" extensions="WorkOrderLineItemsOnWorkOrderClass">     

    <apex:sectionHeader title="Equipment on quote number {! WorkOrder.Workorder_Name__c } for {! WorkOrder.Account.Name }"/>
  
    <p></p>
    
    <apex:pageblock id="WorkOrderLineItemList"> 

         <br/> 

            <apex:pageBlockTable value="{!WorkOrderLineItems}" var="item">                          

                <apex:column value="{!item.Product_Code_Display__c}"/>
                
                <apex:column value="{!item.Description}"/> 
                
                <apex:column value="{!item.Quote_Line_Quantity_Display__c}"/>
                
                <apex:column value="{!item.Quote_Line_Net_Total_Display__c}"/> 
                
                <apex:column value="{!item.Group_Name__c}"/>
               
            </apex:pageBlockTable>     
            
     </apex:pageblock> 

</apex:page>

And here my code for my apex class that extends the standard controller:

public class WorkOrderLineItemsOnWorkOrderClass {

    public List<WorkOrderLineItem> WorkOrderLineItems{get;set;}

    public WorkOrder WorkOrders {get;set;} 

    public WorkOrder wo {get;set;} 

     //Constructor 

    public WorkOrderLineItemsOnWorkOrderClass(ApexPages.StandardController controller) { 

        wo = (WorkOrder)controller.getRecord();      

        WorkOrders = [SELECT id FROM WorkOrder WHERE id=: wo.id LIMIT 1]; 

        WorkOrderLineItems = [SELECT id,Group_Name__c,Product_Code_Display__c,Quote_Line_Quantity_Display__c, Description, Quote_Line_Net_Total_Display__c FROM WorkOrderLineItem WHERE WorkOrderid = :WorkOrders.id ORDER BY Quote_Line__c];     


   
}