Clarity

  • 1.  ${gel_objectInstanceId} not getting Object ID

    Posted May 26, 2016 08:06 AM

    I'm trying to write a Gel script within an Object based process, it needs to get the ID of the object it's running through to pass information to a SQL query to perform the next action. However, when I use ${gel_objectInstanceId} it's pulling back the 5 million number from a dynamic lookup used in an attribute on the object, not the ID or primary key of the object.

     

    What I'm trying to accomplish is triggering a process one object down. I'm starting in a child object from Project, then there's a child of my primary object that I want to run a process on each of the instances below it.

     

    Using the advice from CA PPM Tuesday Tip:  How To Launch a Process from a Gel Script

     

    The SQL Query I'm using is:

     

        SELECT ID
       FROM ODF_CA_SUBOBJECT
       WHERE ODF_PARENT_ID = ${gel_objectInstanceId}

     

    However, like I said, when I log it out to see why it's not working, my SQL isn't getting a result because it's returning the wrong 5 million number, if I'm starting the process from the object I want the ${gel_objectInstanceId} I should be getting the ID from that Object right? Why isn't this working, it appears to be my coding, as there's other processes that run at that same level with the same parameter and it is returning the correct ID.



  • 2.  Re: ${gel_objectInstanceId} not getting Object ID

    Posted May 26, 2016 08:17 AM

    Hello,

     

    Did you run your SQL Query within the Gel Script as follows?

     

    <sql:query dataSource="${clarityDS}" escapeText="0" var="result">

    <![CDATA[

           SELECT ID

            FROM ODF_CA_SUBOBJECT

            WHERE ODF_PARENT_ID = ${gel_objectInstanceId}

    ]]>

    </sql:query>

     

    Suhail.



  • 3.  Re: ${gel_objectInstanceId} not getting Object ID

    Posted May 26, 2016 08:24 AM

    No I wasn't, there are additional parameters within the process using the default gel_ calls, and they function OK.

     

    In previous instances I'm calling the claritydb just not specifically within the <sql:query> tag.



  • 4.  Re: ${gel_objectInstanceId} not getting Object ID

    Posted May 26, 2016 08:28 AM

    You can call the claritydb directly within the <sql:query> - this is not an issue.

     

    SQL Query should always be coded within <![CDATA[ ....sql query... ]]> in the Gel Script or it may give an error message.

     

    Suhail.



  • 5.  Re: ${gel_objectInstanceId} not getting Object ID

    Posted May 26, 2016 08:32 AM

    You are not by any chance 'confusing' (in your code or your reporting out) the ID you get from the ODF_CA_SUBOBJECT table with the gel_objectInstanceId are you? Perhaps overwriting the gel_ variable somehow? (GUESSING)

     

    Certainly gel_objectInstanceId should be the id of the affected object ; when you log it out can you do that at the very start of the script just to convince yourself its right?



  • 6.  Re: ${gel_objectInstanceId} not getting Object ID

    Posted May 26, 2016 08:41 AM

    Also, check this  Unexpeced results while executing custom script just in case this is what is happening (GEL script not in first step of a process -> funny stuff happens with those variables).



  • 7.  Re: ${gel_objectInstanceId} not getting Object ID
    Best Answer

    Posted May 26, 2016 08:48 AM

    Oh my, well, definitely my fault, apparently when I was first setting up the ACTION call, I had it map to the attribute in question, when deleting the process and recreating it, I was able to notice this as I mapped the action back again.

     

    Stupid mistake on my part, but a lesson learned that I won't repeat.



  • 8.  Re: ${gel_objectInstanceId} not getting Object ID

    Posted May 26, 2016 08:41 AM

    You had me doubting myself now, so I moved it to the first call after <gel:script> and it is indeed returning the incorrect ID, based on being in the database, the ID should be 5006000, but it's returning 5001000.

     

    To ensure I'm not making mistakes, I've run the process against several instances of the object, and it's reliably returning the 5 million number for a custom attribute that we've put on the object where we use a dynamic lookup, feeding off of ODF_PARENT_ID of the subobject (returning the 5 million number for the project)

     

    Again, we have other processes coded on the object that the gel_objectInstanceId is returning the correct ID in, so I feel like it's my code, my next step is to completely delete the process and re-code it (since it was only running this script anyways)



  • 9.  Re: ${gel_objectInstanceId} not getting Object ID

    Posted May 26, 2016 08:47 AM

    Sounds very strange ; would be included to get onto support of you can demo a suitably simple case of it "misbehaving".

     

    Could also see if using the gel_processInstanceId variable helps - this is the ID of the running process itself - (and then reading the object id off the BPM_RUN_PROCESSES table).