Skip to main content
Answer

How to bound a multi-part Identifier based on matching condition?

  • February 17, 2022
  • 5 replies
  • 719 views

Forum|alt.badge.img+1

Hi guys How can I bond multi-part identifier .I need to get data from magnifier based on Matching condition

I tried PXRestrictor but couldn’t work out

Could you please help….

Thanks in advance.

 #region FIELD1
[PXDBString(30, IsUnicode = true)]
[PXUIField(DisplayName = "Template ID", Required = true)]
[PXDefault]
[PXSelector(typeof(Search<DAC.FIELD1>),
typeof(DAC1.FIELD1),
typeof(DAC1.FIELD2),
typeof(DAC1.FIELD3),
SubstituteKey = typeof(DAC1.FIELD1),
DescriptionField = typeof(DAC1.FIELD2))]
[PXRestrictor(typeof(Where<DAC2.FIELD1, NotEqual<Current<DAC1.FIELD1>>,
Or<DAC2.FIELD1, IsNull>>), SSS.SSP.Helper.Messages.Getmes)]

 

Best answer by MoulaliShaik79

Hi @ShahidaValiSyed04 

Please check the below code, hope it works for you.

 [PXSelector(typeof(Search<SSPAgreeTemplate.templateCode, 
            Where<SSPAgreeTemplate.validFor, 
                Equal<Current<agreeType>>, Or<Current<agreeType>,IsNull>>>),
               typeof(SSPAgreeTemplate.templateCode),
          typeof(SSPAgreeTemplate.descr),
          typeof(SSPAgreeTemplate.validFor),
          SubstituteKey = typeof(SSPAgreeTemplate.templateCode),
          DescriptionField = typeof(SSPAgreeTemplate.descr))]

 

 

Note:  make AutoRefresh="true" to the TemplateCode field in Aspx file.

 

 

Thanks,

Moulali Shaik.

5 replies

jinin
Pro I
Forum|alt.badge.img+11
  • Pro I
  • February 17, 2022

Hi @ShahidaValiSyed04 

You are using different DAC associations with Selector and Restrictor. Can you please recheck the condition once? 

 #region FIELD1
        [PXDBString(30, IsUnicode = true)]
        [PXUIField(DisplayName = "Template ID", Required = true)]
        [PXDefault]

        [PXSelector(typeof(Search<DAC1.FIELD1>),
          typeof(DAC1.FIELD1),
          typeof(DAC1.FIELD2),
          typeof(DAC1.FIELD3),
          SubstituteKey = typeof(DAC1.FIELD1),
          DescriptionField = typeof(DAC1.FIELD2))]

        [PXRestrictor(typeof(Where<DAC2.FIELD1, NotEqual<Current<DAC1.FIELD1>>,
    Or<DAC2.FIELD1, IsNull>>), SSS.SSP.Helper.Messages.Getmes)]


Refer to the below sample code.
#region SiteID
        [PXDBInt()]
        [PXUIField(DisplayName = "Warehouse")]
        [PXSelector(typeof(INSite.siteID),
                    SubstituteKey = typeof(INSite.siteCD),
                    DescriptionField = typeof(INSite.descr))]
        [PXRestrictor(typeof(Where<INSite.siteID, NotEqual<SiteAttribute.transitSiteID>, And<INSite.active, Equal<True>>>),
                             PX.Objects.IN.Messages.TransitSiteIsNotAvailable)]

        [PXDefault()]
        public override int? SiteID { get; set; }
        public abstract class siteID : PX.Data.BQL.BqlInt.Field<siteID> { }
        #endregion


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • February 17, 2022

@ShahidaValiSyed04 For more understanding about the error and code, please share the real DAC field.

If not possible, please refer to the above example given by Jini


Forum|alt.badge.img+1

Hi @Naveen B Could you please checkout my code

#region TemplateCode
[PXDBString(30, IsUnicode = true)]
[PXUIField(DisplayName = "Template ID", Required = true)]
[PXDefault]
[PXSelector(typeof(Search<SSPAgreeTemplate.templateCode>),
typeof(SSPAgreeTemplate.templateCode),
typeof(SSPAgreeTemplate.descr),
typeof(SSPAgreeTemplate.validFor),
SubstituteKey = typeof(SSPAgreeTemplate.templateCode),
DescriptionField = typeof(SSPAgreeTemplate.descr))]
[PXRestrictor(typeof(Where<SSPAgreeTemplate.validFor, NotEqual<Current<SSPAgreement.agreeType>>,
Or<SSPAgreeTemplate.validFor, IsNull>>), SSS.SSP.Helper.Messages.templateId)]
public virtual string TemplateCode { get; set; }
public abstract class templateCode : PX.Data.BQL.BqlString.Field<templateCode> { }
#endregion

Error will be Like

The multi-part identifier "SSPAgreement.AgreeType" could not be bound.


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • February 17, 2022

Hi @ShahidaValiSyed04  Since you wanted restrict the based on the dynamic value i.e. AgreeType.

You might need to join the both tables (DAC 1 and DAC 2). Can you do join and verify.


Forum|alt.badge.img+1
  • Semi-Pro II
  • Answer
  • February 18, 2022

Hi @ShahidaValiSyed04 

Please check the below code, hope it works for you.

 [PXSelector(typeof(Search<SSPAgreeTemplate.templateCode, 
            Where<SSPAgreeTemplate.validFor, 
                Equal<Current<agreeType>>, Or<Current<agreeType>,IsNull>>>),
               typeof(SSPAgreeTemplate.templateCode),
          typeof(SSPAgreeTemplate.descr),
          typeof(SSPAgreeTemplate.validFor),
          SubstituteKey = typeof(SSPAgreeTemplate.templateCode),
          DescriptionField = typeof(SSPAgreeTemplate.descr))]

 

 

Note:  make AutoRefresh="true" to the TemplateCode field in Aspx file.

 

 

Thanks,

Moulali Shaik.