# Can't refresh an index pattern through my plugin

**URL:** <https://discuss.elastic.co/t/cant-refresh-an-index-pattern-through-my-plugin/65634>\
**Category:** Kibana\
**Created:** [November 10, 2016, 10:37am UTC](https://discuss.elastic.co/t/cant-refresh-an-index-pattern-through-my-plugin/65634 "2016-11-10T10:37:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![pdesoyres](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pdesoyres/32/509_2.png) [@pdesoyres](https://discuss.elastic.co/u/pdesoyres)\
**Post date:** [November 10, 2016, 10:37am UTC](https://discuss.elastic.co/t/cant-refresh-an-index-pattern-through-my-plugin/65634/1 "2016-11-10T10:37:10Z")

</div>

Hi,

I am developping a kibana plugin which, at some point, needs to refresh the fields of a specific index pattern.

I'm using the following code:

```
import uiModules from 'ui/modules';
import 'ui/courier';

var app = uiModules.get('app/myApp', ['kibana/courier']);
app.controller('myCtrl', function($scope, courier) {
    let indexPattern = courier.indexPatterns.get('myIndexPattern-*');
    indexPattern.refreshFields();
});

```

But, I'm getting the following error:

```
angular.js:12477 TypeError: FieldFormat is not a constructor
    at IndexedArray.<anonymous> (http://localhost:5601/bundles/myApp.bundle.js?v=8467:71840:15)
    at IndexedArray.memoized [as getDefaultInstance] (http://localhost:5601/bundles/commons.bundle.js?v=8467:8156:28)
    at new IndexPattern (http://localhost:5601/bundles/myApp.bundle.js?v=8467:71386:90)
    at Object.IndexPatternsProvider.self.make (http://localhost:5601/bundles/myApp.bundle.js?v=8467:71072:13)
    at Object.IndexPatternsProvider.self.get (http://localhost:5601/bundles/myApp.bundle.js?v=8467:71068:48)

```

Indeed, when I debug application, I can see that the property `fieldformats` is empty in `_index_patterns.js`. This makes the `fieldFormats.getDefaultInstance()` method fail : At line 79 of `field_formats.js`, the code `let FieldFormat = self.byId[conf.id];` returns `Undefined`.

Do I miss something in order to use indexPatterns in my plugin ?

_I use Kibana 5.x branch_

---

<div class="post-metadata">

**Author:** ![spalger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spalger/32/14092_2.png) [@spalger](https://discuss.elastic.co/u/spalger)\
**Post date:** [November 11, 2016, 10:00pm UTC](https://discuss.elastic.co/t/cant-refresh-an-index-pattern-through-my-plugin/65634/2 "2016-11-11T22:00:26Z")

</div>

You probably just need to include the default field formatters:

```auto
import 'ui/stringify/register';

```

---

<div class="post-metadata">

**Author:** ![pdesoyres](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pdesoyres/32/509_2.png) [@pdesoyres](https://discuss.elastic.co/u/pdesoyres)\
**Post date:** [November 14, 2016, 8:03am UTC](https://discuss.elastic.co/t/cant-refresh-an-index-pattern-through-my-plugin/65634/3 "2016-11-14T08:03:14Z")

</div>

You're right, it works with this import.

Thank you.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [December 12, 2016, 8:03am UTC](https://discuss.elastic.co/t/cant-refresh-an-index-pattern-through-my-plugin/65634/4 "2016-12-12T08:03:24Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
