Solved

Dropdown list in Customer Location screen.

  • 20 December 2022
  • 6 replies
  • 324 views

Userlevel 3
Badge

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.

 

icon

Best answer by aaghaei 20 December 2022, 23:35

View original

6 replies

Userlevel 5
Badge +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

 

Userlevel 7
Badge +9

@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

 

Userlevel 3
Badge

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.

Userlevel 3
Badge

@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.

Userlevel 7
Badge +9

@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.

Userlevel 3
Badge

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


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved