Quintiq file version 2.0
#parent: #root
Method New (
  internal[GUIComponent] parent
) as FulfillmentRestriction id:Method_DialogCreateEditFulfillmentRestriction_New
{
  #keys: '[123718.0.364071453]'
  Body:
  [*
    // New fulfillment restriction
    
    // Get a default sales segment so we can relshadow fulfillment restriction and bind to dialog
    // Follow the expression filter defined in data extractor for dropdown
    product := null( Product_MP );
    salessegment := FulfillmentRestriction::GetDefaultOwner( MacroPlan, product );
    // Set default start date
    startDate := Date::MinDate();
    
    data := salessegment.FulfillmentRestriction( relshadow, SalesSegmentName := "", ProductID := guard( product.ID(), "" ), StartDate := startDate  );
    data.Product_MP( relset, product );
    
    // Set default end date
    enddate := Date::MaxDate();
    data.EndDate( enddate );
    
    Dialog.Data( data );
    
    if ( Dialog.DoModal( parent ) > 0 )
    {
      data.Commit();
    }
    
    return data.WrappedInstance();
  *]
}
