CA Service Management

 View Only
  • 1.  How to add/use persistent_id to custom created table?

    Posted May 13, 2016 03:56 AM

    Hello community,

    as we know custom created table automatically generates defualt attributes like id, last_mod_dt, etc... also it generates persistent_id which exists as derived (virtual) attribute.

    There is no problem to use it with OOTB factories, where I can build query like : "persistent_id = 'cr:12345'", but when I try to make same query for custom table it fails with error (via web or spel):

    search_with_where: sync_fetch  failed: AHD03053: invalid constraint.  Could not recognize persistent_id. ((persistent_id = 'z_custom_table:400001'))

    My current workaround is to publish custom attribute which will store persid and will be generated on object creation.

    Any ideas?

    --

    Regards,

    Timur



  • 2.  Re: How to add/use persistent_id to custom created table?

    Posted May 13, 2016 07:56 AM

    Hi Timur,

    There is code in place for certain out of the box local attributes to allow for referencing the local attribute via certain queries.  However, that code wont exist for any custom ones that you create.  For custom attributes, I would recommend NOT doing a local attribute, but rather as you said, have it stored in the database as a custom column, so that it can be referenced by standard queries.  Thats probably the best way to handle this situation.

    Thanks,
    Jon I.



  • 3.  Re: How to add/use persistent_id to custom created table?
    Best Answer

    Posted May 13, 2016 11:06 AM

    Thank you for your reply Jon,

    I agreed with your recommendation and used custom column to store persid.

     

    But inner need to play with fire forced me to try to use attribute reference like it released in OOTB maj files, I have specified maj file with followed code:

    OBJECT z_custom_table {
      ATTRIBUTES z_custom_table {
      persistent_id persid STRING ;
      };
    };
    

    this also works fine, new objects have their persids that could be reached by persistent_id attribute and being stored in persid column on DB level.

     

    Have a nice weekend!

     

    Regards,

    Timur



  • 4.  Re: How to add/use persistent_id to custom created table?

    Posted Aug 03, 2016 04:59 PM

    FYI,  if you think about this while creating your custom table, instead of catching it after the fact, while going through Web Screen Painter "Add Column" persistent_id and it'll create the field in SQL to store the value and work as you would expect.  Just make sure the string length is large enough for the table name, the colon and 6 digits.

     

    Ex.

    I created a table called zClinical_Service_Lines, and created the persistent_id field as a string 30 field.

     

    After publication, instead of the persistent_id field showing up in the Schema designer as "N/A: Exists only in Object Engine" it displays as you would have hoped.  And when I add entries to it, the values are stored like this:

     

    zClinical_Service_Lines:400003

     

    Any smaller than 30 characters and that wouldn't have fit.  So may be wise to go larger to be safe.