Clarity

  • 1.  Copy Attribute Value?

    Posted Nov 07, 2010 08:11 PM
    Hi Everyone,

    I have a little bit hard question... ,
    I would like to copy one attribute value to an other one (same type) drived by a process. Is it possible? I think I can use a custom script , but I don't know how to start it.

    Thanks for your answers in advance.
    Br,
    István


  • 2.  RE: Copy Attribute Value?
    Best Answer

    Posted Nov 08, 2010 08:22 AM
    Hello István,

    When you say "copy one attribute value to an other one (same type) drived by a process", do you mean that the process will have to set the new attribute and the old attribute as well?
    Or you mean that the process will have to set the new attribute instead of the new one?

    If option 2 is correct, then do the following:
    1) Create the new attribute. Lets call it attribute 2.
    2) Put the old process (Process version 1) on hold.
    3) Copy the values of old attribute (attribute 1) and put it to attribute 2 via a database update script. Depending upon which object, the table will be different (they all start with odf_ca_). An example script:
    update odf_ca_* obj_parent
    set obj_parent.ca_gis_att_2 = (select obj_child.ca_gis_att_1 from odf_ca_*
                                where obj_child.id = obj_parent.id);
    4) Deploy the new version of the process (Process version 2). This version of the process will update the attribute 2.
    5) Validate and activate Process version 2.

    Hope this helps.

    Regards
    Sankhadeep Dhar


  • 3.  RE: Copy Attribute Value?

    Posted Nov 08, 2010 10:06 AM
    István,

    The question itself is not so hard. The difficulty lies in tailoring the answer to an unknown level of process understanding. If you've not worked with GEL before, you might want to start with some of the basic GEL documentation that CA provides. I recommend "XML Open Gateway Developer Guide" or "XOG Developer Guide: Spring 2010 Edition." Those will help you get started and understand the basics of custom scripting (i.e., GEL).

    That being said, we've adopted the following basic approach that's worked quite well for us. You're welcome to give it a shot.

    Note: This approach assumes that you're familiar with the basics of XOG for the object that contains the attribute you want to update. If not, you can use a more direct SQL update approach, but that's not recommended by CA for a number of reasons. XOG respects most of the business rules you can set up around objects that an Update query would not. In addition, if the update is to a core table, an Update query could put you on the wrong side of CA's customization policy.
    <!-- Query the database for the info you want -->
        <sql:query var="some_variable"><![CDATA[ insert SQL here]]></sql:query>
    <!-- Cycle through the result set from your query -->
        <core:forEach items="${some_variable.rowsByIndex}" trim="true" var="some_variable_2">
    <!-- Assign query result fields/columns to variables -->
            <core:set value="${some_variable_2[0]}" var="some_variable_3"/>
    <!-- Place XOG script into a variable (in this case called update_xog) -->
                <gel:parse var="update_xog">
                    <NikuDataBus ...>
                    </NikuDataBus>
                </gel:parse>
    <!-- Log the resulting XOG script -->
    <!-- The log steps are for basic troubleshooting and present you with information that would otherwise be invisible -->
    <!-- inside of a process.  They can be commented out once you are comfortable with how the script runs -->
                <gel:log>
                    <gel:expr select="$update_xog"/>
                </gel:log>
    <!-- Run the XOG script-->
                <soap:invoke endpoint="${XOGURL}" var="runresult">
                    <soap:message>
                        <soapenv:Envelope
                            xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xog="http://www.niku.com/xog">
                            <soapenv:Header>
                                <xog:Auth>
                                    <xog:SessionID>${sessionID}</xog:SessionID>
                                </xog:Auth>
                            </soapenv:Header>
                            <soapenv:Body>
                                <gel:include select="$update_xog"/>
                            </soapenv:Body>
                        </soapenv:Envelope>
                    </soap:message>
                </soap:invoke>
    <!-- Log the result of the XOG -->
                <gel:log>
                    <gel:expr select="$runresult"/>
                </gel:log>
    <!-- Move on to the next item in your query's result set -->
        </core:forEach>
    Hope this helps.

    David Hoover


  • 4.  RE: Copy Attribute Value?

    Posted Nov 08, 2010 05:40 PM
    Thanks for the really quick answer. I will check out, but I think it will work!

    THX!