Skip to main content
Solved

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


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

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

Best answer by aaghaei

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.

View original
Did this topic help you find an answer to your question?

6 replies

aaghaei
Captain II
Forum|alt.badge.img+9
  • Captain II
  • 1178 replies
  • June 4, 2024

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.


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

@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.


aaghaei
Captain II
Forum|alt.badge.img+9
  • Captain II
  • 1178 replies
  • June 5, 2024

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.


aaghaei
Captain II
Forum|alt.badge.img+9
  • Captain II
  • 1178 replies
  • June 5, 2024

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


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

@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?


aaghaei
Captain II
Forum|alt.badge.img+9
  • Captain II
  • 1178 replies
  • Answer
  • June 5, 2024

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


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