I have a customization that overrides the Purchase Order Line Account field drop-down lookup selector on the Purchase Order screen. It populates like I want, but the account selected from the dropdown doesn't display in the grid field after chosen. Here it is:
[PXSelector(
typeof(Search5<Account.accountID,
InnerJoin<PMCostBudget, On<Account.accountGroupID, Equal<PMCostBudget.accountGroupID>>>,
Where2<Where<PMCostBudget.projectID, Equal<Current<POLine.projectID>>, Or<Current<POLine.projectID>, IsNull>>,
And2<Where<PMCostBudget.projectTaskID, Equal<Current<POLine.taskID>>, Or<Current<POLine.taskID>, IsNull>>,
And2<Where<PMCostBudget.costCodeID, Equal<Current<POLine.costCodeID>>, Or<Current<POLine.costCodeID>, IsNull>>,
And<Where<Current<POLine.lineType>, Equal<POLineType.nonStock>, Or<Current<POLine.lineType>, IsNull>>>>>>,
Aggregate<GroupBy<Account.accountID>>,
OrderBy<Asc<Account.accountCD>>>),
DescriptionField = typeof(Account.description),
Filterable = false,
SelectorMode = PXSelectorMode.DisplayModeValue
)]
It basically filters on the line type, project, task, and cost code selected on the same PO line. What am I missing or doing wrong so that the selected AccountCD value will display?
Assuming the rest of your customization properly handled the override and the selector itself works (I think that is what you are saying)... If you need to display AccountCD, you should add SubstituteKey = typeof(Account.accountCD). Without that, the selector is set right now to display the AccountID.
[PXSelector(
typeof(Search5<Account.accountID,
InnerJoin<PMCostBudget, On<Account.accountGroupID, Equal<PMCostBudget.accountGroupID>>>,
Where2<Where<PMCostBudget.projectID, Equal<Current<POLine.projectID>>, Or<Current<POLine.projectID>, IsNull>>,
And2<Where<PMCostBudget.projectTaskID, Equal<Current<POLine.taskID>>, Or<Current<POLine.taskID>, IsNull>>,
And2<Where<PMCostBudget.costCodeID, Equal<Current<POLine.costCodeID>>, Or<Current<POLine.costCodeID>, IsNull>>,
And<Where<Current<POLine.lineType>, Equal<POLineType.nonStock>, Or<Current<POLine.lineType>, IsNull>>>>>>,
Aggregate<GroupBy<Account.accountID>>,
OrderBy<Asc<Account.accountCD>>>),
SubstituteKey = typeof(Account.accountCD),
DescriptionField = typeof(Account.description),
Filterable = false,
SelectorMode = PXSelectorMode.DisplayModeValue
)]
On PXSelector, the first "typeof" is the value to be selected. You can add subsequent typeof() references if you want to designate fields to display in the PXSelector (if your intent is to display an actual selector).
SubstituteKey = typeof(DAC Field) alters the selector's display to show the designated field rather than the actual value. It is very common to select the recordID field and substitute the recordCD field.
DescriptionField displays the field designated after the displayed valued (the specifically selected field or the SubstituteKey field if specified). I could be wrong, but I don't believe this shows when the selector is displayed in a grid. I believe it only applies to form fields, such as if you toggle the grid row to a form view.
Filterable is optional, but it allows you to set filters in the selector, such as when you have a lot of records to retrieve and may want to quickly locate a value. I believe there is some overhead to using it, so setting to false as you did could be a tiny performance gain.
I never used SelectorMode before, so you taught me something new here! If adding SubstituteKey does not resolve your issue, you might try removing the SelectorMode line to see if that resolves your issue. By the way it reads, that could be changing the behavior of the selector from what I would expect.
Acumatica support's suggestion solved my problem. Since the Account id is a segmented key, I needed to manually change the PXSegmentedValue to a PXSelector in the .ASPX to get it to work. I also got it to work without that change by using a PXDimensionSelector instead of a plain PXSelector in the override.
[PXDimensionSelector(AccountAttribute.DimensionName,
typeof(Search5<Account.accountID>...
I am trying to make a field required on the line item of an AP Invoice, the Tax Category field. However when I change the field to be required I run into the problem of the detail total and the balance to no longer update on the form.
What I've tried doing is eliminating the PersistingCheck = PXPersistingCheck.Nothing of the PXDefault attribute of the TaxCategoryID. This causes the field to be required on the form, however as I've stated, it also causes the form to no longer update totals. I've tried changing the PersistingCheck to PXPersistingCheck.Null, but this also prevents the totals from being updated.
Originally the PXDefault attribute for the Tax Category field is as follows:
[PXDefault(typeof(Search<InventoryItem.taxCategoryID,
Where<InventoryItem.inventoryID, Equal<Current<APTran.inventoryID>>>>),
PersistingCheck = PXPersistingCheck.Nothing)]
This is what my code is:
[PXDefault(typeof(Search<InventoryItem.taxCategoryID,
Where<InventoryItem.inventoryID, Equal<Current<APTran.inventoryID>>>>))]
What I want is to be able to have the Tax Category field required and the totals to be updated as usual, but I am not able to due to something in the code preventing the totals to be updated when the PXDefault attribute of the Tax Category field is changed.
Is there anything additional I must do in order for these issues to be resolved or am possibly going about this the wrong way?
You need to correctly change the PersistenceCheck and add Required=true to PXUIFieldAttribute for showing a red asterisk symbol near the column's name. Please see the example of how to do that using PXMergeAttributesAttribute and PXCustomizeBaseAttribute:
public class APInvoiceEntry_Extension : PXGraphExtension<APInvoiceEntry>
{
#region Event Handlers
[PXMergeAttributes(Method = MergeMethod.Merge)]
[PXCustomizeBaseAttribute(typeof(PXUIFieldAttribute), nameof(PXUIFieldAttribute.Required),true)]
[PXCustomizeBaseAttribute(typeof(PXDefaultAttribute), nameof(PXDefaultAttribute.PersistingCheck), null)]
protected virtual void APTran_TaxCategoryID_CacheAttached(PXCache cache)
{
}
#endregion
}
Here is My DAC Field for the Selector.
It seems fine on the first run, but when I select through the selector, its just blinks, or nothing happens, but when I nagivate through the next and previous buttons it selects the records.
#region RQBatchNbr
[PXDBString(15, IsKey =true, InputMask ="")]
[PXDefault()]
[PXUIField(DisplayName = "Batch Nbr", Required = true)]
[PXSelector(
typeof(Search<GNRequest.rQBatchNbr>),
typeof(GNRequest.prefixCode),
typeof(GNRequest.description),
DescriptionField = typeof(GNRequest.description)
)]
[AutoNumber(
typeof(Search<GNSetup.requestBatchNumberingID>),
typeof(AccessInfo.businessDate)
)]
#endregion
One reason can be that you have forgotten setting IsUnicode = true in the PXDBStringAttribute.
Another one can be related to the typeof(AccessInfo.businessDate) in the AutoNumberAttribute. Try adding Date field to your DAC and passing him instead of AccessInfo.businessDate.
It seems a little weird, but I just Redo the whole ASPX Page. it turns out to be working as it is.
How can I change the prompt character for the key field for my custom table. The only way I know how to change it is to change the segmented key, but since this is a custom table, there is none. Do I have to create one and tie it to my new table? If so, how do I do that? Is there a parameter in the IsKey?
You want to look into InputMask and DisplayMask attribute property.
[PXDBString(10, IsUnicode = true, IsKey = true, InputMask = ">aaaaaaaaaa")]
Example of use:
InputMask = ">LLLLL"
InputMask = ">aaaaaaaaaa"
InputMask = ">CC.00.00.00"
Full documentation of this feature can be found here:
https://help.acumatica.com/Main?ScreenId=ShowWiki&pageid=d0758787-4c73-423b-8566-11c83f3acde8
We have a few needs to have a time field in Acumatica (PXDBInt as total minutes) to show the value to the user and allow the user to enter in a negative value. The standard formatting of the PXDBTimeSpanLong attribute doesn't allow a negative value to be entered or correctly displayed (db value or unbound formula value is negative already).
Has anyone created a custom class that inherits PXDBTimeSpanLongAttribute and been able to get a negative value to display and be entered? We are using the TimeSpanFormatType.ShortHoursMinutesCompact format which displays in hh:mm
Example user entries:
"01:30" (1 hour and 30 minutes)
"-02:45" (negative 2 hours and 45 minutes)
"00:05" (5 minutes)
Sample DAC usage for PXDBTimeSpanLongAttribute:
public abstract class myTime : PX.Data.IBqlField
{
}
[PXDBTimeSpanLong(Format = TimeSpanFormatType.ShortHoursMinutesCompact)]
[PXUIField(DisplayName = "My Time")]
public virtual Int32? MyTime { get set; }
Testing the formatting using ShortHoursMinutesCompact
A positive value between "00:00" (int 0) and "23:59" (int 1439) works correctly
A negative number while stored in the database correctly is not correctly displayed (assuming the entry allows for negative entry). For example an expected "-02:45" (int -165) value results in a display of " 0:2 ". When I click in the field then click out the value is changed to "00:02" without entering any new value.
There is no field restriction from entering in a value greater than 24 hours even though the intent of the ShortHoursMinutesCompact format is a 24 hour entry. The field will allow and accept any value that fits the hh:mm format (values between "00:00" and "99:99"). When the user enters for example "29:00" the displayed value is changed to "05:00" but the database value is 1740 (29 hours as total minutes).
Found a workaround
While I need the PXDBTimeSpanLongAttribute to accept negative values for all allowable formats I was able to solve the more important issue for my requirement of needing a negative value 24 hour time field (which validates the entry within -24 to +24 hours).
I found PXTimeListAttribute is a working version of PXDBTimeSpanLongAttribute (when using the ShortHoursMinutesCompact format).
Benefits of using PXTimeList vs PXDBTimeSpanLong (ShortHoursMinutesCompact)
Using an int data type - no need to change the database field type. (Need to include the PXDBInt attribute with PXTimeListAttribute vs before PXDBTimeSpanLong was both)
Allows for both positive and negative numbers
Restricts the entry from within +/- 23:59
In a perfect world it would be nice to allow -24:00 to +24:00 but topic for another day.
In addition to changing the attribute used on my DAC/field I had to update the page entry for my field from a PXMaskEdit to PXTimeSpan using the following example:
Page grid - RowTemplate:
<px:PXTimeSpan ID="edMyTimeField" TimeMode="True" runat="server" DataField="MyTimeField" InputMask="hh:mm" CommitChanges="True" />
Page grid - Columns:
<px:PXGridColumn DataField="MyTimeField" Width="60px" AutoCallBack="True" RenderEditorText="True"/>
Sample usage of the attribute:
#region MyTimeField
public abstract class myTimeField : PX.Data.IBqlField
{
}
[PXDBInt]
[PXTimeList]
[PXDefault(0)]
[PXUIField(DisplayName = "My Time")]
public virtual Int32? MyTimeField { get; set; }
#endregion