SalesforceLabs / EnhancedLightningGrid

Component that allows you to sort and filter data within the Lightning Experience. Use as a replacement for a Related List, or create a new grid that shows results from a custom query.
BSD 3-Clause "New" or "Revised" License
135 stars 96 forks source link

Unable to query due to FORMAT #78

Open ndemers6201 opened 1 year ago

ndemers6201 commented 1 year ago

I created a grid based on Opportunity and want to display a custom Account field Account.Credit_Limit__c (which is a field type of Currency)

But the query created by this tool uses FORMAT(Account.Credit_Limit__c) with the alias Account.Credit_Limit__cFormatted

I believe this alias is the issue because when I run the entire query in developer console, I get this error: invalid alias: Account.Credit_Limit__cFormatted

The entire query is here: SELECT Account.Name,Name,Amount,FORMAT(Amount) AmountFormatted,tolabel(StageName),Account.Credit_Limit_Notesc,Account.Credit_Limit__c,FORMAT(Account.Credit_Limitc) Account.Credit_LimitcFormatted FROM Opportunity WHERE Account.Credit_Limit_Notesc = 'Notes for testing' ORDER BY Id ASC NULLS FIRST limit 10 offset 0

QUESTION: How can I define this field within the grid Account.Credit_Limit__c so that the query does not format and alias in the SOQL? I cannot change the field type on the Account object itself.

jackdmcgrady commented 1 year ago

Experiencing the same issue. Interested in whether you found a solution?

jackdmcgrady commented 1 year ago

We've identified the cause to be that the code is trying to leave the dot notation for the spanning field in the variable used to create the alias in SOQL. This character is not allowed. image

Updating the above solves part of the issue. Data now flows to the sdg and it's visible in debug but the field renders as blank. So it seems there is still another part requiring update for this scenario to allow it to render in the component.

triestelaporte commented 1 year ago

[EDIT]

I found my issue, this thread clued me in. I need to use the same inline function and alias on currency fields or the front end won't find them.

Example: FORMAT(Amount) AmountFormatted

[ORIGINAL]I have a simpler scenario using an Apex Data Provider. I think it's probably related though, as the results are the same.

In the provider I return a list of Opps with the Amount field. The column is defined as CURRENCY, and the column outputs on the data grid, but with blank values in every cell.

I can see the column definition in the debug, along with the field value in the returned data. If I change the column to DOUBLE it outputs fine, but without any currency formatting.