How do I implement presskey event in Acumatica? - acumatica

I want to call SmartPanel to popup by press any keys.
Example: We click F3 in Selector Field. It'll popup search panel to select.

Could you please check my answer in another thread? You should have no problems utilizing PXButtonAttribute ShortcutChar property with an action opening popup.
For example, the following extension SOOrderEntry extension class will open Inventory Lookup on the Sales Order screen with the F2 key press:
public class SOOrderEntryExt : PXGraphExtension<SOOrderEntry>
{
public PXAction<SOOrder> addInvBySite;
[PXUIField(DisplayName = "Add Stock Item", MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select)]
[PXLookupButton(ShortcutChar = (char)113)]
public virtual IEnumerable AddInvBySite(PXAdapter adapter)
{
return Base.addInvBySite.Press(adapter);
}
}

Related

Add Column in "Add Stock Item" dialog box in Sales Order screen of Acumatica

How can I add the "ItemType" column from "Stock Items" screen to "Add Stock Item" dialog box of Sales Order screen.
Stock Item Image
Sales Order Dialog Image
Is there any direct method using the Acumatica Customization Editor we can do this work or I need to use programming or coding to accomplish the task
Thanks.
You should be creating cache extension for the BQL table SOSiteStatusSelected and add a new field UsrItemType like following:
public class SOOrderEntryExt : PXGraphExtension<SOOrderEntry>
{
public sealed class SOSiteStatusSelectedExt : PXCacheExtension<SOSiteStatusSelected>
{
[PXDBString(1, IsFixed = true, BqlField = typeof(InventoryItem.itemType))]
[PXUIField(DisplayName = "Item Type", Visibility = PXUIVisibility.SelectorVisible)]
[INItemTypes.ListAttribute]
public string UsrItemType { get; set; }
public abstract class usrItemType : BqlType<IBqlString, string>.Field<usrItemType> { }
}
}
After this add the UsrItemType field on the Inventory Lookup screen in the Sales Orders form from the Customization Project Editor menu.

Acumatica Currency Rate Behavior

I am trying to copy the Currency Behavior of APInvoiceEntry BLC.
I'm confused, I copied already all the events, but with no luck,
CurrencyInfo_RowUpdated does not fire event. I am certain that this event is the Currency Conversion when you Click View Cury or View Base.
Somehow I managed to save CuryInfoID information on the Database. I'm only getting confused on the client events.
Am I missing something? I copied also the Currency Rate and set it to my own Currency Rate view. so it is working. Please enlighten me.
Thanks!
The View Base/View Cury action is handled by the ToggleCurrency.Handler() method. The APInvoiceEntry graph has the ToggleCurrency<APInvoice> CurrencyView; member which drives the button. Here is an example on how you could override it in an APInvoiceEntry graph extension:
using PX.Data;
using PX.Objects.CM;
namespace PX.Objects.AP
{
public class APInvoiceEntry_Extension : PXGraphExtension<APInvoiceEntry>
{
public CustomToggleCurrency<APInvoice> CurrencyView;
}
public class CustomToggleCurrency<TNode> : ToggleCurrency<TNode>
where TNode : class, IBqlTable, new()
{
public CustomToggleCurrency(PXGraph graph, string name)
: base(graph, name)
{
}
[PXUIField(DisplayName = "Toggle Currency", MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select)]
[PXButton(ImageKey = PX.Web.UI.Sprite.Main.Money, Tooltip = PX.Objects.CM.Messages.ToggleCurrencyViewTooltip)]
protected override System.Collections.IEnumerable Handler(PXAdapter adapter)
{
return base.Handler(adapter);
}
}
}

Is there any event triggered when highlighting a row?

I created a ListView to show the list of documents, then created a button "Button A" to do some actions, my requirement is I would like the button status may be changed with the selected document changes.
Fox example: there are three documents in the following graphic, I want the button is enabled when I click Order-00001 or Order-00002, and it is disabled for Order-00003 due to no money in it.
I appreciate if you could give me a hint if there is any event to be raised when I click a row. Thanks a lot.
To reduce callback to the server there isn't a row selected event. Instead there is PXToolbarButton StateColumn property to control the button enabled state.
When you declare your button, you specify a Boolean DAC field that will enable/disable the button based on it's value. Note that the button needs the DependOnGrid property set to the ID of the grid to get the selected row:
<px:PXToolBarButton Text="Button A" DependOnGrid="grid" StateColumn="IsButtonVisible">
IsButtonVisible is a custom unbound Boolean DAC field (you may choose any name you want except isSelected/Selected which is reserved for checkbox):
#region IsButtonVisible
public abstract class isButtonVisible : IBqlField
{
}
protected bool? _IsButtonVisible;
[PXBool]
[PXUIField(DisplayName = "Is Button Visible", Enabled = false, Visible = false)]
public virtual bool? IsButtonVisible
{
get
{
return _IsButtonVisible;
}
set
{
_IsButtonVisible = value;
}
}
#endregion
You can set the value of IsButtonVisible in the RowSelected event based on your business logic:
protected virtual void DAC_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
{
DAC row = e.Row as DAC;
if (row != null)
{
bool yourCondition = ???;
row.IsButtonVisible = yourCondition;
}
}
Source:
Enable disable button of grid or PXToolBarButton, which depends from value of column in Acumatica

Issue of creating new item using PXAction in Acumatica

I encounter an issue when using PXAction to create new item in Acumatica and appreciate you can give me a help.
I added the custom auto-increment attribute for the "DocumentNbr" field in my "Document" DAC following the Acumatica official document's example "Example 8.2: Creating the Custom AutoNumber Attribute" in the T200 Document as below.
Here is the snippet of code of the attribute setting for the "DocumentNbr" field:
#region DocumentNbr
protected string _DocumentNbr;
[PXDBString(15, IsUnicode = true, IsKey = true, InputMask = ">CCCCCCCC")]
[PXSelector(typeof(Search<MABUIPDocument.documentNbr>),
typeof(MABUIPDocument.documentNbr),
typeof(MABUIPDocument.documentDate),
typeof(MABUIPDocument.status),
typeof(MABUIPDocument.vendorID)
)]
[AutoNumber(typeof(MABUIPSetup.autoDocumentNbr), typeof(MABUIPSetup.lastDocumentNbr))]
[PXDefault()]
[PXUIField(DisplayName = "ID")]
public string DocumentNbr
{
get
{
return this._DocumentNbr;
}
set { this._DocumentNbr = value; }
}
public class documentNbr : IBqlField { }
#endregion
It is working fine that I can add, edit and delete documents normally as below:
I have a requirement that creates a new item when clicking button, so I created the "Test Creating new item" button including creating new item logic as below, in my understanding, it would show the created item after clicked the "Test Creating new item" button.
public PXAction<MABUIPDocument> BtnCreatingNew;
[PXButton(CommitChanges = true)]
[PXUIField(DisplayName = "Test Creating new item", Visible = true)]
protected virtual void btnCreatingNew()
{
MABUIPDocument row = Documents.Current;
row.DocumentDesc = "Test" + DateTime.Now.ToString();
row = Documents.Update(row);
Actions.PressSave();
}
The actually circumstance is although the new row has been inserted into the database and will occur if I click the "Next" arrow but the form content of the current view is cleared after clicking the button, I tried many methods like setting "Document.Current = row" and "sender.SetValue(row, fieldName, fieldNewValue)" but the content has been keeping blank after clicking the button whatever I tried. Can you please give me a hint what possible reason caused the issue? Thank you very much!
Because your ID value is only generated while new document is saved in the database, you must accordingly update PXAdapter's Searches collection with the actual ID value saved in the database:
public PXAction<MABUIPDocument> BtnCreatingNew;
[PXButton(CommitChanges = true)]
[PXUIField(DisplayName = "Test Creating new item", Visible = true)]
protected virtual IEnumerable btnCreatingNew(PXAdapter adapter)
{
MABUIPDocument row = Documents.Current;
row.DocumentDesc = "Test" + DateTime.Now.ToString();
row = Documents.Update(row);
Actions.PressSave();
adapter.Searches[adapter.Searches.Length - 1] = row.DocumentNbr;
return adapter.Get();
}

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