Read-only fields in BE temp-table
 
Forums / SmartComponent Library - Developer Forum / Read-only fields in BE temp-table

Read-only fields in BE temp-table

5 posts, 2 answered
  1. Patrik Wikström
    Patrik Wikström avatar
    68 posts
    Registered:
    15 Oct 2018
    20 Aug 2019
    Link to this post
    Is it possible to define a field in a BE as read-only. In our case I would like to have one temp-table with 2 source tables and all the fields in the second source table would be handled as read-only by the service. The first table is actually a general "link" table between records but it doesn't affect this question. I can achieve this for example using 2 temp-tables (one for each source table) or using calculated fields but is there more ways to solve this? The first table is regular maintenance table (CRUD), the second one is just for joining read-only data for the user interface. Hope this question is clear enough!?
  2. Patrik Wikström
    Patrik Wikström avatar
    68 posts
    Registered:
    15 Oct 2018
    20 Aug 2019 in reply to Patrik Wikström
    Link to this post
    Hmm, how is the Validation Settings working, under Field Properties? You can set Read Only but does it work as we expect it to do?
  3. Mike Fechner
    Mike Fechner avatar
    319 posts
    Registered:
    14 Sep 2016
    Answered
    20 Aug 2019 in reply to Patrik Wikström
    Link to this post
    OpenEdge does not support read-only fields in temp-tables. So you have to implement this as part of validation. 

    DatasetModel's however support fields with PROTECTED (or PRIVATE) get, so that offers more obvious rules to developers. 

    I'm not sure, if the Business Entity Designer setting for ReadOnly validation does what you want as you did not share your requirements with us. But it generates code for the Validate:ReadOny or ValidationHelper:ReadOnly in the ValidateData Method.

    Alternative if you've got annotations working, use this here:

    @BusinessEntityTable (name="eOrder", performValidation="false", readonlyColumns="ordernum") .

  4. Patrik Wikström
    Patrik Wikström avatar
    68 posts
    Registered:
    15 Oct 2018
    21 Aug 2019 in reply to Mike Fechner
    Link to this post
    Thanks Mike!
    We now use both the PROTECTED for read-only fields and the Validation Settings Read Only setting. Quick idea: Could be nice to have the PROTECTED/PRIVATE switch controlling also the validation in the business entity but might cause some logical challenges because those things aren't exactly the same? :)
  5. Mike Fechner
    Mike Fechner avatar
    319 posts
    Registered:
    14 Sep 2016
    Answered
    21 Aug 2019
    Link to this post
    We are keeping that flexible on purpose. 

    If you want to cause a dependency between those settings, I suggest you implement a plugin to the Business Entity Designer and update the fields in the dsBusinessEntity Dataset in the BeforeGenerate event there.
5 posts, 2 answered