Clarity

  • 1.  Project ID autonumbering with XOG in GEL

    Posted Aug 28, 2014 09:25 AM

    Hello,

     

    I need to create projects from instances of our custom object and I need them to be autonumbered.

     

    Here on Community I found this thread: https://communities.ca.com/message/14395252#14395252

     

    And I tried solutions written in there:

    Unfortunately the Autonumber tag does not work for the Project. Why? i do not know.

    What i have done in the past is to get the next value from the cmn_autonumbering_schemes table. The issue is that this only gets you the last one, and does not update it for you.

    There is a stored procedure that you can run to get this value as well.

    this is the query that gets you the next id change the object code to project, and partition code to whatever it might be

     

    SELECT next_value

    FROM niku.CMN_AUTONUM_SCHEMES

    WHERE 1=1

    AND object_code = 'project'

    AND attribute_code = 'code'

    AND partition_code = 'NIKU.ROOT'

     

    This is the SP that populates the next value for you in that table (change the partition code if needed)

    CMN_AUTONUM_GET_NEXT_SP 'project','code','NIKU.ROOT','','','',0,get_seq_num

    if you are on Oracle, you could write a function that returns the out value from the SP (this is the safest way to do it).

    Hope this helps.

     

    This query returnes the value of ProjectID but it's still the same.

     

    I also tried to call the procedure, but I was not successful

     

    Please do you have any idea how to solve it?

     

    Regards,

    Martin



  • 2.  Re: Project ID autonumbering with XOG in GEL

    Posted Aug 29, 2014 05:46 AM

    Hi Martin,

     

    Did you try doing the auto-numbering for the Project/Investment ID on the Clarity Studio within the Project object? You will need to search for the Project/Investment ID attribute within the Project object and just set the auto-numbering feature to be 'true'. You can also set a format for this auto-numbering as per your requirement. This is a more easier way of dealing with auto-numbering than the xog. Also, I've doubts if xog allows the auto-numbering feature to become true.

     

    Suhail.



  • 3.  Re: Project ID autonumbering with XOG in GEL

    Posted Aug 31, 2014 04:14 AM

    Hello Suhail,

     

    in Clarity Studio I have got the autonumbering setted as true and also formated, but I wrote, that I need to create projects from custom object instances, that is why I have to use XOG. I am not sure, that you understand why I'm trying to do.

     

    Martin



  • 4.  Re: Project ID autonumbering with XOG in GEL

    Posted Sep 01, 2014 04:57 AM

    Hi Martin,

     

    You can refer the information given below that I came across on the internet.

     

    Clarity: Is there a way to control the way auto-numbered attributes are treated while performing a XOG write?

    Description:
    When XOGing into Clarity, how do we override the auto-numbering scheme if it is enabled for an object attribute in the application?
    Solution:
    In Clarity Version 12.0, the flag 'overrideAutoNumbering' is defined on the XOG header and determines whether source XOG content overrides auto-numbering in target content. The flag is available for the custom attributes of stock and custom objects.
    The following rules apply:
    • If the flag is set to TRUE, XOG content from the source is applied to the target.
    • If the flag is set to FALSE, the auto-numbering scheme defined on the target is applied.
    • The flag is specified in the XOG export file.
    • By default, overrideAutoNumbering=TRUE.

    If the 'overrideAutoNumbering' attribute is set to "true" or omitted from the XOG xml write file, the write action will use the value in the 'instanceCode' or 'code' attribute and not use the Auto-Numbering Scheme.

     

    You can see if this works for the CA Clarity v13 as well. I hope this helps.

     

    Suhail.



  • 5.  Re: Project ID autonumbering with XOG in GEL
    Best Answer

    Posted Sep 01, 2014 06:09 AM

    Hello Suhail,

     

    In your last post there is written "The flag is available for the custom attributes of stock and custom objects." And projectID is not custom attribute so it's not working, that is why I want to use the stored procedure.

     

    This morning I found a solution how to solve this.

     

    In GEL script use:

    <sql:update escapeText="false" var="nrParentFields">

      DECLARE

       P_OBJECT_CODE VARCHAR2(200);

       P_ATTRIBUTE_CODE VARCHAR2(200);

       P_PARTITION_CODE VARCHAR2(200);

       P_TABLE_NAME VARCHAR2(200);

       P_COLUMN_NAME VARCHAR2(200);

       P_PARENT_REFERENCE_ATTR VARCHAR2(200);

       P_PARENT_PK NUMBER;

       P_NEXT_ID VARCHAR2(200);

      BEGIN

       P_OBJECT_CODE := 'project';

       P_ATTRIBUTE_CODE := 'unique_code';

       P_PARTITION_CODE := 'NIKU.ROOT';

       P_TABLE_NAME := 'inv_investments';

       P_COLUMN_NAME := 'code';

       P_PARENT_REFERENCE_ATTR := '';

       P_PARENT_PK := 5000000;

     

     

       CMN_AUTONUM_GET_NEXT_SP(

      P_OBJECT_CODE => P_OBJECT_CODE,

      P_ATTRIBUTE_CODE => P_ATTRIBUTE_CODE,

      P_PARTITION_CODE => P_PARTITION_CODE,

      P_TABLE_NAME => P_TABLE_NAME,

      P_COLUMN_NAME => P_COLUMN_NAME,

      P_PARENT_REFERENCE_ATTR => P_PARENT_REFERENCE_ATTR,

      P_PARENT_PK => P_PARENT_PK,

      P_NEXT_ID => P_NEXT_ID

       );

       /* Legacy output: */

      DBMS_OUTPUT.PUT_LINE('P_NEXT_ID = ' || P_NEXT_ID);

     

     

      --  :P_NEXT_ID := P_NEXT_ID;

      --rollback;

      END;

      </sql:update>

     

    The query upper calls the procedure and makes new projectID by the autonumbering, then use query below which reads the new projectID from DB:

    <sql:query var="MAIN_A">

      select  NEXT_VALUE

      from CMN_AUTONUM_SCHEMES

      where OBJECT_CODE='project'

      and ATTRIBUTE_CODE='unique_code'

      </sql:query>

     

    I hope this is sufficiently clear.

     

    Regards,

    Martin



  • 6.  Re: Project ID autonumbering with XOG in GEL

    Posted Feb 02, 2015 07:48 AM

    Thanks for your post.

     

    I am saving data from C# Code. May I know how can I run the above script from C# Code base?

     

    Please help