Web Apps – Using the Console to see data in the grid

Dynamics SL Web Apps is an MVC solution. In order to develop or troubleshoot, you will need to learn how to debug. I debug Controller code using Visual Studio, but today I’ll show you some of the more commonly used grid-related functions in Web Apps Javascript code. We’ll get into adding breakpoints and stepping through JavaScript code in a later post.

Javascript debugging takes place in your browser window and I prefer to work in Chrome. Their developer tools are the best I have seen.

To get started, load your Web Apps website in Chrome. Click your F12 key to open developer tools, load your timecard page and select a row. Click over to the ‘Console’

We’ll explore 4 very commonly used functions throughout Web Apps, so you get an idea of what they do.

  1. GetGrid() – just provide the grid name and this will get all the data in the grid and allow you to run some of the following functions.
  2. GetActiveRow() – this gets the active Row of the grid you define; this is often followed by an if test to see if the active row is null because when the grid loses focus, the active row is now considered ‘Last Active Row’ and there is no ‘Active Row’
  3. GetLastActiveRow() – this gets the Last Active Row of whatever grid you defined
  4. GetCellDataAsObject() – this gets the data of a particular grid row as an object. In the way we are using it in the below video, it gets the data of the last active row in the Timecard grid.

We’ll manually run some of the OnDetailNotes() function to see what they are testing and doing. 

First we define a variable ‘grid’ and use GetGrid(). Then we define a variable activeRow and use the variable ‘grid’ along with the function GetActiveRow() As you can see, there is no active row, so it returns null.  If the active row is null, then we again use the variable ‘grid’ with the function GetLastActiveRow()

Web Apps GetGrid() GetActiveRow() GetLastActiveRow() function

I went ahead and showed how you can use GetCellDataAsObject() because I think that’s a very handy tool when debugging.  It helps to see if you have the correct data to pass to the Controller.  The video below shows the above in action: 

Feel free to share...

Leave a Reply

Close Menu