Skip to main content
Solved

save the Custom field values without having to click on the Revenue Budget tab

  • 4 June 2024
  • 6 replies
  • 57 views

Hello Team,

I've added custom fields to the Revenue Budget tab on the Project screen. I wrote code for the RowSelected event, but the values are not being saved in the database when I click the Save button in the Project Header. However, if I click the Revenue Budget tab any field within it, followed by the Save button, the values are saved properly.

Could you please assist me in finding a solution to save the field values without having to click on the Revenue Budget tab?

 

Custom Field Code:

public class PMBudgetExt : PXCacheExtension<PX.Objects.PM.PMBudget>
{
  #region UsrPTDBilled
  ÂPXDBDecimal]
  >PXUIField(DisplayName="PTD Billed", Enabled = false)]
  public virtual Decimal? UsrPTDBilled { get; set; }
  public abstract class usrPTDBilled : PX.Data.BQL.BqlDecimal.Field<usrPTDBilled> { }
  #endregion

}

 

Code File:

 

public class ProjectEntry_Extension : PXGraphExtension<PX.Objects.PM.ProjectEntry>
{
    public static bool IsActive() => true;

protected virtual void _(Events.RowSelected<PMRevenueBudget> e)
{
    var row = (PMRevenueBudget)e.Row;

    if (row == null) return;
    PMBudgetExt itemExt = PXCache<PMBudget>.GetExtension<PMBudgetExt>(row);
    if (itemExt.UsrPTDBilled == null)
    {
        e.Cache.SetValueExt<PMBudgetExt.usrPTDBilled>(row,100);
    }

}

Thank you.

Sagar

6 replies

Userlevel 7
Badge +9

1) As name indicates, the RowSelected event is triggered when a row is selected. When you click on the revenue budget tab then the first line of the Revenue Budget is selected so the code is triggered.

2) You shouldn’t really manipulating values in the RowSelected event. It’s primary purpose is to manipulate UI controls accessibility.

Userlevel 5
Badge +2

@aaghaei 

Thanks for your response. This custom field is a calculation field. The field value comes from the PM budget table when the transaction is created for the same project.

Could you please assist me with which action or event I can use for this? I await your response.

Userlevel 7
Badge +9

If you reading existing fields when the form is initiated and then run some logic on it for presentation purpose only then I would suggest to change your field type to Unbound and perform the logic in the FieldSelecting event.

Userlevel 7
Badge +9

Sorry, I just noticed from the post title you want to save the values. Please Ignore the Unbound piece from my previous comment.

Userlevel 5
Badge +2

@aaghaei Yes, it is not working. I want to use this field in GI. Do you have any solution for how we can solve this issue?

Userlevel 7
Badge +9

Assuming you retrive the value from existing data then perform your logic o come up with a value then assign it your custom field then as suggested earlier, in the FieldSelecting event set the field value as follows 

decimal? myVar = //Perform your logic and assign your calculated value to this
e.ReturnValue = myVar;

please note the field you are assigning value to should exist in UI to be included in the FieldSelecting Collection.

Reply