Reputation: 41
I modified LeadExtension to add the ownerid so salespeople knows who's leads are theirs during universal search of email address. However I could only get it to report the ID which is a number and not the description. Is there an easy way to modify the following to report the actual name of the employee instead of ID number using typeof(Contact.ownerID):
//modify leads search to report ownerid
public class LeadExtension : PXCacheExtension<Contact>
{
[PXRemoveBaseAttribute(typeof(PXSearchableAttribute))]
[PXMergeAttributes(Method = MergeMethod.Append)]
[PXSearchable(SearchCategory.CR, "{0} {1}", new Type[] { typeof(Contact.contactType), typeof(Contact.displayName) },
new Type[] { typeof(Contact.eMail), typeof(Contact.phone1), typeof(Contact.phone2), typeof(Contact.phone3), typeof(Contact.webSite) },
WhereConstraint = typeof(Where<Current<Contact.contactType>, NotEqual<ContactTypesAttribute.bAccountProperty>, And<Current<Contact.contactType>, NotEqual<ContactTypesAttribute.employee>>>),
Line1Format = "{0}{1}{2}{3}", Line1Fields = new Type[] { typeof(Contact.salutation), typeof(Contact.phone1), typeof(Contact.eMail), typeof(Contact.ownerID) },
Line2Format = "{1}{2}{3}", Line2Fields = new Type[] { typeof(Contact.defAddressID), typeof(Address.displayName), typeof(Address.city), typeof(Address.state), typeof(Address.countryID) }
)]
public Guid? NoteID { get; set; }
}
Upvotes: 0
Views: 219
Reputation: 6778
To show the actual name of the employee instead of ID number, you should also include TM.PXOwnerSelectorAttribute.EPEmployee.acctName
field. Since associated Employee is accessible only though the OwnerID field, Contact.ownerID must also present in the Line1Fields array prior to TM.PXOwnerSelectorAttribute.EPEmployee.acctName
field. And don't forget to change the Line1Format property to {0}{1}{2}{4}
, otherwise it will still show ID number.
Below is the final extension code for your reference:
public class LeadExtension : PXCacheExtension<Contact>
{
[PXRemoveBaseAttribute(typeof(PXSearchableAttribute))]
[PXMergeAttributes(Method = MergeMethod.Append)]
[PXSearchable(SearchCategory.CR, "{0} {1}", new Type[] { typeof(Contact.contactType), typeof(Contact.displayName) },
new Type[] { typeof(Contact.eMail), typeof(Contact.phone1), typeof(Contact.phone2), typeof(Contact.phone3), typeof(Contact.webSite) },
WhereConstraint = typeof(Where<Current<Contact.contactType>, NotEqual<ContactTypesAttribute.bAccountProperty>, And<Current<Contact.contactType>, NotEqual<ContactTypesAttribute.employee>>>),
Line1Format = "{0}{1}{2}{4}",
Line1Fields = new Type[] { typeof(Contact.salutation), typeof(Contact.phone1), typeof(Contact.eMail),
typeof(Contact.ownerID), typeof(TM.PXOwnerSelectorAttribute.EPEmployee.acctName) },
Line2Format = "{1}{2}{3}",
Line2Fields = new Type[] { typeof(Contact.defAddressID), typeof(Address.displayName), typeof(Address.city), typeof(Address.state), typeof(Address.countryID) }
)]
public Guid? NoteID { get; set; }
}
Upvotes: 1