如何在Acumatica自定义DAC(EAAsset)中启用并配置自动化通知?
Got it, let's walk through exactly how to get those standard automation notification buttons working on your custom EAAsset DAC and AssetEntry graph. I’ve done this dozens of times for custom entities, so here’s the no-nonsense step-by-step breakdown:
First, you need to make sure your DAC and graph support Acumatica’s notification infrastructure:
- Add a NoteID field to your
EAAssetDAC: The notification system relies on the Note framework to track related notifications. Add this field if you haven’t already:public abstract class noteID : IBqlField { } [PXNote] public virtual Guid? NoteID { get; set; } - Update your
AssetEntrygraph inheritance: Change your graph to inherit fromPXGraphWithNotification<TGraph, TDac>instead of the basePXGraphclass. This gives it built-in notification support:public class AssetEntry : PXGraphWithNotification<AssetEntry, EAAsset> { // Your existing graph code here }
You have two easy ways to add the standard notification button to your AssetEntry page:
Option 1: ASPX Layout (Recommended)
Open your AssetEntry.aspx file, find the ActionBar section, and add the PXNotificationsMenu control—this automatically renders the full notification dropdown (View Notifications, Send Notification, etc.):
<px:PXActionBar runat="server" ID="ActionBar"> <!-- Your existing toolbar buttons here --> <px:PXNotificationsMenu runat="server" ID="btnNotifications" /> </px:PXActionBar>
Option 2: Code-Based Button
If you prefer adding it via C# (for dynamic scenarios), add this to your graph’s constructor:
public AssetEntry() { this.Toolbar.AddButton(new PXToolBarButton { Text = "Notifications", Command = "Notifications", Key = "Notification", Visible = true }); }
Now you need to set up notification templates tied to your EAAsset entity:
- Navigate to System > Management > Automation Notifications in Acumatica.
- Click Add to create a new template:
- Source Type: Select your
EAAssetDAC (it should appear in the dropdown if your custom project is deployed correctly). - Template ID/Description: Fill in a unique ID and friendly description.
- Trigger Conditions: Define when the notification should send (e.g., when
EAAsset.Statuschanges to "Disposed"). - Recipients: Choose roles, specific users, or map to a field on your DAC (like an
OwnerIDfield if you have one). - Message: Use placeholder values (e.g.,
[EAAsset.AssetID],[EAAsset.Description]) to pull dynamic data from your DAC.
- Source Type: Select your
- Check the Active box and save the template.
- Open your
AssetEntrypage, load anEAAssetrecord—you should see the notification button in the toolbar. - Click the button to access:
- View Notifications: See all sent/queued notifications for the record.
- Send Notification: Manually trigger a notification using your template.
- Verify automated triggers: Update the
EAAssetrecord to meet your template’s conditions, then check the System > Management > Notifications Log to confirm the notification was sent.
- If your DAC doesn’t appear in the Source Type dropdown: Ensure your DAC has the
[PXCacheName("Friendly Asset Name")]attribute for visibility, and confirm your custom project is published. - If the button doesn’t show up: Double-check your graph inheritance and ASPX control placement.
- If placeholders don’t populate: Make sure your DAC fields have the
[PXUIField(DisplayName="Field Name")]attribute.
内容的提问来源于stack exchange,提问作者user3857731

