title: How can I set a default value on a projection field?
body: <p>I have a projection DAC defined as below. I am using this DAC in a view on <code>InventoryItemMaint</code>. I need the <code>InventoryID</code> field of my projection DAC to default to the current item's ID, but nothing I try works.</p>
  <p>Is there a special way to do this?</p>
  <p>I've tried:</p>
  <ul>
  <li><code>PXDBDefault</code> with <code>PXParent</code></li>
  <li><code>PXDefault(typeof(InventoryItem.inventoryID))]</code></li>
  <li><code>PXFormula</code> (like below)</li>
  </ul>
  <h1></h1>
  <pre><code>[PXProjection(typeof(SelectFrom&lt;MXFormulaClass&gt;.InnerJoin&lt;MXFormulaClassNutrients&gt;.
      On&lt;MXFormulaClassNutrients.classID.IsEqual&lt;MXFormulaClass.classID&gt;&gt;.
      LeftJoin&lt;MXNutrientValue&gt;.
      On&lt;MXNutrientValue.nutrientID.IsEqual&lt;MXFormulaClassNutrients.nutrientID&gt;&gt;), Persistent = true)]
  [PXCacheName(&quot;MXItemNutrientValues&quot;)]
  public class MXItemNutrientValues : IBqlTable
  {      
      #region ClassID
      [PXDBInt(IsKey = true, BqlField = typeof(MXFormulaClassNutrients.classID))]
      [PXUIField(DisplayName = &quot;Class ID&quot;)]
      public virtual int? ClassID { get; set; }
      public abstract class classID : PX.Data.BQL.BqlInt.Field&lt;classID&gt; { }
      #endregion
  
      #region NutrientID
      [PXDBInt(IsKey = true, BqlField = typeof(MXFormulaClassNutrients.nutrientID))]
      [PXExtraKey]
      [PXDBDefault(typeof(MXFormulaClassNutrients.nutrientID))]
      [PXSelector(typeof(MXNutrient.nutrientID),
          typeof(MXNutrient.nutrientCD),
          typeof(MXNutrient.description),
          SubstituteKey = typeof(MXNutrient.nutrientCD),
          DescriptionField = typeof(MXNutrient.description))]
      [PXUIField(DisplayName = &quot;Nutrient&quot;)]
      public virtual int? NutrientID { get; set; }
      public abstract class nutrientID : PX.Data.BQL.BqlInt.Field&lt;nutrientID&gt; { }
      #endregion
  
      #region MinMax
      [PXDBInt(IsKey = true, BqlField = typeof(MXFormulaClassNutrients.minMax))]
      [PXIntList(new int[] { 1, 2 }, new string[] { &quot;Min&quot;, &quot;Max&quot; })]
      [PXUIField(DisplayName = &quot;Min/Max&quot;)]
      public virtual int? MinMax { get; set; }
      public abstract class minMax : PX.Data.BQL.BqlInt.Field&lt;minMax&gt; { }
      #endregion
  
      #region SortOrder
      [PXDBInt(BqlField = typeof(MXFormulaClassNutrients.sortOrder))]
      [PXUIField(DisplayName = &quot;Sort Order&quot;)]
      public virtual int? SortOrder { get; set; }
      public abstract class sortOrder : PX.Data.BQL.BqlInt.Field&lt;sortOrder&gt; { }
      #endregion
  
      #region InventoryID
      [PXDBInt(IsKey = true, BqlField = typeof(MXNutrientValue.inventoryID))]
      [PXFormula(typeof(Where&lt;InventoryItem.inventoryID, Equal&lt;Current&lt;InventoryItem.inventoryID&gt;&gt;&gt;))]
      [PXUIField(DisplayName = &quot;Inventory ID&quot;)]
      public virtual int? InventoryID { get; set; }
      public abstract class inventoryID : PX.Data.BQL.BqlInt.Field&lt;inventoryID&gt; { }
      #endregion
  
      #region Value
      [PXDBDecimal(BqlField = typeof(MXNutrientValue.value))]
      [PXUIField(DisplayName = &quot;Value&quot;)]
      public virtual Decimal? Value { get; set; }
      public abstract class value : PX.Data.BQL.BqlDecimal.Field&lt;value&gt; { }
      #endregion
  
      #region CreatedByID
      [PXDBCreatedByID(BqlField = typeof(MXNutrientValue.createdByID))]
      public virtual Guid? CreatedByID { get; set; }
      public abstract class createdByID : PX.Data.BQL.BqlGuid.Field&lt;createdByID&gt; { }
      #endregion
  
      #region CreatedByScreenID
      [PXDBCreatedByScreenID(BqlField = typeof(MXNutrientValue.createdByScreenID))]
      public virtual string CreatedByScreenID { get; set; }
      public abstract class createdByScreenID : PX.Data.BQL.BqlString.Field&lt;createdByScreenID&gt; { }
      #endregion
  
      #region CreatedDateTime
      [PXDBCreatedDateTime(BqlField = typeof(MXNutrientValue.createdDateTime))]
      public virtual DateTime? CreatedDateTime { get; set; }
      public abstract class createdDateTime : PX.Data.BQL.BqlDateTime.Field&lt;createdDateTime&gt; { }
      #endregion
  
      #region LastModifiedByID
      [PXDBLastModifiedByID(BqlField = typeof(MXNutrientValue.lastModifiedByID))]
      public virtual Guid? LastModifiedByID { get; set; }
      public abstract class lastModifiedByID : PX.Data.BQL.BqlGuid.Field&lt;lastModifiedByID&gt; { }
      #endregion
  
      #region LastModifiedByScreenID
      [PXDBLastModifiedByScreenID(BqlField = typeof(MXNutrientValue.lastModifiedByScreenID))]
      public virtual string LastModifiedByScreenID { get; set; }
      public abstract class lastModifiedByScreenID : PX.Data.BQL.BqlString.Field&lt;lastModifiedByScreenID&gt; { }
      #endregion
  
      #region LastModifiedDateTime
      [PXDBLastModifiedDateTime(BqlField = typeof(MXNutrientValue.lastModifiedDateTime))]
      public virtual DateTime? LastModifiedDateTime { get; set; }
      public abstract class lastModifiedDateTime : PX.Data.BQL.BqlDateTime.Field&lt;lastModifiedDateTime&gt; { }
      #endregion
  
      #region Tstamp
      [PXDBTimestamp(BqlField = typeof(MXNutrientValue.tstamp))]
      public virtual byte[] Tstamp { get; set; }
      public abstract class tstamp : PX.Data.BQL.BqlByteArray.Field&lt;tstamp&gt; { }
      #endregion
  
      #region Noteid
      [PXNote(BqlField = typeof(MXNutrientValue.noteid))]
      public virtual Guid? Noteid { get; set; }
      public abstract class noteid : PX.Data.BQL.BqlGuid.Field&lt;noteid&gt; { }
      #endregion
  }
  </code></pre>