Quintiq file version 2.0
#parent: #root
Method SetAttributesBeforeOnApplyData () id:Method_DialogCreateEditProduct_SetAttributesBeforeOnApplyData
{
  #keys: '[124808.1.1739232597]'
  Body:
  [*
    // Set attributes on apply data
    data := Dialog.Data();
    
    // Since we use commit, we need to identiy whether the parent of this product has changed
    // This cannot be done if we commit data.Parent() from SelectionParentProduct(), so we need to disable it
    // and set the attribute ParentID. Propagation will relate this child-parent relation.
    SelectionParentProduct.Enabled( false );
    
    // Parent ID should be empty when the checkbox is not checked / checked but selection is empty
    parentproductid := ifexpr( CheckBoxHasParentProduct.Checked(),
                               guard( SelectionParentProduct.Data().ID(), '' ),
                               '' );
    
    data.ParentID( parentproductid );
    
    // Set the icon name
    data.IconName( LabelImageString.Text() );
    
    // Set IsExcludedFromFulfillmentKPI
    isexcludedfromfulfillmentkpi := ifexpr( CheckBoxIsExcludedFromFulfillmentKPI.Enabled(), 
                                            CheckBoxIsExcludedFromFulfillmentKPI.Checked(), 
                                            data.IsExcludedFromFulfillmentKPI() )
    
    data.IsExcludedFromFulfillmentKPI( isexcludedfromfulfillmentkpi );
    
    // ADSO-47827 Set IsExcludedFromOptimization because 
    // When the checkbox is disabled (with check) it wont register in ApplyChanges.
    // Manually set the boolean value here
    data.IsExcludedFromOptimization( CheckBoxIsExcludedFromOptimization.Checked() );
  *]
}
