To Display a DAC in MYOB Search
MYOB Acumatica provides a text search shown in the following screenshot.
This search allows user to search information from DAC fields that matches text entered in the search box. The DAC search result is displayed in the Documents and Transactions tab and includes the following lines:
- Title (the blue text in the screenshot)
- First information line (optional)
- Second information line (optional)
A DAC can be displayed in the search results if the DAC meets the following requirements:
- The DAC has the PXPrimaryGraphAttribute declared on the graph.
- The DAC has the NoteID field and this field is marked with the
PXNote attribute.
The NoteID field is the main and unique reference of any row in the MYOB Acumatica database.
- 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. In the attribute parameters, you need to specify the DAC properties which will be used to build cached content from the DAC entity. You can also specify conditions which determine whether the DAC is displayed in the search results.
- The DAC is present in the search index.To add a DAC to a search index, you should rebuild the search index. For details, see Search Indexes: To Rebuild Search Indexes.Note:You should rebuild search index after every upgrade.
For a detailed example of adding a DAC to MYOB Acumatica search, refer to Displaying a Custom DAC in MYOB Search.
To Display a DAC in MYOB Search
To configure a DAC to be displayed in MYOB Acumatica search, do the following :
- Find the NoteID field of the DAC.
- Decorate the NoteID field with the PXSearchable
attribute.
In the attribute declaration, specify the following parameters:
- category: The functional area to which the DAC search belongs
- titlePrefix: A format strings which defines the format of the
search result title. For example,
"Generic Inquiry: {0}"
. - titleFields: Fields which are displayed in the search result
- fields: Fields for which the cached content is built and stored in the search index
- Line1Format and Line1Fields: The format of the search result and its arguments which can be displayed in the first line of the search result
- Line2Format and Line2Fields: The format of the search result and its arguments which can be displayed in the second line of the search result
- NumberFields: All fields which are indexed with prefix and without it. For example, CT00000040 and 00000040.
You can also specify the following parameters which define conditions for displaying a DAC in search results:
- MatchWithJoin: A BQL query which joins the current DAC with DACs which has a configured restriction group. Use this property to prevent the display of search results to users who don't have an access to the corresponding entities.
- WhereConstraint: A constraint which determines if the particular DAC instance is searchable or not.
- SelectDocumentUser: A select BQL expression that checks whether
the current user has access rights to the document. If the query is specified, then
the record is shown to the user only in two cases:
- The record was created by the current user
- The current user matches the BQL query specified in the parameter
- SelectForFastIndexing: An optimization property used only at full text index rebuild.
For the full list of possible parameters of the PXSearchable attribute, see PXSearchableAttribute.
Example of the full PXSearchable attribute declaration is shown in the following code.
[PXSearchable(SM.SearchCategory.AP, Messages.SearchableTitleDocument, new Type[] { typeof(APInvoice.docType), typeof(APInvoice.refNbr), typeof(APInvoice.vendorID), typeof(Vendor.acctName) }, new Type[] { typeof(APInvoice.invoiceNbr), typeof(APInvoice.docDesc)}, NumberFields = new Type[] { typeof(APInvoice.refNbr) }, Line1Format = "{0:d}{1}{2}", Line1Fields = new Type[] { typeof(APInvoice.docDate), typeof(APInvoice.status), typeof(APInvoice.invoiceNbr) }, Line2Format = "{0}", Line2Fields = new Type[] { typeof(APInvoice.docDesc) }, MatchWithJoin = typeof(InnerJoin<Vendor, On<Vendor.bAccountID, Equal<APInvoice.vendorID>>>), SelectForFastIndexing = typeof(Select2<APInvoice, InnerJoin<Vendor, On<APInvoice.vendorID, Equal<Vendor.bAccountID>>>>) )] [PXNote(...))]l public override Guid? NoteID { get; set; }
To Add a DAC Field to MYOB Search
If some of the DAC fields can already be displayed in MYOB Acumatica Search, but you need to add a new field to the search, you should do the following:
- Find the NoteID field of the DAC.
Make sure it has the PXSearchable attribute on it. For example, the PXSearchable attribute looks as the following code shows.
[PXSearchable(SM.SearchCategory.AP, Messages.SearchableTitleDocument, new Type[] { typeof(APInvoice.docType), typeof(APInvoice.refNbr), typeof(APInvoice.vendorID), typeof(Vendor.acctName) }, new Type[] { typeof(APInvoice.invoiceNbr), typeof(APInvoice.docDesc)})] [PXNote(...))]l public override Guid? NoteID { get; set; }
- Add the field name to the fourth parameter of the attribute. In the example, the
Status
field is added to the search index.[PXSearchable(SM.SearchCategory.AP, Messages.SearchableTitleDocument, new Type[] { typeof(APInvoice.docType), typeof(APInvoice.refNbr), typeof(APInvoice.vendorID), typeof(Vendor.acctName) }, new Type[] { typeof(APInvoice.invoiceNbr), typeof(APInvoice.docDesc), typeof(APInvoice.Status})] [PXNote(...))]l public override Guid? NoteID { get; set; }
- Rebuild your extension library.
- Rebuild search indexes. For details, see Search Indexes: To Rebuild Search Indexes.