# Clear various tables with single function

**URL:** <https://community.viktor.ai/t/clear-various-tables-with-single-function/113>\
**Category:** Need help? Ask here!\
**Created:** [14 October 2021 07:38 UTC](https://community.viktor.ai/t/clear-various-tables-with-single-function/113 "2021-10-14T07:38:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bart.vosslamber](https://community.viktor.ai/letter_avatar_proxy/v4/letter/b/3e96dc/32.png) [@bart.vosslamber](https://community.viktor.ai/u/bart.vosslamber)\
**Post date:** [14 October 2021 07:38 UTC](https://community.viktor.ai/t/clear-various-tables-with-single-function/113/1 "2021-10-14T07:38:22Z")

</div>

In an application we use different buttons to clear tables. I’ve tried to simplify the code by separating primary functions and one secondary function, like this:

```auto
    def clear_sls_table(self):
        self.clear_table(limit_state='service_limit_state')

    def clear_uls_table(self):
        self.clear_table(limit_state='ultimate_limit_state')

    def clear_als_table(self):
        self.clear_table(limit_state='accidental_limit_state')

    @staticmethod
    def clear_table(limit_state: str):
        new_params = {
            'load_cases': {
                limit_state: default_columns_load_input_table,
            }
        }
        return ViktorResult(set_parameters_result=SetParametersResult(new_params))

```

I can’t find no fault in the above mentioned code, and the application gives no error in the terminal. However, the tables aren’t cleared and the website gives the following warning:  
 ![image](https://community.viktor.ai/uploads/default/original/1X/e210b103e2d3779166068d6bae9b91b0836627a4.png)

The obvious workaround is to return the `new_params` in the `clear_table` method and to add a `ViktorResult` return in the primary functions, but this way around uses more code lines, so I was wondering why this doesn’t work.

---

<div class="post-metadata">

**Author:** ![rdejonge](https://community.viktor.ai/letter_avatar_proxy/v4/letter/r/ba8739/32.png) [@rdejonge](https://community.viktor.ai/u/rdejonge)\
**Post date:** [14 October 2021 08:09 UTC](https://community.viktor.ai/t/clear-various-tables-with-single-function/113/2 "2021-10-14T08:09:34Z")

</div>

Hi Bart,

Your methods are not returning anything. The following should work:

```python
   def clear_sls_table(self):
        return self.clear_table(limit_state='service_limit_state')

    def clear_uls_table(self):
        return self.clear_table(limit_state='ultimate_limit_state')

    def clear_als_table(self):
        return self.clear_table(limit_state='accidental_limit_state')

    @staticmethod
    def clear_table(limit_state: str):
        new_params = {
            'load_cases': {
                limit_state: default_columns_load_input_table,
            }
        }
        return ViktorResult(set_parameters_result=SetParametersResult(new_params))

```

---

<div class="post-metadata">

**Author:** ![bart.vosslamber](https://community.viktor.ai/letter_avatar_proxy/v4/letter/b/3e96dc/32.png) [@bart.vosslamber](https://community.viktor.ai/u/bart.vosslamber)\
**Post date:** [14 October 2021 08:18 UTC](https://community.viktor.ai/t/clear-various-tables-with-single-function/113/3 "2021-10-14T08:18:19Z")

</div>

Thanks, if you see it, it is obvious 😉
