Quintiq file version 2.0 #parent: #root Method SetShadowUnitCostRetainUserValues ( Unit unit ) id:Method_DialogCreateEditUnitCost_SetShadowUnitCostRetainUserValues { #keys: '[144528.2.91510074]' Body: [* // Create shadow unit cost and retrieve values from UI elements // e.g when changing unit from dropdown, we do not want overwrite the previous values) // NOTE: This cannot be call before Show modal as it slows down dialog display (as the shadow creation below refers to UI elements) createCostForSingleUnit := DataHolderUnits.Data().Size() = 1; if( createCostForSingleUnit ) { // As we using DataHolderSelectedUnit.OnDataChanged to workaround DropDownListUnit.OnUserSelectionChanged & enabled/disabled software bug // Check if user switched unit before re-creating shadow unit cost hasUnitChanged := not DataHolderUnits.Data().Find( unit ) >= 0; if( hasUnitChanged ) { // All values except ID and Unit, we want to preserve user values after user switch unit from dropdown obj := unit.UnitCost( relshadow, ID := MacroPlan.IDHolder().GetUnitCostID(), AccountName := DropDownListAccount.Data().Name(), Account_MP := DropDownListAccount.Data(), CostDriver := DropDownStringListCostDriver.Text(), Cost := ApplicationMacroPlanner.FormatStringToReal( EditFieldCost.Text() ), LengthOfTime := ApplicationMacroPlanner.FormatStringToNumber( EditFieldLengthOfTime.Text() ), TimeUnit := DropDownStringListTimeUnit.Text(), Start := DateSelectorCostStart.Date() ); DataHolderDialogData.Data( & obj ); } // Only if single unit cost creation, we want to replace the unit in dataholder (e.g on change unit in dropdown) DataHolderUnits.Data().Flush(); DataHolderUnits.Data().Add( unit ); } *] }