2017-01-06 101 views
0

我修改了LeadExtension以添加ownerid,以便銷售人員在電子郵件地址的全局搜索期間知道誰是潛在客戶。但是,我只能讓它報告一個數字而不是描述的ID。有一個簡單的方法來修改以下使用typeof報告的員工,而不是ID號的實際名稱(Contact.ownerID):如何在通用搜索中檢索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; } 
    } 

回答

1

要顯示的員工,而不是ID號的實際名稱,你還應該包括TM.PXOwnerSelectorAttribute.EPEmployee.acctName字段。由於關聯的Employee只能通過OwnerID字段訪問,因此Contact.ownerID也必須存在於Line1Fields數組之前的TM.PXOwnerSelectorAttribute.EPEmployee.acctName字段中。並且不要忘記將Line1Format屬性更改爲{0}{1}{2}{4},否則它仍將顯示ID號。

下面是供您參考最終擴展代碼:

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; } 
} 
+0

偉大工程的感謝! – AcumaticaGuy