Handling Nullable Tables in Telerik

Handling Nullable Tables in Telerik

Fast-Weigh GraphQL & REST APIs

 
To add the API module to your Fast-Weigh subscription, contact us at 865-219-2980 or support@tacinsight.com.

Sometimes, you may have a table linked in your GraphQL query that can be set or completely blank depending on the parent table it is connected to.

A good example of this would be if you wanted to show the Order Salesperson Name, which might not always be set on the Order. When you query this in GraphQL, it can return in two ways:

While the way this data is returned may be fine in the JSON view, it can cause some major problems in Telerik. This is because you end up trying to call a field object that either exists and returns correctly or doesn't exist at all:

=Fields.Order.Salesperson.Name

When you add the Salesperson Name field to the report like normally and then run the report, the Orders that do not have a salesperson will show you the following error in place of where the name would be:

"An error has occurred while processing TextBox 'textBox2': The expression contains object 'Name' that is not defined in the current context."



If you do receive this error for the Salesperson Name field (or any other field), there is a workaround you can use to display the name when it is set or hide the object entirely when it is blank.

  1. Navigate to the Insert tab at the top of the Report Designer.
  2. Inset a List from the Tables section.
  3. Select the new List object, and navigate to the Properties Panel on the bottom-right.
  4. Find the Data section of the Properties.
  5. Click on the "..." button to edit the Bindings.

  6. Add a new Binding.
    1. Set the Property Path to "DataSource"
    2. The Expression needs to be the parent of the field you are wanting to display. In this case, we want to see = Fields.Order.Salesperson.Name so we will set the Expression to
      = Fields.Order.Salesperson
    3. Click OK to save the Bindings



  7. Click inside of the new List object, add in new text boxes for the field title and the field itself, and set up their formating


  8. In the field where you want to show the salesperson name, you only need to add the second half of the expression we referenced for the DataSource = Fields.Order.Salesperson.Name
    1. In this case, we only need to input = Fields.Name to get the Salesperson Name.


  9. Lastly, make sure to preview the report for both fields that should have a Salesperson and should be blank to make sure everything functions as expected.



  10. In my example, including the field title in the list ensured that it was hidden entirely when there was no salesperson set, but you can keep the title outside of the list to prevent this.


    1. If you do not want the field to be entirely blank, you can set a "NoDataMessage" and "NoDataStyle" in the Properties Panel 




    • Related Articles

    • Helpful Telerik Links

      Fast-Weigh GraphQL & REST APIs To add the API module to your Fast-Weigh subscription, contact us at 865-219-2980 or support@tacinsight.com. Telerik Support Page Telerik Designing Reports Knowledge Base Telerik Reporting Forum Getting Started with ...
    • Telerik Report Formatting

      Fast-Weigh GraphQL & REST APIs To add the API module to your Fast-Weigh subscription, contact us at 865-219-2980 or support@tacinsight.com. Here are some additional walkthrough videos on tools you can use within Telerik to Style your reports ...
    • Using Telerik Report Parameters

      Fast-Weigh GraphQL & REST APIs To add the API module to your Fast-Weigh subscription, contact us at 865-219-2980 or support@tacinsight.com. Required Parameters When building your reports within Telerik, you have the ability to link your GraphQL Where ...
    • Connecting GraphQL to Telerik Report Designer

      Fast-Weigh GraphQL & REST APIs To add the API module to your Fast-Weigh subscription, contact us at 865-219-2980 or support@tacinsight.com. Note: Make sure you are running Telerik Report Designer version 14.0.20.219 or later. Navigate to the Data tab ...
    • Connecting Power BI to GraphQL

      Fast-Weigh GraphQL & REST APIs To add the API module to your Fast-Weigh subscription, contact us at 865-219-2980 or support@tacinsight.com . GraphQL can be connected into Power BI to visualize your data. In order to connect it up, you will need to be ...