Solved

Customer screen Attribute to display in Customer Location screen.

  • 21 December 2022
  • 9 replies
  • 247 views

Userlevel 3
Badge

Hello Everyone, Hi @aaghaei  

I want to add a custom field in Customer Location screen(AR303020) as below so i added as preferred Tech

and the data should picked from Customer screen(AR303000), attribute TAB.

The newly added column Preferred Tech (either as Text or Dropdown) should hold the data of AttributeID field(with Value if its contain).

Kindly advise how to proceed further.

icon

Best answer by aaghaei 22 December 2022, 04:26

View original

9 replies

Userlevel 7
Badge +5

Show us your DAC code for the field.

Userlevel 3
Badge

Kindly advise what to insert in this,

#region UsrPreferredTech
    [PXDBInt]
    [PXUIField(DisplayName="Preferred Tech")]
   
    public int? UsrPreferredTech { get; set; }
    public abstract class usrPreferredTech : PX.Data.BQL.BqlInt.Field<usrPreferredTech> { }
    #endregion

Userlevel 7
Badge +5

You’re going to need two parts.  One part is the PXSelector attribute. 

[PXSelector(  
  typeof(Search<this is your search logic that returns the field value you want>),
  typeof(a field to show in the selector),
  typeof(another field to show in the selector)
)] 

Your search is going to be something similar to this. The NoteID of the customer DAC connects to the CSAnswers.refNoteID  - that’s how attributes are connected to it’s related record.

Search2<CSAnswers.value, LeftJoin<BAccount, On<BAccount.noteID, Equal<CSAnswers.refNoteID>, And<BAccount.bAccountID, Equal<Current<Customer.customerID>>>>>, Where<CSAnswers.attributeID, Equal<PreferredTechCD>>>

And because you’re going to want to include a constant in your search BQL you’ll need to include a constant declaration in your code.

public class PreferredTechCD : PX.Data.BQL.BqlString.Constant<PreferredTechCD> { public PreferredTechCD() : base("the code for your attribute") { } }

 

Userlevel 7
Badge +5

I think you’re going to run into an issue with the data type that you’ve selected. The value of an attribute is a string.

Userlevel 7
Badge +9

@sujithra

@ddunn is absolutely correct. You will need to join the attribute with customers if you need the assigned Tech to customers as per Dunn's instructions. 

From the previous thread regarding “Sales Rep”, I guess you will need the list of all your technicians. Considering you are new to Acumatica I thought you might need a hand. Below is what you will need in your DAC Ext. Replace the “COLOR” with your Technician AttributeID whatever it is.

using PX.Data;
using PX.Objects.AR;
using PX.Objects.CR;
using PX.Objects.CS;

namespace PX.Objects.CR
{
public class TechAttributeID : PX.Data.BQL.BqlString.Constant<TechAttributeID>
{
public TechAttributeID() : base("COLOR") { }
}

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

#region UsrPreferredTech
public abstract class usrPreferredTech : PX.Data.BQL.BqlString.Field<usrPreferredTech> { }
[PXDBString(10, IsUnicode = true, InputMask = "")]
[PXUIField(DisplayName = "Preferred Tech", Required = true, Enabled = true, Visible = true)]
[PXDefault(PersistingCheck = PXPersistingCheck.Null)]
[PXSelector(typeof(Search<CSAttributeDetail.valueID,
Where<CSAttributeDetail.disabled, NotEqual<True>>,
OrderBy<Asc<CSAttributeDetail.sortOrder>>>),
typeof(CSAttributeDetail.valueID),
typeof(CSAttributeDetail.description),
typeof(CSAttributeDetail.disabled),
SubstituteKey = typeof(CSAttributeDetail.valueID),
DescriptionField = typeof(CSAttributeDetail.description),
ValidateValue = true)]
[PXRestrictor(typeof(Where<CSAttributeDetail.attributeID, Equal<TechAttributeID>>), "Invalid Technician")]
public string UsrPreferredTech { get; set; }
#endregion
}
}

You will need to add the custom field (String 10) to your table as well 

<Table TableName="Location">
<Column TableName="Location" ColumnName="UsrPreferredTech" ColumnType="string" AllowNull="True" MaxLength="10" DecimalPrecision="0" DecimalLength="0" IsNewColumn="True" IsUnicode="True" />
</Table>

Publish your customization, then add the control to your screen

<px:PXSelector runat="server" ID="edUsrPreferredTech" DataField="UsrPreferredTech" CommitChanges="True" />

and you should get the below UI

 

Userlevel 7
Badge +9

@sujithra Can you please advise if the above solution worked for you and if yes kindly flag the correct answer to close the case and make it a reference for others in case they come across the same issue? If not what is the problem you are facing and provide your code for further review.@Chris Hackett 

Userlevel 3
Badge

@aaghaei Actually i used int instead of string and following is my code.

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

Userlevel 7
Badge +9

@sujithra It is up to you what kind of data type you store in DB and won’t make any difference to the solution. The question is did the suggested solution worked or not.

Userlevel 3
Badge

@aaghaei , yes it worked thank you.

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