question

mobiledev avatar image
mobiledev asked mobiledev commented

Clover android sdk object's custom fields

Is there any way to set user defined / custom properties to any clover's android sdk objects. For example :

Order has its own properties such as id, note, title, etc. Now I have some other undefined fields I would like to associate with order object such as orderStartTime, orderStoreName, orderType etc. Any way like key-value pair ?

2 comments
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

mobiledev avatar image mobiledev commented ·

I have one finding on above question. All the objects in android sdk has JSON representation and gives JSONObject with its getter method. I believe that JSONObject is reference and we can update it as well as add our own values. I tried it with an experiment on Discount object and found it working. Whatever I store in JSONObject of Discount I get it back when retrieved.

I would like to know If this approach is right and recommended.

0 Likes 0 ·
Jeffrey Blattman avatar image Jeffrey Blattman ♦♦ commented ·

No it's no possible as noted below, and it'd be undesirable since every application that used orders would be forced to send and receive the extra fields that only your app cares about. The correct may to implement this is to keep your own meta data mapping from order ID to meta data.

0 Likes 0 ·

1 Answer

anthonypinto avatar image
anthonypinto answered

The short answer is no, this is not supported. While it is possible to modify your own code, and your local copy of the APK to allow for additional fields on the Java models our platform uses, these changes would not translate into something that would persist meaningfully on the platform.

Clover doesn't allow customization of our actual object schemas, which means that our databases are only ever going to store the attributes we have defined for our models. Because this use-case is not supported, the local APIs may pass objects along with your additions, or may at times strip them from passed objects - no promises.

Any custom state that you actually need to persist will rely on your own database (or equivalent).

10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Welcome to the
Clover Developer Community