Skip to main content
Question

Populating usrFields from Project Task to Time Activity

  • September 30, 2021
  • 0 replies
  • 98 views

greglang
Varsity I
Forum|alt.badge.img+1

I have been attempting to update 2 Boolean field values on Time Activity based on the same usr fields in the PM-Task Table.  So when a time card has the project Task with “OnSite” Checked or “Travel” Checked it will carry over to the Time Card.  Once created I plan to use this to create fields to match Billable and Total Billable on the Time cards.  I understand that is best done with Event Handlers and maybe this would have been as well.  This is my first time working with Attributes and I have tried to write this a number of ways but somehow I am missing something.  My code is below if anyone has any ideas.

 

PMTask
{
  public class PMTaskExt : PXCacheExtension<PX.Objects.PM.PMTask>
  {
    #region UsrIsOnsite
    [PXDBBool]
    [PXUIField(DisplayName="IsOnsite")]

    public virtual bool? UsrIsOnsite { get; set; }
    public abstract class usrIsOnsite : PX.Data.BQL.BqlBool.Field<usrIsOnsite> { }
    #endregion

    #region UsrIsTravel
    [PXDBBool]
    [PXUIField(DisplayName="IsTravel")]

    public virtual bool? UsrIsTravel { get; set; }
    public abstract class usrIsTravel : PX.Data.BQL.BqlBool.Field<usrIsTravel> { }
    #endregion
  }
}

PMTimeActivity
{
  public class PMTimeActivityExt : PXCacheExtension<PX.Objects.CR.PMTimeActivity>
  {
    #region UsrIsOnsite
    [PXDBBool]
    [PXUIField(DisplayName="Onsite")]
    [PXFormula(typeof(Switch<
      Case<Where<
        PMTask.taskID, Equal<Current<PMTimeActivity.projectTaskID>>,
        And<PMTask.projectID, Equal<Current<PMTimeActivity.projectID>>>>,
        PMTaskExt.usrIsOnsite>,
        PMTaskExt.usrIsOnsite>))]


    public virtual bool? UsrIsOnsite{ get; set; }
    public abstract class usrIsOnsite: PX.Data.BQL.BqlBool.Field<usrIsOnsite> { }
    #endregion

    #region UsrIsTravel
    [PXDBBool]
    [PXUIField(DisplayName="IsTravel")]
    [PXFormula(typeof(PMTaskExt.usrIsTravel))]
        [PXFormula(typeof(Switch<
      Case<Where<
        PMTask.taskID, Equal<Current<PMTimeActivity.projectTaskID>>,
        And<PMTask.projectID, Equal<Current<PMTimeActivity.projectID>>>>,
        PMTaskExt.usrIsTravel>,
        PMTaskExt.usrIsTravel>))]
    public virtual bool? UsrIsTravel { get; set; }
    public abstract class usrIsTravel : PX.Data.BQL.BqlBool.Field<usrIsTravel> { }
    #endregion
  }
}

0 replies

Be the first to reply!

Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings