I am attempting to add the SQFTINBOX stock item attribute to the Sales Order Grid.
I have declared a class PXAddAttributeColumns as below:
public class PXAddAtttributeColumns : CRAttributesFieldAttribute
{
stringr] _names;
bool _IsForSelector;
public PXAddAtttributeColumns(stringr] names, Type entityType, Type entityIDField, Type classIDField, bool IsForSelector = true)
: base(entityType, entityIDField, classIDField)
{
_names = names;
_IsForSelector = IsForSelector;
}
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))
{
//Out-of-box DisplayName is prefixed with "$Attributes$-" - if you need to take that off.
state.DisplayName = (!String.IsNullOrEmpty(state.DisplayName)) ? (state.DisplayName.Replace("$Attributes$-", "")) : attributeName;
state.Visible = true;
//Requires AutoGenerateColumns="AppendDynamic" for PXGrid Control for dynamic Attribute columns creation
state.Visibility = (_IsForSelector) ? PXUIVisibility.SelectorVisible : PXUIVisibility.Dynamic;
}
base.AttributeFieldSelecting(sender, e, state, attributeName, idx);
}
public override void CommandPreparing(PXCache sender, PXCommandPreparingEventArgs e)
{
base.CommandPreparing(sender, e);
if (e.BqlTable == null && aggregateAttributes && sender.GetItemType().IsDefined(typeof(PXProjectionAttribute), true))
{
e.BqlTable = _BqlTable;
}
}
}
Add Extended SO Line as below:
public class SOLineExtension : PXCacheExtension<SOLine>
{
public abstract class itemAttributes : IBqlField { }
PXAddAtttributeColumns(new(] {"SQFTINBOX"},
typeof(CSAnswerType.inventoryAnswerType),
typeof(SOLine.inventoryID),
typeof(InventoryItem.itemClassID), false)]
public virtual stringr] ItemAttributes { get; set; }
}
I recieve an error message during validation as shown below:
Validation started.
Copying the website c:\deployment\sites\#####\Customization\#####\siterootValidation\siterootWebsite
Patching the file c:\deployment\sites\#####\Customization\#####\siterootValidation\siterootWebsite\App_RuntimeCode\PXAddAttributeColumns.cs
Patching the file c:\deployment\sites\#####\Customization\#####\siterootValidation\siterootWebsite\App_RuntimeCode\SOLine.cs
Done
Validating Binary Files
Validating Sql Scripts
Validating the website c:\deployment\sites\#####\Customization\#####\siterootValidation\siterootWebsite
IIS APPPOOL\#####
Building directory '\WebSiteValidationDomain\App_RuntimeCode\'.
\App_RuntimeCode\PXAddAttributeColumns.cs(6): error CS0246: The type or namespace name 'CRAttributesFieldAttribute' could not be found (are you missing a using directive or an assembly reference?)
\App_RuntimeCode\PXAddAttributeColumns.cs(18): error CS0115: 'PXAddAtttributeColumns.CacheAttached(PXCache)': no suitable method found to override
\App_RuntimeCode\PXAddAttributeColumns.cs(24): error CS0115: 'PXAddAtttributeColumns.AttributeFieldSelecting(PXCache, PXFieldSelectingEventArgs, PXFieldState, string, int)': no suitable method found to override
\App_RuntimeCode\PXAddAttributeColumns.cs(37): error CS0115: 'PXAddAtttributeColumns.CommandPreparing(PXCache, PXCommandPreparingEventArgs)': no suitable method found to override
\App_RuntimeCode\SOLine.cs(30): error CS0246: The type or namespace name 'PXAddAtttributeColumnsAttribute' could not be found (are you missing a using directive or an assembly reference?)
\App_RuntimeCode\SOLine.cs(30): error CS0246: The type or namespace name 'PXAddAtttributeColumns' could not be found (are you missing a using directive or an assembly reference?)
\App_RuntimeCode\SOLine.cs(31): error CS0246: The type or namespace name 'CSAnswerType' could not be found (are you missing a using directive or an assembly reference?)
\App_RuntimeCode\PXAddAttributeColumns.cs(6): error CS0246: The type or namespace name 'CRAttributesFieldAttribute' could not be found (are you missing a using directive or an assembly reference?)
Compiler time, in seconds: 3.4108918
Validation failed.
Does anyone know why this might be failing validation or where I am going wrong?
Thank you