Skip to main content
Question

How to remove default value


Sagar Greytrix
Captain II
Forum|alt.badge.img+3

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

dcomerford
Captain I
Forum|alt.badge.img+15
  • Captain I
  • 597 replies
  • October 6, 2023

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,

 


Keith Richardson
Varsity II
Forum|alt.badge.img+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) { }


 

 

 


Sagar Greytrix
Captain II
Forum|alt.badge.img+3

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


Keith Richardson
Varsity II
Forum|alt.badge.img+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;
		}

 


Sagar Greytrix
Captain II
Forum|alt.badge.img+3

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.


Keith Richardson
Varsity II
Forum|alt.badge.img+2

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


Sagar Greytrix
Captain II
Forum|alt.badge.img+3

@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


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings