Hi All,
Just a short article where I can share with you customization that can generate time cards from uploaded time activities.
Customization doing following:
- Selects the first and the last unreported (where no time-cards assigned) activity from currently selected employee.
- Goes week by week between first and last activities
- Create a new time card for every week using TimeCardMaint graph
- Code also automatically submit time card for approval
- In case there is unreported activity for already submitted or released time card, code can automatically generate time card correction and submit it again.
It is not very useful customization, but it can be used as good example of calling actions in Acumatica custom code.
public static T ExecAction<T>(PXCache cache, PXAction action, T row) where T : class { PXSelectDelegate handler = new PXSelectDelegate(delegate() { return new object[] { row }; } ); PXAdapter adapter = new PXAdapter(new PXView(cache.Graph, true, BqlCommand.CreateInstance(typeof(Select<>), cache.GetItemType()), handler)); foreach (T item in action.Press(adapter)) { return item; } return null; }
That static method can call any base action and return an new instance of the DAC even if it was changed during internal logic. Good example here is correction of time card – in that case action will change current time card because correcting cart will have another ID.
Full code snippet:
Have a nice time reporting!