How to Inspect Variables without Inspector

Is there a way to iterate the variables in code? I’d like to be able to have a function that shows all variables and their values.

Also, it is unclear when I look in the inspector what scope of variables I’m seeing. Is it Server variables, Client variables or all variables? I set a lot of variables in the InitialSetup function, which runs at login-time. I believe this is in the context of the server, because that function is doing sql queries which can’t be done on the client, right?

Is it a hard rule that code running on the server cannot see variables defined on the client, and vice-versa?

I can’t seem to find a lot of documentation on variables in the docs.

Also, the variables I see in the inspector only seem to be those set in InitialSetup function, which runs when user logs in, and I believe is on the server. So is the inspector only showing variables declared on the server, rather than client-side?

thanks…

Hi Ron,

Thank you for bringing this scenario.

Both client and server-side events are logged in the inspector, the minor improvement that we are already ware is that the inspector is not displaying the value immediately.

As workaround solution while you are developing is to create an application button, attach a new function to the event ‘On Press‘, this function will display all variable inside the property five.variable, anytime that a new variable is created you can click on this button to check.

You can use this example of function if your variables are not nested.

function CheckFiveVariable(five, context, result)  {

function printList(obj) {

  const result = Object.entries(obj)

  .map((\[key, value\]) => \`${key}: ${value}\`)

  .join("\\n");

  five.showMessage(result);

}

// usage

printList(five.variable);

return five.success(result);

}

Regards,

Elton S

Hi Elton,

Thanks for supplying this code, which I can use for examining all variables.
You didn’t exactly answer my question about variables.

This subject is somewhat confusing to me. The variables showing in the inspector are only those that were set on the server, I believe. This is based on my understanding that the Do Logon event fires when the user logs on, and because it is a “Do” function, it runs on the server. I told this event to run the Initial Setup function, which sets a bunch of variables.

These are the only variables I can see in the inspector, even though I have also set other variables during processing and working with some forms. It doesn’t seem to be displaying these values at all, not just delayed as you mentioned in your answer.

It is important that I understand how this works. Variables created during a client function are not available on the server, and should be available in the inspector, right?

Is this also true for variables created in a server function are not available on the client?

Since my reporting needs variables, because passing context to the report doesn’t work, I need to pass information in the context in the client function, then use that to set the relevant variables before trying to run the report, right?

Also, please verify that the code above will show variables created on the client AND those created on the server? So five.variable contains variables from client, or server, or both?

Thanks…

The function as you gave me doesn’t compile.

I presume this is a function inside of a function, and the outer runction, CheckFiveVariable, is run from the button press event, and it runs the printList internal function, right? but as you see, the function you gave me seems to have errors. It will not save.

Hi Ron,

The editor may have changed the code (part of your code got commented), and the code should retrieve all values (Client/server)

Could you please send me a scenario where the variables set in other places are not working, such as the name of the action, if it’s a field/page and the name of the event?

Thank you,

Please use this new version for the function:

function CheckFiveVariable(five, context, result)  {

function printList(obj) {

  const result = Object.entries(obj).map((\[key, value\]) => \`${key}: ${value}\`).join("\\n");

  five.showMessage(result);

}

// usage

printList(five.variable);

return five.success(result);

}

The image shows what it should look like. If the code gets commented again, please use the image to guide you.

Regards,

Elton S

I’m not sure if the variables are not working, I only know that they never seem to appear in the inspector. Only those values that I originally set (I believe on the server event) are showing in the inspector.

But could you please answer the questions in bold on the previous reply to you? I am having a lot of trouble understanding the scope of these variables, and where they can be seen.

Thanks…

Hi Ron,

You should be able to pass parameters to reports.

I suggest you set the variable on the server side via a callback function before calling the report, as you have the data available in the client.

Could you please send me a scenario where the variables set in other places are not working, such as the name of the action, if it’s a field/page and the name of the event?

Regards,
Elton S

I don’t have a specific place they are not working. I have tried to set certain variables such as UserKey and RunKey on the client, and the report did not work. then I learned that I must set them on the server so the report generator will properly have them.

I just want some clarity on scope of variables. I’m told that variables defined on client won’t be available on the server. Is this also true vice-versa? Will variables defined on the server be available on the client?

There is not much detail on this in the documentation. Sometimes client-defined variables never show up in the inspector.

Hi Ron,

In case this issue is related to this one: Email Reports to Specific People - How do I? - Five | Community Forum, I just wanted to let you know that I’ve already flagged a separate internal issue with our development team. It doesn’t appear to be related to the report itself or Five Variables.

However, this issue seems to affect the report generation.

Thanks so much for your understanding!

Regards,
Elton S