Hi Everyone,
Sometime you need to do some customization to meet customer requirements. One of these requirements can be an additional field where they can store some references to other systems/documents.
But when you have a reference you have to search it in the system. Here I will guide you, how to customize Acumatica to be able to search additional fields.
The main thing that we have to customize here is PXSearchableAttribute, which always have to be defined on NoteID field (you know that NoteID is main and unique reference to any row in the Acumatica database). IF you can check the code of this attribute you can see:
The main things here are first 4 lines, that define the way how system will index field from this entity. So we need to add one more type to the Title fields of Other field collections.
But before that we have to determine, what BQL Type should we use for our custom field. It is not a problem if you use extensions with Visual Studio, as you have all code. But in Customization Manager it can be a problem, so lets check first:
OK, now we have a BQL type, lets update exiting PXSearchable on NoteID Field:
Now we can publish customization and use full-text search feature as we wish.
If you want to search field that is related to the different DAC, you can use PXDBScalar, so sub-select required fields to the current DAC. Please note, that this can affect performance of the product.
In the end i want to describe you some additional stuff that you can use with Researchable:
- Line1Format/Line1Fields + Line2Format/Line2Fields – are designed to define the way, how system will show search results. You can redefine it and see how system change the result.
- NumberFields – If a field is a number with a prefix like CT00000040 then searching for 0040 can be a problem. All fields that are list here will get special treatment and will be indexed both with prefix and without one – CT00000040, 00000040
- SelectDocumentUser – Select<> construction that will select the User of the document. If this select is specified then only those records/documents are shown that were either created by the current user or current user matches the User of the document. The company tree hierarchy is not traversed. Ex. Use this setting to filter Expense claims, Timecards, etc.
- WhereConstraint – Constraint that when set controls whether the given instance of a DAC is searchable or not. Ex: Contact DAC is used to represent different types or records including lead which is searchable where as account property is not.
- MatchWithJoin – When a MatchWith Type is used. Join has to be specified for the Entity containing the GroupMask column. Ex. When checking the ARInvoice a join to Customer must be provided. If Customer is not accessible, than invoice should be not accessible ether.
- SelectForFastIndexing – When specified this select is used for Mass-Process index rebuild. Search may include additional joined tables so that if a searchable fields can retrieved in one select and avoid the lazy-loading for each and every row through selector.
Code from this example:
Have a nice development!
Hi Sergey, thanks for the direction. I tried to add a custom field in SOLine, but the search doesn’t work. Here is my code. Can you take a look and let me know what’s wrong? Thanks!
namespace PX.Objects.SO
{
public class SOLineExt : PXCacheExtension
{
#region UsrTraceNo
[PXDBString(20)]
[PXUIField(DisplayName=”Trace #”)]
public virtual string UsrTraceNo { get; set; }
public abstract class usrTraceNo : PX.Data.BQL.BqlString.Field { }
#endregion
}
[PXNonInstantiatedExtension]
public class SO_SOLine_ExistingColumn : PXCacheExtension
{
#region NoteID
[PXSearchable(
SM.SearchCategory.SO,
“{0} {1} – {2}”,
new Type[] { typeof(SOLine.orderType), typeof(SOLine.orderNbr), typeof(SOLine.lineNbr) },
new Type[] { typeof(SOLine.branchID), typeof(SOLine.inventoryID), typeof(SOLineExt.usrTraceNo) },
NumberFields = new Type[] { typeof(SOLine.orderNbr) },
Line1Format = “{0}”, Line1Fields = new Type[] { typeof(SOLine.tranDesc) },
Line2Format = “{0}”, Line2Fields = new Type[] { typeof(SOLine.tranDesc) }
)]
[PXNote()]
public Guid? NoteID { get; set; }
#endregion
}
}
Have you tried to rebuild an index after the publication of customization?
Please note that the search is done by a separate table, and the content needs to be updated after you change the attribute.
Yeah, thats true
Kevin,
I need to see your code to answer this question properly. Most probably something goes wrong with attributes definition or custom field.
Contact me directly our our support and we can help you with code review!
Hi Sergey, thanks for your article that pointed the direction, but i have tried seems not working for me, i added the customized type to fields part, but can not search with it. Then i cleared the whole fields part, it still can search by its old existing fileds. seems i can not affect it at all.