Skip to main content
Solved

How does GLTran DAC manipulate the FinPeriodID

  • November 19, 2024
  • 7 replies
  • 85 views

I am writing a custom DAC that uses the GLTran table.  The default GLTran DAC will filter on the FinPeriodID field in the format MM-YYYY, however stores the field as YYYYMM.  When i try to use the field directly in GI conditions I have to specify the financial period ID as YYYYMM to get the results.  What do I need to do in my DAC for that field to operate in the MM-YYYY form like it does in the stock GLTran DAC?

 

I tried working with something like this:

 

  #region DB Calced Formulas
  using FinPeriodIDLeft4 = Use<Left<GLTran.finPeriodID, int4>>.AsString;
  #endregion

However, I do not know how to swap the first 4 and last 2 of the field value in order to make it work like the stock DAC does.

 

Thank you in advance!

Best answer by MatthewMyersDR

saifalisabri wrote:

You need to work with a DB-calculated formula or a helper field in your custom DAC.

1. Understand the Stock Behavior

The stock GLTran DAC likely uses a display-only attribute or a calculated field to format YYYYMM into MM-YYYY for presentation. When used in a Generic Inquiry (GI), this transformation is handled seamlessly by the system.

2. Create a Display Field for FinPeriodID

You can create a calculated field in your DAC that manipulates the YYYYMM value into the desired MM-YYYY format.

Example Implementation:

#region FinPeriodIDFormatted [PXString(7, IsUnicode = true)] [PXUIField(DisplayName = "Fin. Period (Formatted)")] public virtual string FinPeriodIDFormatted { get { if (string.IsNullOrEmpty(this.FinPeriodID)) return null; // Swap YYYYMM to MM-YYYY return $"{this.FinPeriodID.Substring(4, 2)}-{this.FinPeriodID.Substring(0, 4)}"; } } public abstract class finPeriodIDFormatted : PX.Data.BQL.BqlString.Field<finPeriodIDFormatted> { } #endregion 
  • The FinPeriodIDFormatted field is a calculated property that takes the stored FinPeriodID (in YYYYMM format) and reformats it to MM-YYYY.
  • Use Substring to extract the last two digits (month) and the first four digits (year) from FinPeriodID.

3. Add to Generic Inquiry

In Generic Inquiries, include the FinPeriodIDFormatted field instead of the raw FinPeriodID. This field will display the MM-YYYY format for easy filtering and reporting.

4. If You Need a DB-Level Transformation

For database-level manipulation, you can use a SQL-calculated field by specifying the formula in your DAC using the PXDBCalced attribute.

Example with PXDBCalced:

#region FinPeriodIDFormatted [PXDBCalced(typeof(Substring<GLTran.finPeriodID, int4, int2> + "-" + Substring<GLTran.finPeriodID, int0, int4>), typeof(string))] [PXUIField(DisplayName = "Fin. Period (Formatted)")] public virtual string FinPeriodIDFormatted { get; set; } public abstract class finPeriodIDFormatted : PX.Data.BQL.BqlString.Field<finPeriodIDFormatted> { } #endregion 
  • This SQL-calculated field will dynamically generate the MM-YYYY format for the FinPeriodID column at the database level.

5. Align with UI/Filtering Expectations

Ensure the field aligns with UI expectations:

  • Add [PXUIField] to ensure the field appears correctly in forms and inquiries.
  • Use the formatted field in reports, screens, and GIs where users need MM-YYYY.

Summary

  • Use a helper property or DB-calculated field to format YYYYMM to MM-YYYY.
  • The Substring method allows splitting and reordering of the string.
  • Use the formatted field in UIs and GIs for consistent user interaction.

The DB level version of this seems like it is close, however it does not like this part:
 

[PXDBCalced(typeof(Substring<GLTran.finPeriodID, int4, int2> + "-" + Substring<GLTran.finPeriodID, int0, int4>), typeof(string))]

If I take out the concatenation part where you join the strings together it works as expected, but when I try to use it in the form you provided I get the following errors:

 

 

I really feel like this one is close if I can figure out how to join the strings together in a way that Acumatica likes.

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

7 replies

Nilkanth Dipak
Semi-Pro I
Forum|alt.badge.img+10

Hi ​@MatthewMyersDR,

Have you tried with using same declaration of FinPeriodID field of GLTran Dac in your custom DAC?

#region YourFinPeriodIDField
public abstract class yourPeriodIDField : PX.Data.BQL.BqlString.Field<yourPeriodIDField> { }
protected String _YourPeriodIDField;
[PXDefault]
[FinPeriodID(
    branchSourceType: typeof(GLTran.branchID), 
    masterFinPeriodIDType: typeof(GLTran.tranPeriodID),
    headerMasterFinPeriodIDType: typeof(Batch.tranPeriodID))]
[PXUIField(DisplayName = "Period ID", Enabled = false, Visible = false)]
public virtual String YourPeriodIDField
{
	get
	{
		return this._YourPeriodIDField;
	}
	set
	{
		this._YourPeriodIDField = value;
	}
}
#endregion

Please try to declare like this in your custom DAC for period ID.
Hope, it helps!


Forum|alt.badge.img+1
  • Jr Varsity I
  • 62 replies
  • November 19, 2024

To display financial selector need to add UsrOrganizationID,UsrBranchID,UsrOrgBAccountID field with attribute then UsrCommissionPeriod​ defined it.

#region UsrCommissionPeriod​

[PXDefault()]​

[AnyPeriodFilterable(null, typeof(AccessInfo.businessDate),​

branchSourceType: typeof(usrbranchID),​

organizationSourceType: typeof(usrorganizationID),​

useMasterCalendarSourceType: typeof(AccountByPeriodFilter.useMasterCalendar),​

redefaultOrRevalidateOnOrganizationSourceUpdated: false)]​

[PXUIField(DisplayName = "Commission Period", Visibility = PXUIVisibility.Visible)]​

public virtual string TSCommissionPeriod { get; set; }​

public abstract class uSrCommissionPeriod : PX.Data.BQL.BqlString.Field<uSrCommissionPeriod> { }​

#endregion​


saifalisabri
Jr Varsity II
Forum|alt.badge.img
  • Jr Varsity II
  • 44 replies
  • November 19, 2024

Added by moderator: This reply has been created with the help of AI

 

You need to work with a DB-calculated formula or a helper field in your custom DAC.

1. Understand the Stock Behavior

The stock GLTran DAC likely uses a display-only attribute or a calculated field to format YYYYMM into MM-YYYY for presentation. When used in a Generic Inquiry (GI), this transformation is handled seamlessly by the system.

2. Create a Display Field for FinPeriodID

You can create a calculated field in your DAC that manipulates the YYYYMM value into the desired MM-YYYY format.

Example Implementation:

#region FinPeriodIDFormatted [PXString(7, IsUnicode = true)] [PXUIField(DisplayName = "Fin. Period (Formatted)")] public virtual string FinPeriodIDFormatted { get { if (string.IsNullOrEmpty(this.FinPeriodID)) return null; // Swap YYYYMM to MM-YYYY return $"{this.FinPeriodID.Substring(4, 2)}-{this.FinPeriodID.Substring(0, 4)}"; } } public abstract class finPeriodIDFormatted : PX.Data.BQL.BqlString.Field<finPeriodIDFormatted> { } #endregion 
  • The FinPeriodIDFormatted field is a calculated property that takes the stored FinPeriodID (in YYYYMM format) and reformats it to MM-YYYY.
  • Use Substring to extract the last two digits (month) and the first four digits (year) from FinPeriodID.

3. Add to Generic Inquiry

In Generic Inquiries, include the FinPeriodIDFormatted field instead of the raw FinPeriodID. This field will display the MM-YYYY format for easy filtering and reporting.

4. If You Need a DB-Level Transformation

For database-level manipulation, you can use a SQL-calculated field by specifying the formula in your DAC using the PXDBCalced attribute.

Example with PXDBCalced:

#region FinPeriodIDFormatted [PXDBCalced(typeof(Substring<GLTran.finPeriodID, int4, int2> + "-" + Substring<GLTran.finPeriodID, int0, int4>), typeof(string))] [PXUIField(DisplayName = "Fin. Period (Formatted)")] public virtual string FinPeriodIDFormatted { get; set; } public abstract class finPeriodIDFormatted : PX.Data.BQL.BqlString.Field<finPeriodIDFormatted> { } #endregion 
  • This SQL-calculated field will dynamically generate the MM-YYYY format for the FinPeriodID column at the database level.

5. Align with UI/Filtering Expectations

Ensure the field aligns with UI expectations:

  • Add [PXUIField] to ensure the field appears correctly in forms and inquiries.
  • Use the formatted field in reports, screens, and GIs where users need MM-YYYY.

Summary

  • Use a helper property or DB-calculated field to format YYYYMM to MM-YYYY.
  • The Substring method allows splitting and reordering of the string.
  • Use the formatted field in UIs and GIs for consistent user interaction.

  • Author
  • Freshman II
  • 4 replies
  • November 19, 2024
Dipak Nilkanth wrote:

Hi ​@MatthewMyersDR,

Have you tried with using same declaration of FinPeriodID field of GLTran Dac in your custom DAC?

#region YourFinPeriodIDField
public abstract class yourPeriodIDField : PX.Data.BQL.BqlString.Field<yourPeriodIDField> { }
protected String _YourPeriodIDField;
[PXDefault]
[FinPeriodID(
    branchSourceType: typeof(GLTran.branchID), 
    masterFinPeriodIDType: typeof(GLTran.tranPeriodID),
    headerMasterFinPeriodIDType: typeof(Batch.tranPeriodID))]
[PXUIField(DisplayName = "Period ID", Enabled = false, Visible = false)]
public virtual String YourPeriodIDField
{
	get
	{
		return this._YourPeriodIDField;
	}
	set
	{
		this._YourPeriodIDField = value;
	}
}
#endregion

Please try to declare like this in your custom DAC for period ID.
Hope, it helps!

I tried implementing this code and the field results were blank.


  • Author
  • Freshman II
  • 4 replies
  • Answer
  • November 19, 2024
saifalisabri wrote:

You need to work with a DB-calculated formula or a helper field in your custom DAC.

1. Understand the Stock Behavior

The stock GLTran DAC likely uses a display-only attribute or a calculated field to format YYYYMM into MM-YYYY for presentation. When used in a Generic Inquiry (GI), this transformation is handled seamlessly by the system.

2. Create a Display Field for FinPeriodID

You can create a calculated field in your DAC that manipulates the YYYYMM value into the desired MM-YYYY format.

Example Implementation:

#region FinPeriodIDFormatted [PXString(7, IsUnicode = true)] [PXUIField(DisplayName = "Fin. Period (Formatted)")] public virtual string FinPeriodIDFormatted { get { if (string.IsNullOrEmpty(this.FinPeriodID)) return null; // Swap YYYYMM to MM-YYYY return $"{this.FinPeriodID.Substring(4, 2)}-{this.FinPeriodID.Substring(0, 4)}"; } } public abstract class finPeriodIDFormatted : PX.Data.BQL.BqlString.Field<finPeriodIDFormatted> { } #endregion 
  • The FinPeriodIDFormatted field is a calculated property that takes the stored FinPeriodID (in YYYYMM format) and reformats it to MM-YYYY.
  • Use Substring to extract the last two digits (month) and the first four digits (year) from FinPeriodID.

3. Add to Generic Inquiry

In Generic Inquiries, include the FinPeriodIDFormatted field instead of the raw FinPeriodID. This field will display the MM-YYYY format for easy filtering and reporting.

4. If You Need a DB-Level Transformation

For database-level manipulation, you can use a SQL-calculated field by specifying the formula in your DAC using the PXDBCalced attribute.

Example with PXDBCalced:

#region FinPeriodIDFormatted [PXDBCalced(typeof(Substring<GLTran.finPeriodID, int4, int2> + "-" + Substring<GLTran.finPeriodID, int0, int4>), typeof(string))] [PXUIField(DisplayName = "Fin. Period (Formatted)")] public virtual string FinPeriodIDFormatted { get; set; } public abstract class finPeriodIDFormatted : PX.Data.BQL.BqlString.Field<finPeriodIDFormatted> { } #endregion 
  • This SQL-calculated field will dynamically generate the MM-YYYY format for the FinPeriodID column at the database level.

5. Align with UI/Filtering Expectations

Ensure the field aligns with UI expectations:

  • Add [PXUIField] to ensure the field appears correctly in forms and inquiries.
  • Use the formatted field in reports, screens, and GIs where users need MM-YYYY.

Summary

  • Use a helper property or DB-calculated field to format YYYYMM to MM-YYYY.
  • The Substring method allows splitting and reordering of the string.
  • Use the formatted field in UIs and GIs for consistent user interaction.

The DB level version of this seems like it is close, however it does not like this part:
 

[PXDBCalced(typeof(Substring<GLTran.finPeriodID, int4, int2> + "-" + Substring<GLTran.finPeriodID, int0, int4>), typeof(string))]

If I take out the concatenation part where you join the strings together it works as expected, but when I try to use it in the form you provided I get the following errors:

 

 

I really feel like this one is close if I can figure out how to join the strings together in a way that Acumatica likes.


  • Author
  • Freshman II
  • 4 replies
  • November 19, 2024

Ok so I’ve made some progress, however I still have a problem.  When I use this field in my DAC and try to specify a condition on that field, it does not honor the conditions and returns all records.  Here is my field, what am I doing wrong?

 

[PXString(6, IsKey = false, IsUnicode = true, InputMask = "##-####")]
[PXDBCalced(typeof(Add<BQL.Substring<GLTran.finPeriodID, int5, int2>, BQL.Substring<GLTran.finPeriodID, int1, int4>>), typeof(String))]
[PXUIField(DisplayName = "Period ID")]
public virtual String FinPeriodID { get; set; }
public abstract class finPeriodID : BqlString.Field<finPeriodID> { }

Thank you for your assistance.


  • Author
  • Freshman II
  • 4 replies
  • November 20, 2024

I think I have it working the way I need it to.  Here is my current solution.

 

#region FinPeriodID  
[PXString(6, IsKey = true, IsUnicode = true, InputMask = "##-####")]
[PXDBCalced(typeof(Add<PX.Data.BQL.Substring<GLTran.finPeriodID, int5, int2>, PX.Data.BQL.Substring<GLTran.finPeriodID, int1, int4>>), typeof(String))]
[PXUIField(DisplayName = "Period ID")]
public virtual String FinPeriodID { get; set; }
public abstract class finPeriodID : BqlString.Field<finPeriodID> { }
#endregion

 


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