Skip to main content
Solved

Dropdown list in Customer Location screen.

  • December 20, 2022
  • 6 replies
  • 468 views

Forum|alt.badge.img

Hi,

I have added the below dropdown in the customer location screen(AR303020) and the dropdown should have the sales Rep names from Salesperson screen.


drop down should contain the below list.

DAC name is SalesPerson, ​​​​​​

 

 

can someone help how to write the code for this.

 

Best answer by aaghaei

@sujithra

Dropdowns are suggested when you have a fixed number of values that don’t change. When you have a dynamic list you will need to use a selector control as @Fernando Amadoz had mentioned. Step by step you will need to:

  • Add a Custom Int Field to the Location DAC
<Table TableName="Location">
	<Column TableName="Location" ColumnName="UsrSalesPersonID" ColumnType="int" AllowNull="True" DecimalPrecision="0" DecimalLength="0" IsNewColumn="True" IsUnicode="True" />
</Table>
  • Define the field properties. Make sure to extend “<PX.Objects.CR.Location>” not others.
using PX.Data;
using PX.Objects.AR;
using PX.Objects.CR;

namespace PX.Objects.CR
{
    public sealed class MyCRLocationExt : PXCacheExtension<PX.Objects.CR.Location>
    {
        public static bool IsActive() => true;

		#region UsrSalesPersonID
		public abstract class usrSalesPersonID : PX.Data.BQL.BqlInt.Field<usrSalesPersonID> { }
		[SalesPerson(DisplayName = "Sales Rep.", Required = true, Enabled = true, Visible = true)]
		[PXDefault(PersistingCheck = PXPersistingCheck.Null)]

		public int? UsrSalesPersonID { get; set; }
		#endregion
	}
}
  • Publish your customization
  • Add the created field to your screen AR303020 where you want it
  <px:PXSegmentMask runat="server" ID="CstPXSegmentMask1" DataField="UsrSalesPersonID" />
  • Publish your customization
  • you will get the below result

 

View original
Did this topic help you find an answer to your question?

6 replies

Fernando Amadoz
Jr Varsity I
Forum|alt.badge.img+2

@sujithra 

Your DAC extension field should look something like this:

		#region UsrSalesPersonID
		public abstract class usrSalesPersonID : PX.Data.BQL.BqlInt.Field<usrSalesPersonID> { }
		protected Int32? _UsrSalesPersonID;
		[SalesPerson(DescriptionField = typeof(SalesPerson.descr))]
		public virtual Int32? UsrSalesPersonID
		{
			get
			{
				return this._UsrSalesPersonID;
			}
			set
			{
				this._UsrSalesPersonID = value;
			}
		}
		#endregion

 


aaghaei
Captain II
Forum|alt.badge.img+10
  • Captain II
  • 1198 replies
  • Answer
  • December 20, 2022

@sujithra

Dropdowns are suggested when you have a fixed number of values that don’t change. When you have a dynamic list you will need to use a selector control as @Fernando Amadoz had mentioned. Step by step you will need to:

  • Add a Custom Int Field to the Location DAC
<Table TableName="Location">
	<Column TableName="Location" ColumnName="UsrSalesPersonID" ColumnType="int" AllowNull="True" DecimalPrecision="0" DecimalLength="0" IsNewColumn="True" IsUnicode="True" />
</Table>
  • Define the field properties. Make sure to extend “<PX.Objects.CR.Location>” not others.
using PX.Data;
using PX.Objects.AR;
using PX.Objects.CR;

namespace PX.Objects.CR
{
    public sealed class MyCRLocationExt : PXCacheExtension<PX.Objects.CR.Location>
    {
        public static bool IsActive() => true;

		#region UsrSalesPersonID
		public abstract class usrSalesPersonID : PX.Data.BQL.BqlInt.Field<usrSalesPersonID> { }
		[SalesPerson(DisplayName = "Sales Rep.", Required = true, Enabled = true, Visible = true)]
		[PXDefault(PersistingCheck = PXPersistingCheck.Null)]

		public int? UsrSalesPersonID { get; set; }
		#endregion
	}
}
  • Publish your customization
  • Add the created field to your screen AR303020 where you want it
  <px:PXSegmentMask runat="server" ID="CstPXSegmentMask1" DataField="UsrSalesPersonID" />
  • Publish your customization
  • you will get the below result

 


Forum|alt.badge.img
  • Author
  • Freshman II
  • 16 replies
  • December 21, 2022

thankyouso much @aaghaei, its working fine.

and i want to add one more column to Customer location Screen.

This is Preferred Tech (same Selector) from the Customers screen (AR303000) and pull the data from Attributes Tab . 

 

I have added the CUstom Int field, added to the screen , DO i need to follow the same? 

Do i need to add the PX.Objects.CS.CSAnswers anywhere? 

#region UsrPreferredTech
     public abstract class UsrPreferredTech : PX.Data.BQL.BqlInt.Field<UsrPreferredTech> { }
    [CSAnswers(DisplayName = "PreferredTech", Required = true, Enabled = true, Visible = true)]
    [PXDefault(PersistingCheck = PXPersistingCheck.Null)]
    public int? UsrPreferredTech { get; set; }
    #endregion

 

kindly correct me if am wrong.


Forum|alt.badge.img
  • Author
  • Freshman II
  • 16 replies
  • December 21, 2022

@aaghaei, am trying to add one more custom field but Now am getting error .

 

 

 

Preview looks lik this.

And my code is,

 

using PX.Data.ReferentialIntegrity.Attributes;
using PX.Data;
using PX.Objects.AP;
using PX.Objects.AR;
using PX.Objects.CA;
using PX.Objects.CR.MassProcess;
using PX.Objects.CR.Workflows;
using PX.Objects.CR;
using PX.Objects.CS;
using PX.Objects.GL;
using PX.Objects.IN;
using PX.Objects.PO;
using PX.Objects.SO;
using PX.Objects.TX;
using PX.Objects;
using System.Collections.Generic;
using System;
using PX.Data.BQL.Fluent;
using PX.Data.BQL;

namespace PX.Objects.CR
{
  public sealed class LocationExt : PXCacheExtension<PX.Objects.CR.Location>
  {
   public static bool IsActive() => true;
    #region UsrPreferredTech
    [PXDBInt]
    [PXUIField(DisplayName="Preferred Tech")]
    public int? UsrPreferredTech { get; set; }
    public abstract class usrPreferredTech : PX.Data.BQL.BqlInt.Field<usrPreferredTech> { }
    #endregion

    #region UsrSalesRep
    public abstract class UsrSalesRep : PX.Data.BQL.BqlInt.Field<UsrSalesRep> { }
    [SalesPerson(DisplayName = "Sales Rep.", Required = true, Enabled = true, Visible = true)]
    [PXDefault(PersistingCheck = PXPersistingCheck.Null)]
    public int? UsrSalesPersonID { get; set; }
    #endregion

    #region UsrAcquisitionDate
    [PXDBDate]
    [PXUIField(DisplayName="Acquisition Date")]
    public DateTime? UsrAcquisitionDate { get; set; }
    public abstract class usrAcquisitionDate : PX.Data.BQL.BqlDateTime.Field<usrAcquisitionDate> { }
    #endregion
  }
}

 

please do the needful.


aaghaei
Captain II
Forum|alt.badge.img+10
  • Captain II
  • 1198 replies
  • December 21, 2022

@sujithra the “Attributes” are a little bit more complicated as they are not created on the “Main Records” in your case customers.
 

I suggest create a new question that other more experienced community members also have a look as usually they don’t look into the posts with lengthy threads and multiple issues/questions. If you like, tag me as well and I will try to have a look this weekend or overnight.

 

Also please provide the info about the Attributes (ID, Name, Type, …) preferably screenshots from “Attributes” screen itself and Customer attributes tab.


Forum|alt.badge.img
  • Author
  • Freshman II
  • 16 replies
  • December 21, 2022

Thanks for your response @aaghaei . Since am very new, i was not aware of this. Will post a new question as per your advise.


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings