'Is it possible change ARInvoice Project/Conract search field description?
On the Acumatica Invoice page in the Project/Conract search field by default search result show in format: "ProjectID - ProjectDescription". May be somebody know - Can we change this to "ProjectID - CustomerName" screenshot
Solution 1:[1]
The ProjectID field uses the attribute ActiveProjectOrContractBaseAttribute. So I created a an extension which assigns the Description field. Override the default attribute in ProjectID field with this custom attribute. See if this achieves your goal.
public class ActiveProjectOrContractBaseAttributeExtended : AcctSubAttribute, IPXFieldVerifyingSubscriber
{
protected Type customerField;
public ActiveProjectOrContractBaseAttributeExtended() : this(null) { }
public ActiveProjectOrContractBaseAttributeExtended(Type customerField)
{
this.customerField = customerField;
PXDimensionSelectorAttribute select;
if (PXAccess.FeatureInstalled<FeaturesSet.projectModule>() && customerField != null)
{
List<Type> command = new List<Type>();
command.AddRange(new[] {
typeof(Search2<,,>),
typeof(PMProject.contractID),
typeof(LeftJoin<,>),
typeof(Customer),
typeof(On<,>),
typeof(Customer.bAccountID),
typeof(Equal<>),
typeof(PMProject.customerID),
});
command.AddRange(
new[]
{
typeof(Where<,,>),
typeof (PMProject.nonProject),
typeof (Equal<>),
typeof (True),
typeof (Or2<,>),
typeof (Where2<,>),
typeof (Where<,,>),
typeof (PMProject.customerID),
typeof (Equal<>),
typeof (Current<>),
customerField,
typeof (And<,,>),
typeof (PMProject.restrictProjectSelect),
typeof (Equal<>),
typeof (PMRestrictOption.customerProjects),
typeof (Or<,,>),
typeof (PMProject.restrictProjectSelect),
typeof (Equal<>),
typeof (PMRestrictOption.allProjects),
typeof (Or<,>),
typeof(PMProject.baseType),
typeof(Equal<PX.Objects.CT.CTPRType.contract>),
typeof (Or<,>),
typeof (Current<>),
customerField,
typeof (IsNull),
typeof (And2<,>),
typeof (Match<Current<AccessInfo.userName>>),
typeof (Or<,>),
typeof (PMProject.nonProject),
typeof (Equal<>),
typeof (True)
});
select = new PXDimensionSelectorAttribute(ProjectAttribute.DimensionName,
BqlCommand.Compose(command.ToArray())
, typeof(PMProject.contractCD), typeof(PMProject.contractCD), typeof(PMProject.description),
typeof(PMProject.status), typeof(PMProject.customerID), typeof(Customer.acctName), typeof(PMProject.curyID));
}
else
{
select = new PXDimensionSelectorAttribute(ProjectAttribute.DimensionName,
typeof(Search2<PMProject.contractID,
LeftJoin<Customer, On<Customer.bAccountID, Equal<PMProject.customerID>>>,
Where<PMProject.nonProject, Equal<True>, Or<Match<Current<AccessInfo.userName>>>>>)
, typeof(PMProject.contractCD), typeof(PMProject.contractCD), typeof(PMProject.description),
typeof(PMProject.status), typeof(PMProject.customerID), typeof(Customer.acctName), typeof(PMProject.curyID)
);
}
select.DescriptionField = typeof(Customer.acctName);
select.ValidComboRequired = true;
select.CacheGlobal = true;
_Attributes.Add(select);
_SelAttrIndex = _Attributes.Count - 1;
Filterable = true;
DescriptionField = typeof(Customer.acctName);
}
public virtual void FieldVerifying(PXCache sender, PXFieldVerifyingEventArgs e)
{
PMProject project = PXSelect<PMProject>.Search<PMProject.contractID>(sender.Graph, e.NewValue);
if (customerField != null && project != null && project.NonProject != true)
{
int? customerID = (int?)sender.GetValue(e.Row, customerField.Name);
if (customerID != project.CustomerID)
{
sender.RaiseExceptionHandling(FieldName, e.Row, e.NewValue,
new PXSetPropertyException(Warnings.ProjectCustomerDontMatchTheDocument, PXErrorLevel.Warning));
}
}
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Chris H |