# OpenUI - how to save data from extension to CMS

**URL:** <https://community.bloomreach.com/t/openui-how-to-save-data-from-extension-to-cms/1332>\
**Category:** Experience Manager (PaaS/OnPrem)\
**Created:** [August 9, 2019, 9:13am UTC](https://community.bloomreach.com/t/openui-how-to-save-data-from-extension-to-cms/1332 "2019-08-09T09:13:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Flavio\_Ricci](https://yyz1.discourse-cdn.com/flex027/user_avatar/community.bloomreach.com/flavio_ricci/32/256_2.png) [@Flavio\_Ricci](https://community.bloomreach.com/u/Flavio_Ricci)\
**Post date:** [August 9, 2019, 9:13am UTC](https://community.bloomreach.com/t/openui-how-to-save-data-from-extension-to-cms/1332/1 "2019-08-09T09:13:19Z")

</div>

Hi,

I have implemented a OpenUI extension in order to include an autocomplete input text in an iframe as described in the documentation.  
The autocomplete feature is working fine and I have successfully included in a document type in the CMS but I miss the last step: how can I pass the value stored in the iframe input text to the CMS document editor page?

Thanks,

Flavio

---

<div class="post-metadata">

**Author:** ![mathijs](https://yyz1.discourse-cdn.com/flex027/user_avatar/community.bloomreach.com/mathijs/32/26_2.png) [@mathijs](https://community.bloomreach.com/u/mathijs)\
**Post date:** [August 9, 2019, 9:38am UTC](https://community.bloomreach.com/t/openui-how-to-save-data-from-extension-to-cms/1332/2 "2019-08-09T09:38:57Z")

</div>

Hi Flavio,

Storing a string value back into the current field can be done with

ui.document.field.setValue(value)

See [https://documentation.bloomreach.com/library/concepts/open-ui/develop-a-document-field-extension.html](https://documentation.bloomreach.com/library/concepts/open-ui/develop-a-document-field-extension.html) for more details.

best,

Mathijs

---

<div class="post-metadata">

**Author:** ![Flavio\_Ricci](https://yyz1.discourse-cdn.com/flex027/user_avatar/community.bloomreach.com/flavio_ricci/32/256_2.png) [@Flavio\_Ricci](https://community.bloomreach.com/u/Flavio_Ricci)\
**Post date:** [August 9, 2019, 10:47am UTC](https://community.bloomreach.com/t/openui-how-to-save-data-from-extension-to-cms/1332/3 "2019-08-09T10:47:46Z")

</div>

> [@mathijs](#):
>
> Mathijs

Thank you Mathijs,

do you know or could you please link a doc page about how to get that value in the CMS editor page and how to grab that value when the user clicks on “save”?  
Thanks!

---

<div class="post-metadata">

**Author:** ![mathijs](https://yyz1.discourse-cdn.com/flex027/user_avatar/community.bloomreach.com/mathijs/32/26_2.png) [@mathijs](https://community.bloomreach.com/u/mathijs)\
**Post date:** [August 9, 2019, 11:18am UTC](https://community.bloomreach.com/t/openui-how-to-save-data-from-extension-to-cms/1332/4 "2019-08-09T11:18:59Z")

</div>

Getting the current field value can be done with

ui.document.field.getValue()

The documentation page in my previous reply ([https://documentation.bloomreach.com/library/concepts/open-ui/develop-a-document-field-extension.html](https://documentation.bloomreach.com/library/concepts/open-ui/develop-a-document-field-extension.html)) contains a full code example at the bottom. The example is in vanilla HTML + JS, but you can use any framework you like if you want (Angular, React, Vue, …). The @bloomreach/ui-extension library ships in various module formats.

The basic idea is to first register your UI extension with UiExtension.register(), which resolves with a ‘ui’ object that provides all API to interact with the CMS. Note that all API methods return a Promise, so you have to wait for the result (e.g. either do ui.document.field.getValue().then(value =\> doSomethingWith(value)) or use async-await like in the example code).

Once registered, you get get the current field value (ui.document.field.getValue()), provide a UI to change it, and in some callback set the changed field value (ui.document.field.setValue(newValue)) .

Note that this is all independent of the “Save” button in the surrounding document editor. A UI extension cannot know whether a user clicked “save”. Calling setValue() will persist the new value in the draft variant of the document (or more accurately, use a throttle of 2 seconds before persisting the latest change in the draft variant). Clicking “Save” will copy all draft values in a document to the preview variant, so other (concurrent) CMS users can see the changes too.

hth,

Mathijs

---

<div class="post-metadata">

**Author:** ![Flavio\_Ricci](https://yyz1.discourse-cdn.com/flex027/user_avatar/community.bloomreach.com/flavio_ricci/32/256_2.png) [@Flavio\_Ricci](https://community.bloomreach.com/u/Flavio_Ricci)\
**Post date:** [August 9, 2019, 1:05pm UTC](https://community.bloomreach.com/t/openui-how-to-save-data-from-extension-to-cms/1332/5 "2019-08-09T13:05:35Z")

</div>

> [@mathijs](#):
>
> is all independent of the “Save” button in the surrounding document editor. A UI extension cannot know whether a user clicked “save”. Calling setValue() will persist the new value in the draft variant of the document (or more accurately, use a throttle of 2 seconds before persisting the latest change in the draft variant). Clicking “Sav

OK thanks Mathijs,  
what I was concerned about is how data are stored in JCR; I saw that the value is stored by default as :openuistring by default but this can configured in the CMS field editor

Thank you for your help!
