Skip to main content
Question

How to resolve field disable issue when Joining DAC's in a view


Forum|alt.badge.img

I created a custom screen of type FormTab. I added the following view to the form (summary) area. However, some fields appear as disabled(uneditable) when the screen is displayed. Specially all fields in the second DAC. When I add these DACs alone as the view, fields appear correctly with editability. This issue occurs only when the DACs are joined.

   public SelectFrom<AMMTran>
        .InnerJoin<AMProdItem>
.           On<AMProdItem.orderType.IsEqual<AMMTran.orderType>
.           And<AMProdItem.prodOrdID.IsEqual<AMMTran.prodOrdID>>>

            .View HeaderView;

I tried resolving this issue using an a RowSelected event handler as follows, but it didn’t work. I also set Enabled = true for the fields using the Customization Project Editor, but the problem persists. Any detailed instructions, tips, or code snippets would be greatly appreciated. Thank you!

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


            PXUIFieldAttribute.SetEnabled<AMProdItem.prodOrdID>(e.Cache, e.Row, true);

        }

6 replies

Forum|alt.badge.img+7
  • Captain II
  • 270 replies
  • November 19, 2024

Hi ​@RKarunarathne51 

 

When you join the views, I believe that the secondary table is just read-only, in your case AMProdItem is the secondary table.

 

Hope this helps, 

Aleks


darylbowman
Captain II
Forum|alt.badge.img+13

Aleks is correct. The only way around this is to create a PXProjection with Persistent = true (more info here).


Forum|alt.badge.img

@aiwan, ​@darylbowman,

Why does this happen? Built-in Acumatica views do not exhibit this behavior, and sometimes even custom-made views work without this issue.


Forum|alt.badge.img

@darylbowman ,

I want to create a view with four DACs. Three of them are built-in, and one is custom. I intend to use this view in a form to display data from the first three DACs and store data in the custom DAC. I started using the above method, but that’s when the issue occurred. Can PXProjection be used for this task, or is my approach correct? What would you suggest? Thank you in advance!


saifalisabri
Freshman I
Forum|alt.badge.img
  • Freshman I
  • 12 replies
  • November 21, 2024

My response was crafted with AI assistance, tailored to provide detailed and actionable guidance for your query.

This issue commonly occurs in Acumatica when joining Data Access Classes (DACs) because fields in the secondary DAC can become read-only if Acumatica's UI framework determines that they are not directly editable based on the BQL query structure and related caching logic.

Here are steps to resolve this issue:

1. Ensure Proper Declaration of the View

When joining DACs, ensure that the primary DAC (AMMTran) is clearly defined as the main focus of the view. Joined DACs may inherit the read-only state unless explicitly overridden.

2. Use PXUIFieldAttribute.SetEnabled in the RowSelected Event of the Primary DAC

If you want fields from the secondary DAC (AMProdItem) to be editable, you must explicitly enable them in the RowSelected event for the primary DAC (AMMTran in your case). Adjust your event handler as follows:

csharp  Copy code

protected virtual void _(Events.RowSelected<AMMTran> e) { if (e.Row == null) return; var prodItem = PXSelectorAttribute.Select<AMMTran.prodOrdID>(e.Cache, e.Row) as AMProdItem; if (prodItem != null) { PXUIFieldAttribute.SetEnabled<AMProdItem.prodOrdID>(Caches[typeof(AMProdItem)], prodItem, true); PXUIFieldAttribute.SetEnabled<AMProdItem.someOtherField>(Caches[typeof(AMProdItem)], prodItem, true); } }

3. Validate Your View Definition

Sometimes, the structure of your BQL query can influence the editability of fields. To mitigate this, consider defining a separate view for the secondary DAC and linking them through events or delegates. For example:

csharp Copy code

public SelectFrom<AMMTran>.View HeaderView; public SelectFrom<AMProdItem> .Where<AMProdItem.orderType.IsEqual<HeaderView.Current.orderType> .And<AMProdItem.prodOrdID.IsEqual<HeaderView.Current.prodOrdID>>> .View ProdItemView;

You can use the HeaderView to handle the main DAC and ProdItemView to manage the secondary DAC's fields.

4. Customization Project Editor Configuration

Verify the field-level properties in the Customization Project Editor. Make sure:

  • The fields are not explicitly set as Disabled or Read-Only.
  • The fields have no conflicting Enabled or Read-Only conditions in their attributes.

5. Override Cache-Level Field Attributes

If none of the above works, you can directly override the field's cache-level attributes. Add the following code in the Initialize or RowSelected event:

csharp Copy code

protected virtual void AMProdItem_RowSelected(PXCache cache, PXRowSelectedEventArgs e) { var row = e.Row as AMProdItem; if (row == null) return; PXUIFieldAttribute.SetEnabled<AMProdItem.prodOrdID>(cache, row, true); }

6. Check Field Permissions and Access Rights

  • Verify the user role permissions for the fields and DACs. The Field Security settings could cause fields to appear disabled.
  • Confirm there are no restrictions applied via the Access Rights configuration for the screen.

7. Debug and Trace the Issue

Enable the Debug Mode in Acumatica and monitor the trace log when the screen is loaded. Look for any unexpected overrides or conditions affecting field states.

8. Revisit Your Join Logic

If the above approaches fail, try modifying your join logic to avoid potential side effects. For instance, using LeftJoin instead of InnerJoin may sometimes resolve field editability issues by avoiding strict dependency between the DACs.

By combining these techniques, you should be able to resolve the issue and ensure the fields in the secondary DAC are editable when displayed in the joined view.


Forum|alt.badge.img+7
  • Captain II
  • 270 replies
  • November 21, 2024

Hi ​@RKarunarathne51 

 

I don’t particularly have experience in SQL views but I can only imagine BQL views work the same way.

Using joins in a view is usually for data display, not modification.

However, using a PXProjection, as Daryl said, is the only way to join tables and be able to edit them.

The CRQuote DAC is a PXProjection, so is the CROpportunity table. They are both projections of the CR.Standalone.CRQuote/Opportunity DACs.

Here is a snippet of the source code:

[PXProjection(typeof(Select2<Standalone.CROpportunity,
    InnerJoin<Standalone.CROpportunityRevision,
        On<Standalone.CROpportunityRevision.noteID,/*This is the Projection Declaration*/ Equal<Standalone.CROpportunity.defQuoteID>>,
    LeftJoin<Standalone.CRQuote,
        On<Standalone.CRQuote.quoteID, Equal<Standalone.CROpportunity.defQuoteID>>>>>),
    new Type[]
    {
        typeof(Standalone.CROpportunity),
        typeof(Standalone.CROpportunityRevision),
    })]

 Here is a field declaration:

#region Details
public abstract class details : PX.Data.BQL.BqlString.Field<details> { }

/// <summary>
/// The detailed description or any relevant notes of the opportunity
/// </summary>
/// <value>
/// The value is in rich text format.
/// </value>
[PXDBText(IsUnicode = true, BqlField = typeof(Standalone.CROpportunity.details))] //Notice the BqlField = typeof, this declares what field the value persists to and pulls data from it is the only change to the DAC that you would need to make alongside the PXProjeciton Declaration
[PXUIField(DisplayName = "Details")]
public virtual String Details { get; set; }
#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