--- title: "Line Change Subline Updater" slug: "line-change-subline-updater" updated: 2023-06-28T16:28:34Z published: 2023-06-28T16:28:34Z canonical: "docs.zilliant.com/line-change-subline-updater" --- > ## Documentation Index > Fetch the complete documentation index at: https://docs.zilliant.com/llms.txt > Use this file to discover all available pages before exploring further. # Line Change Subline Updater Class When a user updates a field on a parent line, this Apex hook can update additional parent line fields and one or more fields on one or more sublines of that parent line. The hook occurs within the following workflow: 1. In the **Edit Lines** modal, the user selects a parent line and updates the editable field. 2. Before the user selects **Save**, the parent line, all sublines created for that parent line, and the field that was changed are sent to the Apex hook. 1. Some custom logic or calculations, an IQA call, or both are made (IQA called by hook). 2. The parent line value and subline values returned by the hook service are displayed in the **Edit Lines** modal. 3. If the user selects **Save**, the fields changed by the user and the hook are saved. 4. If the user selects **Cancel**, the changes are not saved. 5. The user can continue changing editable fields on a line or subline. ## Apex hook class - It must implement the **LineChangeSublineUpdater** interface. - It must have a global access modifier. - You must specify the Apex hook class name in the **Line Change Subline Updater Class Name** field of the **Product Selector Configuration** that is mapped to the **Line Items** component to be affected by the hook. ## Interface definition ``` global interface LineChangeSublineUpdater { LinesAndSublinesResponse updateSublinesOnLineItemChange(LinesAndSublinesInputData data); } ``` As an input parameter, this method has **LinesAndSublinesInputData** which contains **changedSObject** (the object that is updated by the user), line, **changedFieldName** (the field that was changed by user on **changedSObject**), **parameterSublines** and **tieredSublines**. ``` global class LinesAndSublinesInputData { @AuraEnabled global SObject changedSObject { get; private set; } @AuraEnabled global SObject line { get; private set; } @AuraEnabled global String changedFieldName { get; private set; } @AuraEnabled global List parameterSublines { get; private set; } @AuraEnabled global List tieredSublines { get; private set; } global LinesAndSublinesInputData(SObject changedSObject, String changedFieldName, SObject line, List parameterSublines, List tieredSublines) { this.changedSObject = changedSObject; this.line = line; this.changedFieldName = changedFieldName; this.parameterSublines = parameterSublines; this.tieredSublines = tieredSublines; } } ``` As a return value, the method has **LinesAndSublinesResponse** which contains an updated line, **parameterSublines** and **tieredSublines**. ``` global class LinesAndSublinesResponse { @AuraEnabled global SObject line; @AuraEnabled global List parameterSublines; @AuraEnabled global List tieredSublines; global LinesAndSublinesResponse(SObject line, List parameterSublines, List tieredSublines) { this.line = line; this.parameterSublines = parameterSublines; this.tieredSublines = tieredSublines; } ``` ## Example of the class implementation ``` global class TestSublineFieldUpdater implements LineChangeSublineUpdater { public LinesAndSublinesResponse updateSublinesOnLineItemChange(LinesAndSublinesInputData data) { if (data.line.get('zpl__ContractPrice__c') == 1 && data.changedFieldName == 'zpl__ContractPrice__c') { data.line.put('zpl__ContractPrice__c', 10); for (SObject parameterSubline : data.parameterSublines) { parameterSubline.put('zpl__ups_Guidance__c', 3); parameterSubline.put('zpl__ups_Offer__c', 2); parameterSubline.put('zpl__ups_UOM__c', 'updated'); } for (SObject tierdSubline : data.tieredSublines) { tierdSubline.put('zpl__Value__c', 10); tierdSubline.put('zpl__ups_Guidance__c', 3); tierdSubline.put('zpl__ups_UOM__c', 'updated'); tierdSubline.put('zpl__ups_Offer__c', 100); } } return new LinesAndSublinesResponse(data.line, data.parameterSublines, data.tieredSublines); } } ```