Krunal
Krunal

Reputation: 1188

Inventory Attribute column in Kit Assembly

I need to have an InventoryItem Attribute as a column in Kit Assembly screen (IN307000) on Stock Components grid.

I am able to get the Attribute column on grid but not its value. Can anyone please suggest what is missing in below code.

Here is the code I have written-

public class PXAddAtttributeColumns : CRAttributesFieldAttribute
{
	string[] _names;

	public PXAddAtttributeColumns(string[] names, Type classID, Type noteID)
		: base(classID, noteID)
	{
		_names = names;
	}

	public override void CacheAttached(PXCache sender)
	{
		this._IsActive = true;
		base.CacheAttached(sender);
	}

	protected override void AttributeFieldSelecting(PXCache sender, PXFieldSelectingEventArgs e, PXFieldState state, string attributeName, int idx)
	{
		if (_names.Any(attributeName.Equals))
		{
			state.DisplayName = (!String.IsNullOrEmpty(state.DisplayName)) ? (state.DisplayName.Replace("$Attributes$-", "")) : attributeName;
			state.Visible = true;
			state.Visibility = PXUIVisibility.Dynamic;
		}

		base.AttributeFieldSelecting(sender, e, state, attributeName, idx);
	}
}

public class INComponentTranExtension : PXCacheExtension<INComponentTran>
{
	public abstract class itemAttributes : IBqlField { }

	[PXAddAtttributeColumns(new[] { "Attrib101" }, typeof(InventoryItem.itemClassID), typeof(INComponentTran.noteID))]
	public virtual string[] ItemAttributes { get; set; }
}

Note: I am using Acumatica ver 6.10.0956

enter image description here

Upvotes: 1

Views: 222

Answers (1)

DChhapgar
DChhapgar

Reputation: 2340

You need to declare ItemAttributes field with PXAddAtttributeColumns attribute in Cache Extension for InventoryItem DAC.

The attributes are related to InventoryItem entity hence you need to reference NoteID and ClassID of InventoryItem DAC. Attribute information will be fetched as long as View tied with Grid works with InventoryItem DAC (in your case, Data View is Components and has inner join with InventoryItem DAC).

public class InventoryItemDemoPXExt : PXCacheExtension<InventoryItem>
{
    public abstract class itemAttributes : IBqlField { }

    [PXAddAtttributeColumns(new[] { "COLOR", "CONFIGURAB", "PIXELSIZE", "WIDEANGLE" },
                                    typeof(InventoryItem.itemClassID),
                                    typeof(InventoryItem.noteID))]
    public virtual string[] ItemAttributes { get; set; }
}

Make sure to specify AutoGenerateColumns="AppendDynamic" for PXGrid control for Framework to dynamically generate Attribute columns.

Fields will show up as below:

enter image description here Note: This example is applicable to 6.1 series onward.

Upvotes: 2

Related Questions