Quintiq file version 2.0 
 | 
#parent: #root 
 | 
Method New ( 
 | 
  structured[SalesSegment_MP] salesSegmentsSelected, 
 | 
  structured[Product_MP] products 
 | 
) id:Method_DialogCreateEditFulfillmentRestriction_New 
 | 
{ 
 | 
  #keys: '[135040.0.183105624]' 
 | 
  Body: 
 | 
  [* 
 | 
    // Create a new fulfillment restriction 
 | 
    // Select an owner 
 | 
    // Get a default sales segment so we can relshadow fulfillment restriction and bind to dialog 
 | 
    product   := null( Product_MP ); 
 | 
    owner     := null( SalesSegment_MP ); 
 | 
     
 | 
    if ( products.Size() >0 ) 
 | 
    { 
 | 
      product := minselect( products, Elements, p, p.Child( relsize ) =0, p.DisplayIndex() );   
 | 
    } 
 | 
     
 | 
    //get default SS 
 | 
    if( salesSegmentsSelected.Size() > 0 ) 
 | 
    { 
 | 
       
 | 
      //get a default leaf sales segment from the selected sales segment 
 | 
      owner   := select(  salesSegmentsSelected, Elements.AllChildren.AsChildren, ss, ss.Child( relsize ) =0 ); 
 | 
    } 
 | 
    else 
 | 
    { 
 | 
       
 | 
      owner   := FulfillmentRestriction::GetDefaultOwner( MacroPlan, product ); 
 | 
    } 
 | 
     
 | 
     
 | 
    obj       := owner.FulfillmentRestriction( relshadow, 
 | 
                                               ProductID := guard( product.ID(), "" ), 
 | 
                                               SalesSegmentName := "", 
 | 
                                               StartDate := Date::MinDate(), 
 | 
                                               EndDate := Date::MaxDate(), 
 | 
                                               Product_MP := product 
 | 
                                              ); 
 | 
     
 | 
    DataHolderDialogData.Data( &obj ); 
 | 
     
 | 
    Form.SetDefaultValue( salesSegmentsSelected ); 
 | 
     
 | 
    ApplicationMacroPlanner.ShowFormModal( this ); 
 | 
  *] 
 | 
} 
 |