1

I'm trying to set the default value of a custom field to the defContactID of the currently logged in user. I cannot get the BQL correct, any advise?

namespace PX.Objects.PJ.DailyFieldReports.PJ.Graphs
{
    public class DailyFieldReportEntry_Extension : PXGraphExtension<DailyFieldReportEntry>
    {
        protected void DailyFieldReport_UsrOwner_FieldDefaulting(PXCache cache, PXFieldDefaultingEventArgs e, PXFieldDefaulting InvokeBaseHandler)
        {
            if (InvokeBaseHandler != null)
                InvokeBaseHandler(cache, e);
            var row = e.Row as DailyFieldReport;

            //BQL Statement to pull the EPEmployee record for the currently logged in employee

            e.NewValue = EPEmployee.defContactID;
        }
    }
}


1 Answers1

2

To get the logged in user details you can use the AccessInfo object which is in every graph. Accessinfo.UserContactID will retrieve the logged in user contact ID.

you can also use this by specifying it in the PXDefault attribute, without having the need to use the field event. In this case:

[PXDefault(typeof(AccessInfo.userContactID)) 
Jean Claude Abela
  • 782
  • 1
  • 9
  • 26