I’m trying to add a tab to Cost Projection (PM.30.50.00) that will keep the details of changes for each Projection Line in the Details Tab. The Details DAC is “PMCostProjectionLine”. I have two problems:
1) The Revision Log grid is read only even though the Add/delete buttons are enabled, when I click on Add for example, it inserts a record to the grid, but it is read only, and I can not modify the record. I tried to override the system behaviour in all of row Inserting/Inserted/Selected events as follows but didn’t work.
cache.AllowSelect = true;
cache.AllowInsert = true;
cache.AllowUpdate = true;
cache.AllowDelete = true;
When I click on the primary form save, also the inserted record wont be saved.
2) I would like to push Task and Cost Code from the Details (PMCostProjectionLine) grid to Revision Log grid (PMCostProjectionRevisionLog) as default by using the “Current” but it doesn’t work. I do the same for document header (PMCostProjection) for Date and Description fields and it works. It seems the Revision Log grid doesn’t read the cache. Both of these tabs grids CommitChanges=true and Syncposition=true.
The funny part is if in the Details tab I click on a row and try to add a note for example, then hit the escape and go to Revision Log tab and add new record, it reads the correct defaults. Here is my GraphExt, DAC and Screen Shot from Cost Projection Screen.
using PX.Data;
using PX.Data.ReferentialIntegrity.Attributes;
using PX.Objects.PM;
using System;
using System.Windows.Forms;
namespace PX.Objects.CN.ProjectAccounting
{
public class CostProjectionEntry_Extension : PXGraphExtension
{
#region Event Handlers
protected void PMCostProjectionRevisionLog_RowInserting(PXCache cache, PXRowInsertingEventArgs e)
{
var logRow = e.Row as PMCostProjectionRevisionLog;
var lineRow = Base.Details.Current;
var docRow = Base.Document.Current;
if (logRow == null) return;
if (lineRow == null) return;
if (docRow == null) return;
logRow.LineNbr = lineRow.LineNbr;
logRow.ProjectID = lineRow.ProjectID;
logRow.RevisionID = docRow.RevisionID;
logRow.TaskID = lineRow.TaskID;
logRow.CostCodeID = lineRow.CostCodeID;
logRow.Date = docRow.Date;
logRow.Description = docRow.Description;
logRow.UnitCost = lineRow.Amount;
}
protected void PMCostProjectionRevisionLog_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
{
cache.AllowSelect = true;
cache.AllowInsert = true;
cache.AllowUpdate = true;
cache.AllowDelete = true;
}
public PXSelect RevisionLog;
public class PMCostProjectionRevisionLog : IBqlTable
{
#region LogNbr
gPXDBIdentity(IsKey = true)]
public virtual int? LogNbr { get; set; }
public abstract class logNbr : PX.Data.BQL.BqlInt.Field { }
#endregion
#region LineNbr
iPXDBInt]
/PXForeignReference(typeof(Field.IsRelatedTo))]
ePXParent(typeof(Select))]
public virtual int? LineNbr { get; set; }
public abstract class lineNbr : PX.Data.BQL.BqlInt.Field { }
#endregion
#region ProjectID
nActiveProjectOrContractBase(Required = true)]
ePXForeignReference(typeof(Field.IsRelatedTo))]
ePXDefault(typeof(Current), PersistingCheck = PXPersistingCheck.Nothing)]
kPXUIField(DisplayName = "Project")]
public virtual int? ProjectID { get; set; }
public abstract class projectID : PX.Data.BQL.BqlInt.Field { }
#endregion
#region RevisionID
PXDBString(30, IsUnicode = true, InputMask = ">aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")]
aPXUIField(DisplayName = "Revision", Required = true, Enabled = true, Visibility = PXUIVisibility.SelectorVisible)]
oPXDefault(typeof(Current), PersistingCheck = PXPersistingCheck.Nothing)]
kPXForeignReference(typeof(Field.IsRelatedTo))]
ePXSelector(typeof(Search), DescriptionField = typeof(PMCostProjection.description))]
cPXRestrictor(typeof(Where), "Revision does not exist for the selected project.")]
public virtual string RevisionID { get; set; }
public abstract class revisionID : PX.Data.BQL.BqlString.Field { }
#endregion
#region TaskID
gBaseProjectTaskAttribute(typeof(projectID), AllowInactive = false, AllowCanceled = false, AllowCompleted = false, Required = true)]
ePXForeignReference(typeof(Field.IsRelatedTo))]
ePXDefault(typeof(Current), PersistingCheck = PXPersistingCheck.Nothing)]
kPXUIField(DisplayName = "Task")]
public virtual int? TaskID { get; set; }
public abstract class taskID : PX.Data.BQL.BqlInt.Field { }
#endregion
#region CostCodeID
CostCode(null, typeof(taskID), AllowNullValue = false, Required = true)]
ePXForeignReference(typeof(Field.IsRelatedTo))]
ePXDefault(typeof(Current), PersistingCheck = PXPersistingCheck.Nothing)]
kPXUIField(DisplayName = "Cost Code")]
public virtual int? CostCodeID { get; set; }
public abstract class costCodeID : PX.Data.BQL.BqlInt.Field { }
#endregion
#region Date
rPXDBDate]
>PXUIField(DisplayName = "Date", Required = true, Enabled = true)]
ePXDefault(typeof(Current), PersistingCheck = PXPersistingCheck.Nothing)]
//NPXDefault(typeof(AccessInfo.businessDate), PersistingCheck = PXPersistingCheck.Nothing)]
public virtual DateTime? Date { get; set; }
public abstract class date : PX.Data.BQL.BqlDateTime.Field { }
#endregion
#region Description
DPXDBString(500, IsUnicode = true, InputMask = "")]
MPXUIField(DisplayName = "Description", Required = true, Enabled = true)]
ePXDefault(typeof(Current), PersistingCheck = PXPersistingCheck.Nothing)]
public virtual string Description { get; set; }
public abstract class description : PX.Data.BQL.BqlString.Field { }
#endregion
#region TotalCost
nPXDBDecimal()]
BPXUIField(DisplayName = "Total Cost", Required = true, Enabled = true)]
ePXDefault(typeof(Current), PersistingCheck = PXPersistingCheck.Nothing)]
public virtual Decimal? TotalCost { get; set; }
public abstract class totalCost : PX.Data.BQL.BqlDecimal.Field { }
#endregion
}
#endregion
}
}