Displaying a Custom DAC in MYOB Search

This activity describes how to add support of MYOB Search to a custom DAC.

Acumatica Search Overview

MYOB Acumatica provides a text search shown in the following screenshot.

Figure 1. MYOB Acumatica Search


This search allows user to find DACs which match text entered in the search box.

A DAC is displayed in the search results if a DAC meets the following requirements:

  • The DAC is marked with the PXPrimaryGraph attribute, or an attribute derived from it. The attribute is used to provide the navigation to search results. The results that support navigation are not displayed to a user.
  • The DAC has the NoteID field
  • The NoteID field of the DAC has the PXSearchableAttribute declared on it.

    The PXSearchableAttribute can configure access restriction or format of the search result. For details, see the PXSearchableAttribute Class.

  • The DAC is present in the search index.

Customization Description

Suppose you added a custom DAC and you need to a user to be able to search information displayed in the DAC.

For example, suppose that you have the custom RSSVWorkOrder DAC which contains information about repair work orders. The fields of the RSSVWorkOrder DAC are displayed in the Summary area of the Repair Work Orders (RS301000) form as shown in the following screenshot.

Note:
The DAC is developed in the T220 Data Entry and Setup Forms training course. You can find the full example in the Help-and-Training-Examples repository on GitHub.
Figure 2. Repair Work Orders form


Process Overview

To implement DAC search, you need to specify the PXPrimaryGraph attribute for the DAC, and declare the PXSearchable attribute to the NoteID property of the DAC.

System Preparation

Before you begin performing the steps of this activity, do the following:

  1. Prepare an MYOB Acumatica instance as with the dataset that contains the RSSVWorkOrder DAC (for example, T230 Actions or T270 Workflow API course).
  2. Make sure you have enabled full-text search for the Microsoft SQL Server. For details, see Enabling Semantic Search for Microsoft SQL Server.
    Note:
    MYOB Acumatica supports database search event if this option is disabled, but users will get a warning about it.

Step 1: Configure the DAC

To add support of MYOB Search to the RSSVWorkOrder, do the following:

  1. For the RSSVWorkOrder DAC, specify the following attributes:
    • The PXCacheName attribute which defines the name which will be displayed for the entity in the Rebuild Full-Text Entity Index form
    • The PXPrimaryGraph attribute to specify the graph that corresponds to the default editing form for records of the DAC.
    You can add the following attributes to the RSSVWorkOrder DAC.
    [PXCacheName("Repair Work Order")]
    [PXPrimaryGraph(typeof(RSSVWorkOrderEntry))]
  2. In the RSSVWorkOrder DAC, make sure the NoteID field is present and is decorated with the PXNote attribute.
  3. Add a new search category for the RSSVWorkOrder DAC. (Because the RSSVWorkOrder DAC is located in a custom functional area called PhoneRepairShop, you need to add a new search category for the search results of the DAC). Search categories are located in the PX.Objects.SM.SearchCategory class. To add a new category, you need to create an extension of this class as the following code shows.
    public class SearchCategoryExt : PX.Objects.SM.SearchCategory
    {
        // the number must be the power of two 
        public const int RS = 32768;
    }
    Note:
    Currently, the search category is not used in the UI. The usage of the search category value will be implemented in future releases of MYOB Acumatica.
  4. Add the PXSearchable attribute to the NoteID field of the RSSVWorkOrder DAC as the following code shows.
    #region NoteID
    [PXSearchable(SearchCategoryExt.RS, "Repair Work Order: {0}",
        new Type[] { typeof(RSSVWorkOrder.orderNbr) },
        new Type[] { typeof(RSSVWorkOrder.orderNbr), 
            typeof(RSSVWorkOrder.description) },
        NumberFields = new Type[] { typeof(RSSVWorkOrder.orderNbr) },
        Line1Format = "{0:d}{1}{2}", Line1Fields = new Type[] 
            { typeof(RSSVWorkOrder.dateCreated), typeof(RSSVWorkOrder.status), 
              typeof(RSSVWorkOrder.customerID)},
        Line2Format = "{0}", Line2Fields = new Type[] { 
            typeof(RSSVWorkOrder.description) })]
    [PXNote()]
    public virtual Guid? NoteID { get; set; }
    public abstract class noteID : PX.Data.BQL.BqlGuid.Field<noteID> { }
    #endregion

    In the PXSearchable attribute, you specify the following:

    • The category of the search
    • The format string which defines the format of the title for the search result
    • Values which will be used as format arguments of the previous parameter value
    • The list of fields where the search should be performed
    • Fields containing numbers or prefixes that should be indexed
    • Format for the first and second lines of the result
    Important:
    The NoteID property must have exact capitalization; otherwise the search will not work for this DAC.
  5. Rebuild the Visual Studio project that contains the RSSVWorkOrder DAC.
  6. Rebuild the search indexes: on the Rebuild Full-Text Entity Index (SM209500) form, find the Repair Work Order entity, select it, and click Process on the form toolbar.

Step 2: Test the Search

To test the search for the record of the RSSVWorkOrder DAC, do the following:

  1. Open the Repair Work Orders (RS301000) form.

    Note the text of the Description box for the repair work orders.

  2. In the Search bar, type words from the Description box.
  3. In the Search results window, open Transactions and Profiles tab.

    The results of the search including the records from the Repair Work Orders form are shown.

  4. Click the result from the Repair Work Orders form.

    The corresponding record from the Repair Work Orders form is opened.

Examples in MYOB Acumatica Source Code

The following table lists MYOB Acumatica forms where the DAC search is implemented.

Form Location in Source Code
Invoices (SO303000) The PX.Objects.AP.APInvoice DAC
Sales Orders (SO301000) The PX.Objects.SO.SOOrder DAC