View the current dataset that is populating the table

Ok, I have a table that has a pretty complication "if" ternary statement in it.

However, it is becoming quite difficult for me to determine "which" if statement is triggering the table dataset that fills the table. I know this sounds strange but, I can see the console and see that a certain dataset has been triggered. But, the wrong data is actually being displayed in the table.

Is there a way for me to determine "which" resource query is currently being used to populate a table? I looked at table1.data and that just contains the query results but nothing about which resource has populated the table. Any ideas? Thanks!

Hey @macphreak,

There is no straightforward way of doing it this directly from the table's data.

However, you could create a simple js query with the same terniary logic and log to your console, for each condition, which data source is being used. You can then change the variables impacting your conditions and see what the is being logged in your console by the JS query.

Hi @MiguelOrtiz,

How would I add console.log() statements inside a tertiary code segment? For example, if I had something like this:

{{  select1.value === '5555' && varSubStatus.value === '' ? getALLUpsheetsSubs2.data : select1.value === '5555' && tblCampaignLeadsCount.selectedRow.sub_status_c != '' ?  getALLUpsheetsSubsWithSubStatus.data: (select1.value != '5555' && select1.value != '7777' && txtSubStatus.value === '') ? getUpsheetsSubsNO_SUB_STATUS.data :
  select1.value === '7777' && varSubStatus.value != ''  ? getUpsheetsSubsWEBSITE_ONLY_NO_SUB_STATUS.data : 
  select1.value === '7777' && tblCampaignLeadsCount.selectedRow.sub_status_c != '' ? getUpsheetsSubsWEBSITE_ONLY.data : 
  getUpsheetsSubs.data }}

I had to remove and generalize the above data but it's essentially the same. How would I add console logging for each one here? The above is in the "Data source" for the table I am trying to work with. Thanks!

Hey Scott,

So I'm not suggesting to make the embed the logs within your code segment. What I suggest is to create a transformer and add a code like the below:

const select1Value = {{ select1.value }};
const varSubStatusValue = {{ varSubStatus.value }};
const tblCampaignSubStatus = {{ tblCampaignLeadsCount.selectedRow.sub_status_c }};
const txtSubStatusValue = {{ txtSubStatus.value }};

return (
  select1Value === '5555' && varSubStatusValue === '' 
    ? "getALLUpsheetsSubs2.data"
    : select1Value === '5555' && tblCampaignSubStatus !== '' 
    ? "getALLUpsheetsSubsWithSubStatus.data"
    : select1Value !== '5555' && select1Value !== '7777' && txtSubStatusValue === '' 
    ? "getUpsheetsSubsNO_SUB_STATUS.data"
    : select1Value === '7777' && varSubStatusValue !== '' 
    ? "getUpsheetsSubsWEBSITE_ONLY_NO_SUB_STATUS.data"
    : select1Value === '7777' && tblCampaignSubStatus !== '' 
    ? "getUpsheetsSubsWEBSITE_ONLY.data"
    : "getUpsheetsSubs.data"
);

This transformer then will actually return a string with the data (you could arguably use transformer1.value as your data source and make it easier for you to modify it in the future).

Does this make sense?

That worked! Only problem is now - the table (tblUpsheet) doesn't seem to want to refresh even when the transformer is set correct. I can run the transformer query once and it works. But, if I run it the second time, the table will keep the results from the transformer data from the first run. Any way to force the table to refresh programmatically? Thanks!

So, are you using a transformer or a Js query? the trasnformer's value will update automatically whenever one of your variables changes.

Now, your table's data set should be updating automatically (although I've never tried this so I'm not completely sure if that's the case). Just a quick question: by refresh do you mean the data set or also the columns?

What happens if you right click on the table and click "Reset state", will that update the data source?

Nope. reset state doesn't do anything. I can't seem to find a way to have it "refresh". The only way I can get it to work is to manually go over to the query and just run the query that I know is supposed to be triggered and then it refreshes it (which tells me the transformer JS is working correctly and populating the correct query source).

And it is a transformer that I am using.

Any additional thoughts on this one?

Hi @macphreak! The transformer runs every time the references change, but we are not triggering the query. Maybe we can use a JS query.

Instead of doing that ternary, we could use a case or if statement to trigger first and then return:

const select1Value = {{ select1.value }};
const varSubStatusValue = {{ varSubStatus.value }};
const tblCampaignSubStatus = {{ tblCampaignLeadsCount.selectedRow.sub_status_c }};
const txtSubStatusValue = {{ txtSubStatus.value }};

if (select1Value === '5555' && varSubStatusValue === '') {
    await getALLUpsheetsSubs2.trigger();
    return "getALLUpsheetsSubs2.data";
} else if (select1Value === '5555' && tblCampaignSubStatus !== '') {
    await getALLUpsheetsSubsWithSubStatus.trigger();
    return "getALLUpsheetsSubsWithSubStatus.data";
} else if (select1Value !== '5555' && select1Value !== '7777' && txtSubStatusValue === '') {
    await getUpsheetsSubsNO_SUB_STATUS.trigger()
    return "getUpsheetsSubsNO_SUB_STATUS.data";
} else if (select1Value === '7777' && varSubStatusValue !== '') {
    await getUpsheetsSubsWEBSITE_ONLY_NO_SUB_STATUS.trigger();
    return "getUpsheetsSubsWEBSITE_ONLY_NO_SUB_STATUS.data";
} else if (select1Value === '7777' && tblCampaignSubStatus !== '') {
   await getUpsheetsSubsWEBSITE_ONLY.trigger() 
   return "getUpsheetsSubsWEBSITE_ONLY.data";
} else {
    await getUpsheetsSubs.trigger()
    return "getUpsheetsSubs.data";
}

Finally, create even handlers to run this query when needed (e.g. change on select component, change in selected row, etc).