Error Log - Common Errors Exercise
Error Log - Common Errors Exercise
What to do next?
7. Investigate it: Open Service Center and search for your application's errors:
a. Click the gear in Service Studio
b. When the Service Center application opens in the browser, log in with your IT user if
required.
c. Click Monitoring and then Errors.
d. Filter the search by your Application name.
e. You should see the error log as in the image below.
8. Analyze it: Open the Detail of the error and analyze the information:
a. If you look at the Stack section, you will notice some hints that you can follow to find
the cause of the error.
[OUTSYSTEMS].DBO.[OSUSR_53I_CUSTOMER] with key 0 was not found
at ssCustomerOrders.Functions.ssGetCustomer(HeContext heContext,
Int64 inParamId)
at ssCustomerOrders.Flows.FlowMainFlow.ScrnOrders.expression3()
at System.Web.UI.Control.OnDataBinding(EventArgs e)
at System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding)
at OutSystems.HubEdition.WebWidgets.PlaceHolder.DataBindChildren()
at System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding)
at OutSystems.HubEdition.WebWidgets.PlaceHolder.DataBind()
at OutSystems.HubEdition.WebWidgets.OSDataGridTableCell.
DataBindChildren()
at System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding)
at OutSystems.HubEdition.WebWidgets.OSDataGridTableCell.DataBind()
at OutSystems.HubEdition.WebWidgets.OSDataGridItem.DataBindChildren()
at System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding)
PagedDataSource pagedDataSource)
at ...
9. Understand it: The error should be in your Orders module, in the Orders screen, in the
Orders Table, in the last column cell inside the expression.
So, we have that GetCustomer() function in the Orders screen.
Well, it seems that the foreign key RequestedBy in the Orders entity is not mandatory,
and that means that there may be Order records that have a Null Identifier as the
attribute's value. So, when using the GetCustomer() function to find a record that does
not exist, the database raises an exception, and all of this occurs.
Great! You found it and understood it! Now you just need to fix it!
10. Know your options: the first step in fixing errors is knowing what your options are, and
that is something that will come easier with experience, we promise. To guide you, we will
present you with two common approaches:
a. Make sure the function GetCustomer() is not called when its Customer Identifier input
does not exist in the database, in this case, that is not a Null Identifier
OR
b. Since it is called in a table row and there is an existing database relationship between
the entities Order and Customer fetch the information in the query that sources the
table instead of calling the GetCustomer() function.
Note: The best approach, in this case, would be option b. When you use the
GetCustomer() function inside of a table records, there is a call to the database for
each record of that list.
So if we can fetch the information inside of the aggregate that sources the table, we
only have one call to the database and avoid harming the performance by having
multiple calls to the database in that table.
a.
b.
Part II - Unexpected Feedback Messages
1. In the browser, go to the Orders screen (of the Orders application you cloned in the
exercise above) and open the detail of an Order.
2. Click the New Order Product, fill in the fields, and click save. What happens?
3. Follow the same approach as earlier: Investigate, Analyse, Follow the hints, Understand,
Know your options and Fix the error.
4. Solve the error: In Service Center, as we read the stack trace, we see that the problem is
the attribute OrderId, a foreign key in the OrderProduct entity. So let's look at the entity.
The attribute OrderId exists in the entity and is set as mandatory. What happens when we
try to create a new record in the database without providing existing identifiers for all the
mandatory foreign keys?
b. Again, in the browser, click the New Order Product link, fill in the details and click the
Save button.
It is possible to see that the exception raised where Service Center showed it did. And
we do have the order attribute with a value that does not exist in the Orders entity.
Hence the unexpected feedback message.
b. After that, in the flow of the Save screen action, the value must be assigned to the
source of the CreateOrUpdateOrderProduct action.
7. Publish it and test it. You should already be able to add new products to an order.