Question

How to remove default value

  • 6 October 2023
  • 7 replies
  • 120 views

Userlevel 5
Badge +1

Hi team,

I would like to remove the default value in the Project screen based on a template condition.

I attempted to use the Row_Updated event, but it didn't work. I then tried using the Row_Selected event, which successfully removed the default value. However, a new issue arose: when I select a new value, it also becomes blank because the Row_Selected event is triggered.

Could you please provide an alternative solution to address this problem?

 

I am using the code provided below.

 

 protected virtual void _(Events.RowSelected<PMTask> e)
        {
            var row = (PMTask)e.Row;
            if (row == null)
                return;

  if (row.TemplateID != null )
   {

    e.Cache.SetValue<PMTask.defaultExpenseSubID>(row, “ ”);

}

}

Regards,

Sagar

 


7 replies

Userlevel 7
Badge +12

The department is being set i presume when the TaskID ts being added to i would base your code on the TaskID FieldUpdated event to then set the Department to null. Even if it set when the line is added once the TaskId is set then you can use ity to blank it,

 

Userlevel 4
Badge +2

I would try removing the default attribute in your graph extension:

        [PXMergeAttributes(Method = MergeMethod.Append)]
        [PXRemoveBaseAttribute(typeof(PXDefaultAttribute))]
        protected virtual void _(Events.CacheAttached<PMTask.defaultExpenseSubID> e) { }


 

 

 

Userlevel 5
Badge +1

Hi @Keith Richardson @dcomerford  ,

I have attempted both solutions, but I still haven't achieved the desired result. The default value is still visible. I also attempted to remove address values in the Quote screen, but the field remains populated. How can I remove default values and provide new values in the project and quote screens?

Regards

Sagar

Userlevel 4
Badge +2

I checked, and they are adding the attribute for defaulting in the ProjectEntry graph, so that is most likely why the remove base attribute will not work.

 

The other approach is to attach to the field defaulting event, execute the delegates first, and then at the end set to null.

Let me know if this works for you.

 


public virtual void _(Events.FieldDefaulting<PMTask.defaultExpenseSubID> e, PXFieldDefaulting del)
{
//call all other defaulting methods first
del?.Invoke(e.Cache, e.Args);

//set the value to null
e.NewValue = null;
}

 

Userlevel 5
Badge +1

namespace PX.Objects.PM
{
    public class ProjectEntry_Extension : PXGraphExtension<PX.Objects.PM.ProjectEntry>
    {
     #region Event Handlers

 public virtual void _(Events.FieldDefaulting<PMTask.defaultSalesSubID> e, PXFieldDefaulting del)
 {
     //call all other defaulting methods first
     del?.Invoke(e.Cache, e.Args);

     //set the value to null
     e.NewValue = null;
 }
        #endregion

}

}

@Keith Richardson I tried the code provided above in the 'ProjectEntry_Extension,' graph but whenever I select a template or task, it always shows the default value there.

Userlevel 4
Badge +2

Which field is department? I do not find it in the default DAC.

Userlevel 5
Badge +1

@Keith Richardson I have renamed the field in this department. When I select the template, a default value appears in this field on the project screen. I want to remove that value.

I tried the code you provided on the Quote screen to remove the default address, but when I select 'business account' on the Quote screen, the address is still appearing as default.

I tried this code in the 'ProjectEntry_Extension' graph of the project, but I didn't get the desired result. is there any other way I can remove the default value from the fields in the Project and Quote screens?

 

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