Hello all,
How would I go about changing the default value in the customization project for a specific field on a form?
I though it would be under this section, but I haven’t had any luck so far.
Hello all,
How would I go about changing the default value in the customization project for a specific field on a form?
I though it would be under this section, but I haven’t had any luck so far.
Typically you won’t change the business logic for default field values within the screen code. What are you trying to do with your change?
Hi ddunn,
I am trying to use the case class id as a unique identifier for cases, therefore i have setup different forms and views in case management to segregate let’s say between customer service and construction department. I need to change default values for those screens individually so that users dont have to every time they manually enter a case.
Example: customer service employee opens their case management form and “CS” is already checked by default and they cannot update. This way their cases stay in their section
Hopefully that made sense.
Override the target field and change PXDefault attribute:
#region CaseClassID
public abstract class caseClassID : PX.Data.BQL.BqlString.Field<caseClassID> { }
[PXDBString(10, IsUnicode = true, InputMask = ">aaaaaaaaaa")]
[PXDefault(typeof(Search<CRSetup.defaultCaseClassID>))]
[PXUIField(DisplayName = "Class ID")]
[PXSelector(typeof(CRCaseClass.caseClassID),
DescriptionField = typeof(CRCaseClass.description),
CacheGlobal = true)]
[PXMassUpdatableField]
public virtual String CaseClassID { get; set; }
#endregion
Or create a graph extension, then use FieldDefaulting event and NewValue property:
public class CRCaseMaintExt : PXGraphExtension<PX.Objects.CR.CRCaseMaint>
{
public virtual void CRCase_CaseClassID_FieldDefaulting(PXCache sender, PXFieldDefaultingEventArgs e)
{
e.NewValue = "DefaultValue";
}
}
Thanks Hughes, looks like that 1st option might be the way.
Would you happen to know the syntax to default it to a specific Class ID? I’m kind of lost on that part.
PXDefault attribute points to DB field CRSetup.defaultCaseClassID. This is where the default value is stored. In UI this field is shown in Customer Management Preferences screen:
If you need any complex initialization logic PXDefault attribute will not be able to do it. You need to use FieldDefaulting or build a custom defaulting attribute for that.
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.