Skip to content

Instantly share code, notes, and snippets.

@Parmisean
Last active Jul 28, 2021
Embed
What would you like to do?
namespace MyCustomization.DAC
{
[Serializable]
[PXCacheName("My Custom Table")]
public class MyCustomDAC : IBqlTable
{
#region Keys and other fields
// ...
#endregion
#region PrimaryField
public abstract class primaryField : BqlString.Field<primaryField> { }
[PXDBString]
[PXUIField(DisplayName = "Primary Field!")]
public virtual string PrimaryField { get; set; }
#endregion
#region DependentField
public abstract class dependentField : BqlString.Field<dependentField> { }
[PXDBString]
[PXDefault("The default value")]
[PXUIField(DisplayName = "Dependent Field!")]
[PXFormula(typeof(Default<primaryField>))]
public virtual string DependentField { get; set; }
#endregion
}
}
namespace MyCustomization.Graph
{
public class MyCustomGraph : PXGraph<MyCustomGraph>
{
public SelectFrom<PrimaryDAC>.View PrimaryDocument;
public SelectFrom<DependentDAC>.View DependentRecords;
#region Actions
#endregion
#region Events
protected virtual void _(Events.FieldUpdated<PrimaryDAC, PrimaryDAC.primaryField> eventHandler)
{
PrimaryDAC row = eventHandler.Row;
if (row is null) return;
UpdateDependentFields(row);
}
#endregion
private protected virtual void UpdateDependentFields(PrimaryDAC row)
{
var dependentRecordCollection = DependentRecords.Select();
foreach (var dependentRecord in dependentRecordCollection)
{
dependentRecord.DependentField = "My new value";
DependentRecords.Update(dependentRecord);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment