TL;DR - I am creating a time clock feature on the Employee Time Activities Screen (EP307000). How does one select/use the default view already built into a screen (or graph)?
I have two custom actions - Stop_Timer and Pause_Timer. I could not figure out how to act upon the "Activity" view already built into the Graph (PX.Objects.EP.EmployeeActivitiesEntry).
To solve the problem, I wrote my own PXSelect statement (seen below). But, by writing my own PXSelect statement, I broke the filter already present on the screen. Additionally, I seem to have lost the ability to use the "DependonGrid" property of the "PXDSCallbackCommand".
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using PX.Common;
using PX.Data.EP;
using PX.Objects.CR;
using PX.Objects.CS;
using PX.Objects.CT;
using PX.Objects.IN;
using PX.Objects.PM;
using PX.SM;
using PX.Data;
using PX.TM;
using OwnedFilter = PX.Objects.CR.OwnedFilter;
using PX.Api;
using PX.Objects;
namespace PX.Objects.EP
{
public class EmployeeActivitiesEntry_Extension : PXGraphExtension<EmployeeActivitiesEntry>
{
#region Select
public PXSelectJoin<EPActivityApprove,
InnerJoin<PMTask,
On<PMTask.taskID, Equal<EPActivityApprove.projectTaskID>>,
LeftJoin<PMTimeActivity,
On<PMTimeActivity.noteID, Equal<EPActivityApprove.origNoteID>>>>,
Where<EPActivityApprove.ownerID, Equal<Current<EmployeeActivitiesEntry.PMTimeActivityFilter.ownerID>>,
And<EPActivityApprove.trackTime, Equal<True>>>> Activity;
#endregion
#region Actions
public PXAction<PX.Objects.EP.EmployeeActivitiesEntry.PMTimeActivityFilter> Stop_Timer;
[PXButton]
[PXUIField(DisplayName = "Stop")]
protected void stop_Timer()
{
EPActivityApprove row = Activity.Current;
PMTimeActivityExt pMTimeActivityExt = PXCache<PMTimeActivity>.GetExtension<PMTimeActivityExt>(row);
throw new PXException("You pressed Stop Timer for the row containing Date = " + (DateTime)row.Date);
// All of my actions
Base.Caches[typeof(PMTimeActivity)].Update(pMTimeActivityExt);
Base.Caches[typeof(EPActivityApprove)].Update(row);
}
public PXAction<PX.Objects.EP.EmployeeActivitiesEntry.PMTimeActivityFilter> Pause_Timer;
[PXButton]
[PXUIField(DisplayName = "Pause/Play")]
protected void pause_Timer()
{
EPActivityApprove row = Activity.Current;
PMTimeActivityExt pMTimeActivityExt = PXCache<PMTimeActivity>.GetExtension<PMTimeActivityExt>(row);
throw new PXException("You pressed Pause Timer for the row containing Date = " + (DateTime)row.Date);
// All of my actions
Base.Caches[typeof(PMTimeActivity)].Update(pMTimeActivityExt);
Base.Caches[typeof(EPActivityApprove)].Update(row);
}
#endregion
}
}
see customization package stored on Github - for laughter at my poor coding skills
If you are happy with the view in the base graph, just refer to it as Base.Activity in your graph extension. Accessing views and actions work similarly to how you did Base.Caches at the bottom of your code.
The current Activity record => Base.Activity.Current
EPActivityApprove row = Base.Activity.Current;
EPActivityApproveExt rowExt = row.GetExtension<>EPActivityApproveExt>();
rowExt.MyField = "My Value";
Base.Activity.Cache.Update(rowExt);
If you need to press the save button at some point...
Base.Save.Press();