Skip to main content
Solved

Can't change combine DiscriptionField of Selector Stock Item

  • 6 November 2022
  • 7 replies
  • 145 views

Forum|alt.badge.img

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

Best answer by Fernando Amadoz

@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

View original
Did this topic help you find an answer to your question?

7 replies

Fernando Amadoz
Jr Varsity I
Forum|alt.badge.img+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.


Forum|alt.badge.img
  • Author
  • Jr Varsity II
  • 85 replies
  • November 14, 2022

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)


Fernando Amadoz
Jr Varsity I
Forum|alt.badge.img+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


Fernando Amadoz
Jr Varsity I
Forum|alt.badge.img+2

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


Forum|alt.badge.img
  • Author
  • Jr Varsity II
  • 85 replies
  • November 17, 2022

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?


Fernando Amadoz
Jr Varsity I
Forum|alt.badge.img+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>

 


Forum|alt.badge.img
  • Author
  • Jr Varsity II
  • 85 replies
  • November 19, 2022

Hi @Fernando Amadoz,

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

 

 


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings