Skip to main content
Question

Getting and set new value to customized unbound field in graph.

  • Jan 16, 2024 11:18 AM UTC
  • 5 replies
  • 226 views
  • Translate All

Forum|alt.badge.img

Hi All,

I need to get the value of newly added unbound customized field value and also need to set new value to another customized unbound field. I created separated extension class from the parent class and added new fields into it. 

 

public sealed class TaxHistoryMasterExt : PXCacheExtension<PX.Objects.TX.TaxHistoryMaster>
    {
        public static bool IsActive()
        {
            return true;
        }

        #region PeriodStart
        [PXDate()]
        [PXUIField(DisplayName = "PeriodStart")]
        [PXDefault(typeof(AccessInfo.businessDate))]
        public  DateTime? UsrPeriodStart { get; set; }
        public abstract class usrPeriodStart : PX.Data.BQL.BqlDateTime.Field<usrPeriodStart> { }
        #endregion
        
        #region Period End
        [PXDate()]
        [PXUIField(DisplayName = "PeriodEnd")]
        [PXDefault(typeof(AccessInfo.businessDate))]
        public  DateTime? UsrPeriodEnd { get; set; }
        public abstract class usrPeriodEnd : PX.Data.BQL.BqlDateTime.Field<usrPeriodEnd> { }
        #endregion

        #region ByDatePeriod
        [PXBool()]
        [PXUIField(DisplayName = "ByDatePeriod")]
        [PXDefault(typeof(True))]
        public bool? UsrByDatePeriod { get; set; }
        public abstract class usrByDatePeriod : PX.Data.BQL.BqlBool.Field<usrByDatePeriod> { }
        #endregion
    }

Graph

public PXFilter<TaxHistoryMaster> History_Header;

protected virtual void TaxHistoryMaster_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
{

TaxHistoryMasterExt extensionRow = PXCache<TaxHistoryMaster>.GetExtension<TaxHistoryMasterExt>(History_Header.Current);

}

 

 

5 replies

darylbowman
Captain II
Forum|alt.badge.img+17

What have you tried so far?

 

Also, when do you need this to happen? When a field value is changed? When the record is being saved?

Translate

Forum|alt.badge.img
  • Author
  • Jr Varsity II
  • Jan 16, 2024 12:48 PM UTC

What have you tried so far?

 

Also, when do you need this to happen? When a field value is changed? When the record is being saved?

 When a field value is changed

Translate

darylbowman
Captain II
Forum|alt.badge.img+17

And what have you tried?

Translate

Forum|alt.badge.img
  • Author
  • Jr Varsity II
  • Jan 16, 2024 12:50 PM UTC

And what have you tried?

protected virtual void TaxHistoryMaster_RowSelected(PXCache sender, PXRowSelectedEventArgs e)

in this event 

TaxHistoryMasterExt extensionRow = PXCache<TaxHistoryMaster>.GetExtension<TaxHistoryMasterExt>(History_Header.Current);

Translate

darylbowman
Captain II
Forum|alt.badge.img+17

It’s still not really clear to me exactly what you’re trying to accomplish, but if you want to perform this on the update of another field, you’d want to use the FieldUpdated event for that field.

For instance, if you wanted to do this when Period Start is updated, it would look something like this:

protected virtual void _(Events.FieldUpdated<TaxHistoryMaster, TaxHistoryMasterExt.usrPeriodStart> e)
{
TaxHistoryMaster row = e.Row;
if (row is null) return;

var rowExt = row?.GetExtension<TaxHistoryMasterExt>();

var startDate = rowExt?.UsrPeriodStart;
var endDate = rowExt?.UsrPeriodEnd;
var byDatePeriod = rowExt?.UsrByDatePeriod;

// Do stuff
}

 

Translate