# User Custom Field - Order

**URL:** <https://community.dreamfactory.com/t/user-custom-field-order/1196>\
**Category:** REST API\
**Created:** [June 18, 2015, 11:59am UTC](https://community.dreamfactory.com/t/user-custom-field-order/1196 "2015-06-18T11:59:58Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Serkan](https://avatars.discourse-cdn.com/v4/letter/s/b5ac83/32.png) [@Serkan](https://community.dreamfactory.com/u/Serkan)\
**Post date:** [June 18, 2015, 11:59am UTC](https://community.dreamfactory.com/t/user-custom-field-order/1196/1 "2015-06-18T11:59:59Z")

</div>

Hello,

We can store datas in “user\_data” column for users. It is in JSON format. In “user\_data” column, there are sub field like score,age,weight,height… But when i want to call system/user api to list the users, how can i order them according to their “scores” in “user\_data”?

Is there a function for JSON parsing or something else?

Thanks,

---

<div class="post-metadata">

**Author:** ![jeffreystables](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/jeffreystables/32/173_2.png) [@jeffreystables](https://community.dreamfactory.com/u/jeffreystables)\
**Post date:** [June 23, 2015, 12:35pm UTC](https://community.dreamfactory.com/t/user-custom-field-order/1196/2 "2015-06-23T12:35:31Z")

</div>

I believe this would need to be accomplished client-side rather than in the query. You could receive the JSON, then sort it in your app, then present it to the user.

---

<div class="post-metadata">

**Author:** ![jeffreystables](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/jeffreystables/32/173_2.png) [@jeffreystables](https://community.dreamfactory.com/u/jeffreystables)\
**Post date:** [June 23, 2015, 5:27pm UTC](https://community.dreamfactory.com/t/user-custom-field-order/1196/3 "2015-06-23T17:27:52Z")

</div>

Alternatively, if you are able to store the data in any other table, you could simply store your additional user data in the separate table and query it as related data with an ownerId field in the extra table.

---

<div class="post-metadata">

**Author:** ![Serkan](https://avatars.discourse-cdn.com/v4/letter/s/b5ac83/32.png) [@Serkan](https://community.dreamfactory.com/u/Serkan)\
**Post date:** [June 25, 2015, 11:38am UTC](https://community.dreamfactory.com/t/user-custom-field-order/1196/4 "2015-06-25T11:38:11Z")

</div>

Hello Jeffrey, that is what i want exactly. I created another table for additional user data. I created a relation from phpmyadmin with the df\_sys\_user id field and other my custom table id. But in live api, i couldn’t get the data. Do you have any idea?

---

<div class="post-metadata">

**Author:** ![jeffreystables](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/jeffreystables/32/173_2.png) [@jeffreystables](https://community.dreamfactory.com/u/jeffreystables)\
**Post date:** [June 25, 2015, 5:59pm UTC](https://community.dreamfactory.com/t/user-custom-field-order/1196/5 "2015-06-25T17:59:52Z")

</div>

Could you post the API call you’re making and the result/error that was returned?

---

<div class="post-metadata">

**Author:** ![Serkan](https://avatars.discourse-cdn.com/v4/letter/s/b5ac83/32.png) [@Serkan](https://community.dreamfactory.com/u/Serkan)\
**Post date:** [June 26, 2015, 8:58am UTC](https://community.dreamfactory.com/t/user-custom-field-order/1196/6 "2015-06-26T08:58:04Z")

</div>

I am making a call from system/user api endpoint to get the users table and related table.

---

<div class="post-metadata">

**Author:** ![Serkan](https://avatars.discourse-cdn.com/v4/letter/s/b5ac83/32.png) [@Serkan](https://community.dreamfactory.com/u/Serkan)\
**Post date:** [June 26, 2015, 9:08am UTC](https://community.dreamfactory.com/t/user-custom-field-order/1196/7 "2015-06-26T09:08:05Z")

</div>

Also i get this error in phpmyadmin when i want to create a relationship with the custom table’s foreign key with df\_system\_user’ id field.

#1452 - Cannot add or update a child row: a foreign key constraint fails (`bitnami_dreamfactory`.`#sql-9c9_2cb2`, CONSTRAINT `#sql-9c9_2cb2_ibfk_2` FOREIGN KEY (`ownerid`) REFERENCES `df_sys_user` (`id`))

---

<div class="post-metadata">

**Author:** ![jeffreystables](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/jeffreystables/32/173_2.png) [@jeffreystables](https://community.dreamfactory.com/u/jeffreystables)\
**Post date:** [June 29, 2015, 4:47pm UTC](https://community.dreamfactory.com/t/user-custom-field-order/1196/8 "2015-06-29T16:47:56Z")

</div>

I will attempt to get an example mocked up for you of how to accomplish this.

---

<div class="post-metadata">

**Author:** ![Serkan](https://avatars.discourse-cdn.com/v4/letter/s/b5ac83/32.png) [@Serkan](https://community.dreamfactory.com/u/Serkan)\
**Post date:** [June 29, 2015, 5:19pm UTC](https://community.dreamfactory.com/t/user-custom-field-order/1196/9 "2015-06-29T17:19:00Z")

</div>

I will be waiting for it. Thank you so much jeffrey.

---

<div class="post-metadata">

**Author:** ![jeffreystables](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.dreamfactory.com/jeffreystables/32/173_2.png) [@jeffreystables](https://community.dreamfactory.com/u/jeffreystables)\
**Post date:** [July 8, 2015, 3:21pm UTC](https://community.dreamfactory.com/t/user-custom-field-order/1196/10 "2015-07-08T15:21:06Z")

</div>

I have confirmed that, for security, relationship queries with user data are not supported. We are looking into a way to simulate a related data call to the user table with server-side scripts. Of course you’re welcome to investigate this as well.

My thought is that a post-process script on the user table call could also call the additional table and concatenate the response from that table, then sort. What do you think?

---

<div class="post-metadata">

**Author:** ![abhinavg](https://avatars.discourse-cdn.com/v4/letter/a/c2a13f/32.png) [@abhinavg](https://community.dreamfactory.com/u/abhinavg)\
**Post date:** [December 16, 2016, 2:40am UTC](https://community.dreamfactory.com/t/user-custom-field-order/1196/11 "2016-12-16T02:40:09Z")

</div>

Is it something that can be done(in latest dreamfactory versions 2.3 or 2.4) to create a separate table (in mysql for example) containing a owner\_id field which is a foreign key to user\_id in user table - by virtual foreign key(I tried but didnt see the user table available in schema tab) or something similar.

I am working on a project which require many fields for a user, and these fields should be created/read/edited by another user via rest api.

Any ideas?
