Reputation: 51
On the Cases(CR30600) screen, I need to show all the business accounts with a status of 'Active' or 'On Hold' in a selector. How would the selector be created?
Upvotes: 0
Views: 350
Reputation: 1941
We start by looking for the graph (CRCaseMaint) and DAC field (CRCase.CustomerID) that you need to modify. Do this by using the Customization menus in the top right corner and selecting Inspect Element and then clicking the field. Alternatively, hold Ctrl + Alt and click the field.
Next, we need to consider if this change is needed everywhere that CRCase.CustomerID is used or just in the CRCaseMaint graph (CR306000 screen). If you need the change applied everywhere, you would want to customize the DAC. If only in this screen, you could use CacheAttached to redefine the field only in this graph.
If you are just starting out, you might be inclined to redefine the selector itself. However, I would suggest that you use PXRestrictor in this case as you simply want to add a new condition to what records to display.
Since you didn't give much detail, I will assume you only need this restriction in the specific screen named. Therefore, we will use CacheAttached in the graph extension to tweak the field's behavior. Be sure to apply PXMergeAttributes(Method = MergeMethod.Append) or your CacheAttached will completely replace the predefined attributes for the field when you are in this graph.
#region CRCase_CustomerID_CacheAttached
[PXMergeAttributes(Method = MergeMethod.Append)]
[PXRestrictor(typeof(Where<BAccount.status, Equal<CustomerStatus.active>,
Or<BAccount.status, Equal<CustomerStatus.hold>>>),
"Must be Active or On Hold")]
protected virtual void CRCase_CustomerID_CacheAttached(PXCache sender) { }
#endregion
Upvotes: 3
Reputation: 479
using PX.Data;
namespace PX.Objects.CR
{
public class CRCaseMaint_Extension : PXGraphExtension<CRCaseMaint>
{
#region Event Handlers
[PXMergeAttributes(Method = MergeMethod.Append)]
[PXRestrictor(typeof(
Where<BAccount.status, Equal<BAccount.status.active>,
Or<BAccount.status,Equal<BAccount.status.hold>>>), Messages.CustomerRequired, typeof(BAccount.acctCD))]
protected virtual void CRCase_CustomerID_CacheAttached(PXCache cache)
{}
#endregion
}
}
Upvotes: 2