# AWM. Lookup fields

**URL:** <https://forum.xwiki.org/t/awm-lookup-fields/4264>\
**Category:** Help / Discuss\
**Created:** [January 22, 2019, 1:49pm UTC](https://forum.xwiki.org/t/awm-lookup-fields/4264 "2019-01-22T13:49:08Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rostyslav\_Fitsyk](https://forum.xwiki.org/user_avatar/forum.xwiki.org/rostyslav_fitsyk/32/1427_2.png) [@Rostyslav\_Fitsyk](https://forum.xwiki.org/u/Rostyslav_Fitsyk)\
**Post date:** [January 22, 2019, 1:49pm UTC](https://forum.xwiki.org/t/awm-lookup-fields/4264/1 "2019-01-22T13:49:08Z")

</div>

Hi!

I try to implement the following: generate a list of values ​​of the Database List, based on the data of another AWM.

Source class:  
## SoftwareInventory.Code.SoftwareInventoryClass  
## Code (code: String)  
## Desc (desc: String)

Hibernate Query field filled by this query:  
`select doc.fullName from XWikiDocument as doc, BaseObject as obj where doc.fullName=obj.name and obj.className='SoftwareInventory.Code.SoftwareInventoryClass' and doc.fullName not like '%Template'`

However, the result differs from the expected: instead of  
`<FieldValue>`  
i see  
`SoftwareInventory.<FieldValue>.WebHome`

![image](https://discourse.xwiki.org/uploads/default/original/2X/7/71beea78f6d47e2ef2573d66f6144e9c0fbbdba1.png)

How do I write a query to display only the field value without prefixes and suffixes?  
How do I specify the list of fields to display?

---

<div class="post-metadata">

**Author:** ![Rostyslav\_Fitsyk](https://forum.xwiki.org/user_avatar/forum.xwiki.org/rostyslav_fitsyk/32/1427_2.png) [@Rostyslav\_Fitsyk](https://forum.xwiki.org/u/Rostyslav_Fitsyk)\
**Post date:** [January 22, 2019, 2:17pm UTC](https://forum.xwiki.org/t/awm-lookup-fields/4264/2 "2019-01-22T14:17:20Z")

</div>

upd:  
Way 2:

![image](https://discourse.xwiki.org/uploads/default/original/2X/4/4dfb2eea9525cb904dfaca670ae7f2d1518e68bb.png)  
 ![image](https://discourse.xwiki.org/uploads/default/original/2X/3/3333e48423fcc895227ecc506ebb8eaeca54e59b.png)  
 ![image](https://discourse.xwiki.org/uploads/default/original/2X/f/fbe567bce7571184f7f7717597c927d9db38b467.png)

---

<div class="post-metadata">

**Author:** ![Rostyslav\_Fitsyk](https://forum.xwiki.org/user_avatar/forum.xwiki.org/rostyslav_fitsyk/32/1427_2.png) [@Rostyslav\_Fitsyk](https://forum.xwiki.org/u/Rostyslav_Fitsyk)\
**Post date:** [January 23, 2019, 9:01am UTC](https://forum.xwiki.org/t/awm-lookup-fields/4264/3 "2019-01-23T09:01:38Z")

</div>

Hi to all!

Somewhat clarify a little: the value I specified in the screenshot occurs due to violation of the integrity of data between tables in two cases:

1. Edit the field that has the deactivated **Relational Storage** option;
2. Delete the entry from the source table.

Case 1 is easy to process: **Relational Storage** must always be enabled.  
Case 2 is more complicated. Actually, the question is:  
_how to implement Reference Constraint (as in RDBMS), which would handle the attempts to delete the data that are linked in other pages / tables / documents?_

Thanks.

---

<div class="post-metadata">

**Author:** ![Rostyslav\_Fitsyk](https://forum.xwiki.org/user_avatar/forum.xwiki.org/rostyslav_fitsyk/32/1427_2.png) [@Rostyslav\_Fitsyk](https://forum.xwiki.org/u/Rostyslav_Fitsyk)\
**Post date:** [January 27, 2019, 2:44pm UTC](https://forum.xwiki.org/t/awm-lookup-fields/4264/4 "2019-01-27T14:44:18Z")

</div>

Hi!

Another case:  
AWM - Application Within Minute.

- In AWM 2 create a record (DB LIST field type), which refers to the data in AWM 1.
- In AWM 1 remove the data.
- In AWM 2 they are still present in lookup.

When I start the HQL selec manually - there is no data, everything is ok:

```
select concat(' [', softName.value, ' ', softVersion.value, '] ') 
from
     XWikiDocument as doc,
     BaseObject obj,
     StringProperty softName,
     StringProperty softVersion
 where doc.fullName=obj.name and
     obj.className='SoftwareInventory.Code.SoftwareInventoryClass' and
     softName.id.id=obj.id and softName.name='softName' and
     softVersion.id.id=obj.id and softVersion.name='softVersion' and
     doc.fullName not like '%Template'

```

How to remove them?  
How to implement integrity checking?  
How to add a Clear Field button?

Thanks.

---

<div class="post-metadata">

**Author:** ![Rostyslav\_Fitsyk](https://forum.xwiki.org/user_avatar/forum.xwiki.org/rostyslav_fitsyk/32/1427_2.png) [@Rostyslav\_Fitsyk](https://forum.xwiki.org/u/Rostyslav_Fitsyk)\
**Post date:** [February 4, 2019, 7:55am UTC](https://forum.xwiki.org/t/awm-lookup-fields/4264/5 "2019-02-04T07:55:45Z")

</div>

Hi!

The problem is solved: for correct operation it is necessary that the request return the unique key field (what I did not do) and the value field. I added a key field and everything worked fine.  
Next, also need to implement the correct autogeneration of the unique ID using [UIN Script Service](https://extensions.xwiki.org/xwiki/bin/view/Extension/UIN%20Script%20Service)  
but that’s the next story 🙂
