Adding a Customized Button to a Processing Page [Acumatica] - acumatica

I am trying to customise an Acumatica Processing Page by adding my own processing button. I have tried the usual methods of extending the processing page but unfortunately the button is not displayed on the page.
public class APPrintChecks_Extension : PXGraphExtension<APPrintChecks>
{
public PXAction<APPayment> Test;
[PXProcessButton]
[PXUIField(DisplayName = "Button Test")]
protected virtual IEnumerable test(PXAdapter adapter)
{
return adapter.Get();
}
}
I do not want to override the existing functionality provided by the processing button and as such would like to add my own.
Thanks.

The primary view of the Process Payments / Print Checks page is Filter which is of type PrintChecksFilter. So you need to have your PXAction on that Type. Try to replace
public PXAction<APPayment> Test;
with
public PXAction<PrintChecksFilter> Test;

Related

How do I edit a BLC extension that is part of out-of-the-box Acumatica, specifically SM_CRCaseMaint.cs?

I need to add some logic to the CreateServiceOrder action that is shown on the CRCaseMaint screen. I've discovered that the logic actually exists in the file called SM_CRCaseMaint.cs in a class that is an extension of CRCaseMaint. This file is part of base Acumatica, so it is already an extension but cannot be edited directly without risk of losing the changes when the instance is updated. When I attempt to create a graph extension:
I get an error:
Is there any way I can edit this page?
According to Brendan's answer here, as of Acumatica version 2018R1 Update 4 (18.104.0023) you can override or redefine the content of the graph extension shipped with the product.
I did a test with CreateServiceOrder action in version 2018R2 and it worked. The debugger did break into the redefined action when I invoked Create Service Order action from a case:
using PX.Data;
using PX.Objects.FS;
namespace PX.Objects.CR
{
public class CRCaseMaint_Extension : PXGraphExtension<CRCaseMaint>
{
[PXCopyPasteHiddenView]
public PXFilter<FSCreateServiceOrderOnCaseFilter> CreateServiceOrderFilter;
public PXAction<CRCase> CreateServiceOrder;
[PXButton]
[PXUIField(DisplayName = "Create Service Order", MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select)]
public virtual void createServiceOrder()
{
CRCase crCaseRow = Base.Case.Current;
FSxCRCase fsxCRCaseRow = Base.Case.Cache.GetExtension<FSxCRCase>(crCaseRow);
if (CreateServiceOrderFilter.AskExt() == WebDialogResult.OK)
{
Base.Case.SetValueExt<FSxCRCase.sDEnabled>(crCaseRow, true);
Base.Case.SetValueExt<FSxCRCase.branchLocationID>(crCaseRow, CreateServiceOrderFilter.Current.BranchLocationID);
Base.Case.SetValueExt<FSxCRCase.srvOrdType>(crCaseRow, CreateServiceOrderFilter.Current.SrvOrdType);
Base.Case.SetValueExt<FSxCRCase.assignedEmpID>(crCaseRow, CreateServiceOrderFilter.Current.AssignedEmpID);
Base.Case.SetValueExt<FSxCRCase.problemID>(crCaseRow, CreateServiceOrderFilter.Current.ProblemID);
Base.Case.Cache.SetStatus(crCaseRow, PXEntryStatus.Updated);
Base.Save.Press();
}
}
}
}

Add PXButton in top Navbar

How do I put a PXActionButton that I have created using the below code in top nav bar of Acumatica.
public override void Initialize()
{
if (!String.IsNullOrEmpty(Base.PrimaryView))
{
Type primaryViewItemType = Base.Views[Base.PrimaryView].Cache.GetItemType();
PXAction action = PXNamedAction.AddAction(Base, primaryViewItemType, "SubmitTicket", "Submit Ticket", TestClick);
}
}
public IEnumerable TestClick(PXAdapter adapter)
{
throw new PXException("Button clicked from graph" + Base.GetType().Name);
}
I tried to edit in Menu.aspx inside Frames page. But it doesn't seem to be the right one.
Is there some way, that I can choose the top nav as container while adding the button via my code in PXGraphExtension?
The screen you are showing "PM3010PL" is a Generic Inquiry screen:
Generic Inquiries can't be customized using Acumatica Project Editor like the other regular screens such as project "PM301000". This applies to all screen ending with suffix "PL".
Editing Menu.ASPX is out of customization scope and strongly discouraged. To achieve what you want, I would create a new Custom Inquiry screen using template 'Grid (Grid View)' that is functionally equivalent to 'PM3010PL'. Since that screen would be a Custom Inquiry instead of Generic Inquiry you can extend the graph and screen to customize it like all other screens.
The trick to have the button appear at the top is to decorate the action event handler with 'PXProcessButton' attribute instead of 'PXButton':
public class ProjectEntry_Extension : PXGraphExtension<ProjectEntry>
{
public PXAction<PMProject> testBill;
[PXUIField(DisplayName = "Test Bill", MapEnableRights = PXCacheRights.Update, MapViewRights = PXCacheRights.Select)]
[PXProcessButton(Tooltip = "Test Bill")]
public virtual IEnumerable TestBill(PXAdapter adapter)
{
return adapter.Get();
}
}
Then you declare the action in the Customized screen (Button Actions->Edit ASPX), this is the part you can do with regular screens but can't do with Generic Inquiries:
The Action will then be displayed on top:
EDIT:
For the top most navigation bar (in blue in your screenshot), this is completely out of customization scope. You could work out something in ASP I guess but this can't be packaged in customization and will be rejected for customization certification process.

Render Action button

I was creating a new Screen with the FormDetail template where I would be having a Filter DAC and list of DAC to display on Grid. I created the page successfully. Then,I wanted to put a button on the top of the button which would pull data from api and refresh grid. So, I wrote the below code to render an action button on page(FormDetail) like this.
But, it is not working.
using System;
using PX.Data;
namespace AcumaticaSquarePOSIntegration
{
public class SquarePOSTransactionInquiry : PXGraph<SquarePOSTransactionInquiry>
{
public PXSave<MasterTable> Save;
public PXCancel<MasterTable> Cancel;
public PXFilter<MasterTable> MasterView;
public PXFilter<DetailsTable> DetailsView;
public PXAction<MasterTable> Calc;
[PXUIField(DisplayName="Calc")]
[PXButton]
protected virtual IEnumerable calc(PXAdapter adapter)
{
return adapter.Get();
}
[Serializable]
public class MasterTable : IBqlTable
{
}
[Serializable]
public class DetailsTable : IBqlTable
{
}
}
}
I even tried add
Is there anything that I am missing here?
You have two PXFilters, change the second to PxSelect and make the PXFilter your first Data view in the list.
try using PXProcessButton instead of PXButton.
Also make sure MasterView is specified in aspx as a PrimaryView.

How to add an action and handler to the Process Shipments screen?

How do I add an action and handler to the Process Shipments screen? We want to add an action to the Action combobox on screen SO503000, and then add a handler in code to process the new action. We want to do this without having to override the huge switch/case statement for Action in the SOShipmentEntry graph.
The PXAutomationMenu attribute pulls from Automation Steps all actions, which have appropriate processing screen set up as Mass Processing Screen:
To extend the list of actions available on the Process Shipments screen, please proceed as follows:
Declare custom action within a BLC extension and invoke AddMenuAction method during BLC initialization to add it as a drop-down item for the Actions button
To add custom action to the Process Shipments screen, add custom actions to appropriate automation step(s) and specify Mass Processing Screen ID. When user selects your custom action, Shipments from all Automations Steps, that contain a custom action, will be available for selection on the Process Shipments screen:
Two extensions (of the same 1st level) declared for the SOShipmentEntry BLC, as shown in the code snippet below, can be used to extend Actions drop-down with multiple customization projects (two customization packages that are independent of each other; either one or both may be published on a particular site. And both add an action to the Process Shipments screen):
To address this scenario, :
public class SOShipmentEntryExt1 : PXGraphExtension<SOShipmentEntry>
{
public PXAction<SOShipment> Test1;
[PXButton]
[PXUIField(DisplayName = "Test Action 1")]
protected void test1()
{
throw new PXException("Not implemented action: {0}", "Test Action 1");
}
public override void Initialize()
{
Base.action.AddMenuAction(Test1);
}
}
public class SOShipmentEntryExt2 : PXGraphExtension<SOShipmentEntry>
{
public PXAction<SOShipment> Test2;
[PXButton]
[PXUIField(DisplayName = "Test Action 2")]
protected void test2()
{
throw new PXException("Not implemented action: {0}", "Test Action 2");
}
public override void Initialize()
{
Base.action.AddMenuAction(Test2);
}
}

Add button to the top toolbar on Case screen

I am trying to add a new toolbar button next to "TAKE CASE" in Case screen (CR306000). I have customize CRCaseMaint DAC but still the button is not appearing. Can anyone please suggest.
replicated this and issue and solution was PXAction should be public. In sample above its marked as private.
code as follows works:
public class CaseExtension : PXGraphExtension<CRCaseMaint>
{
public PXAction<CRCase> Change2;
[PXButton(CommitChanges=true)]
[PXUIField(DisplayName="Change Me")]
protected virtual void change2()
{
}
}
Here is another reason. In base graph there is code
public PXAction<CRCase> takeCase;
[PXUIField(DisplayName = "Take Case", MapEnableRights = PXCacheRights.Update, MapViewRights = PXCacheRights.Select)]
[PXButton]
public virtual IEnumerable TakeCase(PXAdapter adapter)
Acumatica itself has button TakeCase which blocks your button TakeCase. You need to understand, why you need another one button Take Case because Acumatica team already implemented it. Are you sure you want to replace it?
Following steps are needed for you:
1. Create class library (CL).
2. Reference in created CL dlls from Acumatica folder which start from PX.*
3. In CL add new class CRCaseMaintExt with member TakeCase like this:
public class CRCaseMaintExt : PXGraphExtension<CRCaseMaint>
{
private PXAction<CRCase> TakeCase2;
[PXButton]
[PXUIField(DisplayName = "Take Case")]
public virtual IEnumerable takeCase2(PXAdapter adapter)
{
//your custom code
return adapter.Get();
}
}
4. Take note, that case in TakeCase and takeCase matter. Also matters PXAction
5. Build CL
6. Add reference to CL to your Acumatica project.

Resources