Solved

Can't change combine DiscriptionField of Selector Stock Item

  • 6 November 2022
  • 7 replies
  • 117 views

Userlevel 3
Badge

Hi,

I have a custom field named UserSearchName on Stock Item and I want to use this field to combine DescriptionField of seletor Inventory.

I updated the attribute DescriptionField of InventoryID to: PX.Objects.IN.InventoryItem+userSearchName

But I got the error regarding syntax I think, I have no idea what wrong here.

 

Do you have any experience about this one?

Any idea would be appreciate.

Thanks

icon

Best answer by Fernando Amadoz 14 November 2022, 14:47

View original

7 replies

Userlevel 5
Badge +2

@mrthanhkhoi I don’t quite follow what you are trying to accomplish.

Are you looking to concatenate a new Usr field with the InventoryItem Description so that you can show the concatenation result in the DescriptionField of the PXSelectors?

Try to describe the expected functionality in the final result.

Userlevel 3
Badge

Hi @Fernando Amadoz, sorry for the ambiguous describe.

When I try to search Inventory in Sales Orders screen, the display name of selector InventoryID is combine between InventoryItem and description fields.

The goal is: display name when searching should be combined from InventoryItem and a new field (called: userSearchName)

Userlevel 5
Badge +2

@mrthanhkhoi 

This is the original field definition

		#region InventoryID
public abstract class inventoryID : PX.Data.BQL.BqlInt.Field<inventoryID>
{
public class InventoryBaseUnitRule :
InventoryItem.baseUnit.PreventEditIfExists<
Select<SOLine,
Where<inventoryID, Equal<Current<InventoryItem.inventoryID>>,
And<lineType, In3<SOLineType.inventory, SOLineType.nonInventory>,
And<completed, NotEqual<True>>>>>>
{ }
}
protected Int32? _InventoryID;
[SOLineInventoryItem(Filterable=true)]
[PXDefault()]
[PXForeignReference(typeof(FK.InventoryItem))]
public virtual Int32? InventoryID
{
get
{
return this._InventoryID;
}
set
{
this._InventoryID = value;
}
}
#endregion

The attribute [SOLineInventoryItem] includes the PXSelector definition, which is the one that manages the SubstituteKey and DescriptionField properties.

You could redefine that attribute in the following way:

  [PXDBInt()]
[PXUIField(DisplayName = "Inventory ID", Visibility = PXUIVisibility.Visible)]
[PXRestrictor(typeof(Where<InventoryItem.itemStatus, NotEqual<InventoryItemStatus.noSales>,
Or<Where2<Where<Current<SOOrderType.behavior>, Equal<SOOrderTypeConstants.salesOrder>,
And<Current<SOOrderType.iNDocType>, Equal<INTranType.transfer>>>,
Or<Current<SOLine.operation>, Equal<SOOperation.receipt>>>>>), PX.Objects.IN.Messages.ItemCannotSale)]
public class SOLineTESTInventoryItemAttribute : CrossItemAttribute
{
public SOLineTESTInventoryItemAttribute()
: base(typeof(Search<InventoryItem.inventoryID, Where<Match<Current<AccessInfo.userName>>>>), typeof(InventoryItem.inventoryCD), typeof(InventoryItemExt.usrCustomField), INPrimaryAlternateType.CPN)
{
}
}

Notice that the second to last parameter of the constructor implements InventoryItemExt.usrCustomField, instead of the original InventoryItem.descr

Then the field can be redefined in the SOOrderEntry graph via CacheAttached in order to use the new Attribute, instead of the original one:

  public class SOOrderEntry_Extension : PXGraphExtension<PX.Objects.SO.SOOrderEntry>
{
[SOLineTESTInventoryItem(Filterable=true)]
[PXDefault()]
public void SOLine_InventoryID_CacheAttached(PXCache sender) { }
}

Result

 

Attached is a customization project example for additional references

Userlevel 5
Badge +2

@mrthanhkhoi were you able to implement the suggested approach from my last post?

Userlevel 3
Badge

Hi @Fernando Amadoz,

Thank you very much for your suggestion. I could change the combination of display name now.

In addition, My boss want to search by following fields:Search Name, InventoryID, English Name.

It means: if we input Energiner, it should show V-IL-00701 (same as image above) because its description contains “Energiner

but I don’t know we could do it or not.

Do you have any idea?

Userlevel 5
Badge +2

@mrthanhkhoi as fas as I know, when the search is done from the field directly, only 2 fields can be used: the selector’s SubstituteKey and DescriptionField

However, you could try to use the FastFilterFields property in order to filter by additional columns, using the selector’s smartpanel.

Example:

   <px:PXSegmentMask ID="edItemClassID" runat="server" DataField="ItemClassCD">
             <GridProperties FastFilterFields="Description" />
    </px:PXSegmentMask>

 

Userlevel 3
Badge

Hi @Fernando Amadoz,

I think it is the only one option we could choose. Thank you very much for your help.

 

 

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved