0

Good morning,

I have customized two fields in the first customized project of the project screen. apart in another two customized project a pxselector is being made to the UsrBaseIndex field passing the "PMAddressExt.usrCounty" field as a parameter, but I notice that it does not show information, it could indicate that I am doing it wrong.

Attached image for better understanding.

Thanks in advance.

project 1

namespace PX.Objects.PM
{
    public class PMAddressExt : PXCacheExtension<PX.Objects.PM.PMAddress>
    {
        #region UsrGeocode
                                                                        [PXDBString(30)]
        [PXUIField(DisplayName="Geo code")]

        public virtual string UsrGeocode { get; set; }
        public abstract class usrGeocode : PX.Data.BQL.BqlString.Field<usrGeocode> { }
        #endregion

        #region UsrCounty

[PXDBInt]
        [PXUIField(DisplayName="County")]

[PXSelector(
        typeof(PESKCounty.countyID),
        typeof(PESKCounty.countyCD),
        typeof(PESKCounty.countyName),
        DescriptionField = typeof(PESKCounty.countyName),
        SubstituteKey = typeof(PESKCounty.countyCD))]

        [PXRestrictor(typeof(Where<PESKCounty.stateID, Equal<Current<PMSiteAddress.state>>>), "", typeof(PESKCounty.stateID))]
        public virtual int? UsrCounty { get; set; }
        public abstract class usrCounty : PX.Data.BQL.BqlInt.Field<usrCounty> { }
        #endregion
    }
}

project 2

namespace PX.Objects.CT
{
    public class ContractExt : PXCacheExtension<PX.Objects.CT.Contract>
    {
        #region UsrSPriceIndex
                        [PXDBBool]
        [PXUIField(DisplayName = "Subject to Price Index")]

        public virtual bool? UsrSPriceIndex { get; set; }
        public abstract class usrSPriceIndex : PX.Data.BQL.BqlBool.Field<usrSPriceIndex> { }
        #endregion

        #region UsrPRCNumber
                
        [PXDBInt]
        [PXUIField(DisplayName = "PRC Number")]
        [PXSelector(typeof(Search2<PESKPRC.recordID,
                InnerJoin<PESKCountyPriceIndexDetail, On<PESKCountyPriceIndexDetail.recordID, Equal<PESKPRC.recordID>>>,
                Where<PESKPRC.availabletoAll, Equal<True>,
                     And<PESKPRC.active, Equal<True>
                         //And<PESKCountyPriceIndexDetail.countyID, Equal<Current<PMAddressExt.usrCounty>>>
                         >>>),
                typeof(PESKPRC.prcnbr),
                typeof(PESKCountyPriceIndexDetail.pRCPriceIndexCD),
                SubstituteKey = typeof(PESKPRC.prcnbr)
                )]

        public virtual int? UsrPRCNumber { get; set; }
        public abstract class usrPRCNumber : PX.Data.BQL.BqlInt.Field<usrPRCNumber> { }
        #endregion

        #region UsrBaseIndex

        [PXDBInt]
        [PXUIField(DisplayName = "Base Index")]
        [PXSelector(typeof(Search<PESKViewBaseIndex.priceIndexID,
            Where<PESKViewBaseIndex.recordID, IsNull
                ,And<PESKViewBaseIndex.countyID, Equal<Current<PMAddressExt.usrCounty>>,
                    Or<PESKViewBaseIndex.countyID,IsNull>
                    >
                >>),
        typeof(PESKViewBaseIndex.pRCPriceIndexCD),
        SubstituteKey = typeof(PESKViewBaseIndex.pRCPriceIndexCD),ValidateValue =false)]
        public virtual int? UsrBaseIndex { get; set; }
        public abstract class usrBaseIndex : PX.Data.BQL.BqlInt.Field<usrBaseIndex> { }
        #endregion

        #region UsrPCNumber
                        [PXDBString(60)]
        [PXUIField(DisplayName = "PCNumber")]

        public virtual string UsrPCNumber { get; set; }
        public abstract class usrPCNumber : PX.Data.BQL.BqlString.Field<usrPCNumber> { }
        #endregion
    }
}

enter image description here

Marco A.
  • 27
  • 5
  • Since you are using the first project in the second, it means that you have it referenced. So you don't need to copy the first field in the second, as you have access to it's value. Has your 'County' field set CommitChanges = "True"? Has your 'Base Index' field set AutoRefresh = "True" (this is to reload the values in selector based on the new value of the County field)? Can you check the query with a SQL Profiler, to see what the selector is looking for and if the query is good and has results when executed directly in the database? – Lucian Dec 24 '20 at 12:18

1 Answers1

1

You should be adding a new extension for PMAdress in the second project then add a new field in that extension for getting the value of the County from the first project.

public sealed class PMAddressCountyExt : PXCacheExtension<PMAddress>
    {
        public static bool IsActive() { return true; }
        #region UsrGetCounty
        [PXDBInt]
        [BaseIndexSelectorAttribute]
        public int? UsrGetCounty { get; set; }
        public abstract class usrGetCounty : BqlInt.Field<usrGetCounty> { }
        #endregion
    }
    public sealed class BaseIndexSelectorAttribute : AcctSubAttribute, IPXFieldSelectingSubscriber
    {
        public void FieldSelecting(PXCache sender, PXFieldSelectingEventArgs e)
        {
            if (e.Row is PMAddress)
            {
                sender.SetValue(e.Row, "UsrGetCounty", sender.GetValue(e.Row, "UsrCounty"));
            }
        }
        public override void RowSelecting(PXCache sender, PXRowSelectingEventArgs e)
        {
            base.RowSelecting(sender, e);
            if (e.Row is PMAddress)
            {
                sender.SetValue(e.Row, "UsrGetCounty", sender.GetValue(e.Row, "UsrCounty"));
            }
        }
    }  

Change the search type for the selector of the UsrBaseIndex field in the ContarctExt extension like this:

typeof(Search<PESKViewBaseIndex.priceIndexID, Where<PESKViewBaseIndex.recordID, IsNull, And<PESKViewBaseIndex.countyID, Equal<Current<PMAddressCountyExt.usrGetCounty>>, Or<PESKViewBaseIndex.countyID, IsNull>>>>)
Vardan Vardanyan
  • 649
  • 5
  • 12