Skip to main content
Answer

Property for Custom DAC field to hard code first character and now allow it to be overwritten?

  • May 5, 2025
  • 3 replies
  • 60 views

Forum|alt.badge.img

Hello Community, 

I am working on a customization to add a custom user field with a character hard coded as the first character in the string and would like it to not be selectable\overwritable. So essentially it would look like “T” on the screen and start at data entry after that character. Currently I have below. Is there a property I could set to start the text entry at position 2? 

#region UsrTNo
[PXDBString(3)]
[PXDefault(typeof(T), PersistingCheck = PXPersistingCheck.Nothing)]
public virtual string UsrTNo { get; set; }
public abstract class usrTNo : PX.Data.BQL.BqlString.Field<usrTNo> { }
#endregion
public class T : PX.Data.BQL.BqlString.Constant<T>
{
public T() : base("T") { }
}

Thanks!

Best answer by darylbowman

Essentially, no I don’t think there is any way to do EXACTLY what you’re describing (aside from possibly using JavaScript). However, you could handle the FieldUpdating event to check if the new value begins with ‘T’ and prepend it if it does not; you could handle the FieldVerifying event to throw an error if the value does not begin with ‘T’, etc.

3 replies

darylbowman
Captain II
Forum|alt.badge.img+15

Essentially, no I don’t think there is any way to do EXACTLY what you’re describing (aside from possibly using JavaScript). However, you could handle the FieldUpdating event to check if the new value begins with ‘T’ and prepend it if it does not; you could handle the FieldVerifying event to throw an error if the value does not begin with ‘T’, etc.


Forum|alt.badge.img
  • Author
  • Jr Varsity III
  • May 6, 2025

@darylbowman Thanks for the assist. So many properties for DACs that I wanted to make sure I had not missed a fancy one I could add to my repertoire!

Thanks!


darylbowman
Captain II
Forum|alt.badge.img+15

If you wanna flex your creative muscles, you could build an attribute yourself with the event handlers contained within it 😉