Clarity

Expand all | Collapse all

Run Parameterised Job via GEL & Process

  • 1.  Run Parameterised Job via GEL & Process

    Posted Jan 25, 2013 06:53 AM
    I am trying to create a process which performs a series of housekeeping activities on old projects. What I would like the process to do (for an individual project on-demand, initially) is to set a few field values then run the Purge Financial Tables job then the Purge Documents job for just the initiating project.

    I have a main process that does the field stuff and then runs a GEL script with an InvokeAction call to fire up two other individual processes which run each job.

    Field stuff works fine. GEL script runs, starts the jobs OK but my issue is in how to pass the parameters those job require. Jobs just finish as the parameter(s) are not passed to them.

    By looking at other posts on this I've put my GEL together as follows. I have no idea what tags I should be using under the Request section (or indeed if I should be using the Request element at all), and I'm guessing that the parameter names should be the same as the job parameter names defined in Clarity. Any ideas on how I should be passing things?
    <!-- Get the external project code and internal ID from the object instance id - for use as a parameter in jobs-->
    
    <sql:query dataSource="${clarityDS}" escapeText="false" var="project">
    
    
    <![CDATA[
    
    
    SELECT 
    
    
    code, id 
    
    
    from inv_investments i
    
    
    where i.id = ${gel_objectInstanceId}
    
    
    ]]> 
    
    </sql:query>
    
    
    <core:forEach items="${project.rowsByIndex}" trim="true" var="project_data">
    
    
    <core:set value="${project_data[0]}" var="project_code" />
    
    
    <core:set value="${project_data[1]}" var="project_id" />
    
    </core:forEach>
    
    
    
    <soap:invoke endpoint="${XOGURL}/niku/xog" var="auth">
    
    
            <soap:message>
    
    
    
                <soapenv:Envelope     xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
    
    
    
    
    
    
    
    
    
     xmlns:xog="http://www.niku.com/xog">
    
    
    
    
    
    
    
    <soapenv:Header/>
    
    
    
    
                    <soapenv:Body>
    
    
    
    
                        <xog:Login>
    
    
    
    
    
    
                            <xog:Username>${XOGUsername}</xog:Username>
    
    
    
    
    
    
                            <xog:Password>${XOGPassword}</xog:Password>
    
    
    
    
    
    
    
    
    
    </xog:Login>
    
    
    
    
    
    
    
    
    </soapenv:Body>
    
    
    
    
    
    
    </soapenv:Envelope>
    
    
    
    
    </soap:message>
    
    </soap:invoke>
    
    
    
    <gel:set asString="true" select="$auth/SOAP-ENV:Envelope/SOAP-ENV:Body/xog:SessionID/text()" var="sessionID"/>
    
    <core:choose>
    
    
        <core:when test="${sessionID == null}">
    
    
    
            <gel:log>Couldn't Log in.  Check the username/password.</gel:log>
    
    
    
    
    
    </core:when>
    
    
    <core:otherwise></core:otherwise>
    
    </core:choose>
    
    
    
    
    <gel:log>Logging in and running jobs for project ${project_code}...</gel:log>
    
    
    
    
    <soap:invoke endpoint="${XOGURL}/niku/xog" 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>
    
    
    
    
    
    
    
    <!-- First run Purge Financial Tables job-->
    
    
    
    
    
    
    
    <gel:log>${project_code} Purge financial table job...</gel:log>
    
    
    
    
    
    
    
    <Process xmlns="http://www.niku.com/xog/InvokeAction">
    
    
    
    
    
    
    
    
    <code>owen_purge_financials</code>
    
    
    
    
    
    
    
    
    <request>
    
    
    
    
    
    
    
    
    
    <thisProject>
    
    
    
    
    
    
    
    
    
    
    param_project_code="${project_id}"
    
    
    
    
    
    
    
    
    
    </thisProject>
    
    
    
    
    
    
    
    
    </request>
    
    
    
    
    
    
    
    </Process>
    
    
    
    
    
    
    
    
    <!-- Then run Delete Documents job-->
    
    
    
    
    
    
    
    <gel:log>${project_code} Purge documents job...</gel:log>
    
    
    
    
    
    
    
    
    <Process xmlns="http://www.niku.com/xog/InvokeAction">
    
    
    
    
    
    
    
    
    
    <code>archive_purge_docs</code>
    
    
    
    
    
    
    
    
    
    <request>
    
    
    
    
    
    
    
    
    
    
    <documents>
    
    
    
    
    
    
    
    
    
    
    
    retainVersions="-1"
    
    
    
    
    
    
    
    
    
    
    
    notAccessedDays="-1"
    
    
    
    
    
    
    
    
    
    
    
    purgeAll="true"
    
    
    
    
    
    
    
    
    
    
    
    allProjects="false"
    
    
    
    
    
    
    
    
    
    
    
    projectOBSunitId="-1"
    
    
    
    
    
    
    
    
    
    
    
    allResources="false"
    
    
    
    
    
    
    
    
    
    
    
    resourceOBSunitId="-1"
    
    
    
    
    
    
    
    
    
    
    
    specificResourceId="-1"
    
    
    
    
    
    
    
    
    
    
    
    allCompanies="false"
    
    
    
    
    
    
    
    
    
    
    
    companyOBSunitId="-1"
    
    
    
    
    
    
    
    
    
    
    
    specificCompanyId="-1"
    
    
    
    
    
    
    
    
    
    
    
    retainVersions="-1
    
    
    
    
    
    
    
    
    
    
    
    purgeKnowledgeStore="false"
    
    
    
    
    
    
    
    
    
    
    
    specificProjectId="${project_id}"
    
    
    
    
    
    
    
    
    
    
    </documents>
    
    
    
    
    
    
    
    
    
    </request>
    
    
    
    
    
    
    
    </Process>
    
    
    
    
    
    
    </soapenv:Body>
    
    
    
    
    
    </soapenv:Envelope>
    
    
    
    </soap:message>
    
    
    </soap:invoke>
    My result in the process messages is as follows:
    <?xml version="1.0" encoding="UTF-8"?>
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
        <soapenv:Header/>
        <soapenv:Body>
            <ProcessResult xmlns="http://www.niku.com/xog/InvokeAction"/>
        </soapenv:Body>
    </soapenv:Envelope>
    Any suggestions as to what I'm missing?

    Thanks


  • 2.  RE: Run Parameterised Job via GEL & Process

     
    Posted Jan 28, 2013 06:02 PM
    Hi All,

    Any suggestions here for Owen?

    Thanks!
    Chris


  • 3.  RE: Run Parameterised Job via GEL & Process

    Posted Feb 01, 2013 11:06 AM
    Bump...

    Any ideas, anyone....? Can't believe I've stumped everyone here, will take any suggestions no matter how wacky!


  • 4.  RE: Run Parameterised Job via GEL & Process

    Posted Feb 01, 2013 11:29 AM
    Does this thread help any? Launch a job from gel.

    (I have no idea if it does - I can't read it..... well you asked for "wacky" :tongue)


  • 5.  RE: Run Parameterised Job via GEL & Process

    Posted Feb 04, 2013 09:33 AM
    Well that thread might, if there were any answers in it :grin:

    I've raised a case with Support, but they've gone quiet on this one too, so perhaps I have stumped the world....if anything comes back from them then I'll post it here.


  • 6.  RE: Run Parameterised Job via GEL & Process

    Posted Feb 04, 2013 10:00 AM

    Owen_R wrote:

    Well that thread might, if there were any answers in it :grin:.
    Google's webcache tells me that Nick D said;
    Create a process with no primary object, and a step to run your chosen job / parameters.

    Create another process, and within the GEL make an invokeAction/Process web service call (see: http://yourserver/niku/wsdl/InvokeAction) to the XOG end point. It's indirect to have a 2nd process to give you the item you can call on demand, but as a route and solution, it is supported.


  • 7.  RE: Run Parameterised Job via GEL & Process

    Posted Feb 04, 2013 11:55 AM
    OK, I'd seen that via the Google cache the other week, and that's what I am doing. I can get the job to start and complete from within my main process, it's just the passing parameter bit that doesn't work. So I can run Clean User Session easily enough but I can't run Purge Financial Transactions for a specific project.


  • 8.  RE: Run Parameterised Job via GEL & Process

    Posted Feb 13, 2013 06:12 AM
    An update...from Support I got the suggestion to use the getDocument tag in my GEL to retrieve the process XML and set the variables. This and setDocument are not tags I've used before. Looking at the Integration Guide doesn't really help much either as there's no example code. Has anybody got any examples of these tags in action or suggestions where I should use them in my script above?


  • 9.  RE: Run Parameterised Job via GEL & Process

    Posted Feb 07, 2014 02:35 PM
    Owen_R:
    An update...from Support I got the suggestion to use the getDocument tag in my GEL to retrieve the process XML and set the variables. This and setDocument are not tags I've used before. Looking at the Integration Guide doesn't really help much either as there's no example code. Has anybody got any examples of these tags in action or suggestions where I should use them in my script above?


    Hello Owen, 

    I know this is an old thread but I am trying to do the same thing in our environment, trying to run auto-schedule project job from within a processes with dynamic project id as param..any idea how to achieve it? Possibly with a code?

    Thanks

     



  • 10.  Re: Run Parameterised Job via GEL & Process

    Posted Oct 30, 2014 09:50 PM

    Hi,

     

    Owen_R and @TonyRosa, I'm trying to do something similar (programmatically trigger a process on a specific object instance), and I too can't quite follow the setDocument and getDocument and InvokeAction items. Please share any guidance!

     

     

    My code snippet below is as far as I've gotten. It does trigger the process, but it doesn't appear to attach the process instance to an object instance (task in my case, even though the process "z_sam_tt2" definition is to a task instance?)

     

     

        <gel:parse var="v_xml_root_2">

            <Process xmlns="http://www.niku.com/xog/InvokeAction">

                <code>z_sam_tt2</code>

                    <request>

                        <thisTask>5108018</thisTask>

                    </request>

            </Process>

        </gel:parse>

      

        <!--  Execute XOG -->

        <core:catch var="xog_error">

            <soap:invoke endpoint="${v_clarityURL}" 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>${v_xogSessionId}</xog:SessionID>

                            </xog:Auth>

                        </soapenv:Header>

                        <soapenv:Body>

                            <gel:include select="$v_xml_root_2"/>

                        </soapenv:Body>

                    </soapenv:Envelope>

                </soap:message>

            </soap:invoke>

        </core:catch>



  • 11.  Re: Run Parameterised Job via GEL & Process

    Posted Oct 20, 2017 03:52 PM

    Hi Samos, I know it's a pretty old thread, but I do have the same issue.  Did you figured it out?

     

    If I excecute this:

    -------------------------------

    <?xml version="1.0" encoding="UTF-8"?>
    <Process xmlns="http://www.niku.com/xog/InvokeAction">>
    <code>cs_cp_actuals</code>
    <request>
    <thisCostPlan>XOG-002350-20171118CO</thisCostPlan>
    </request>
    </Process>

    ------------------------------

    and looked into process, my XOG-002350-20171118CO is not linked to the process



  • 12.  Re: Run Parameterised Job via GEL & Process

    Posted Oct 20, 2017 05:57 PM

    See if this link helps: Gel access to WSDL Process InvokeAction content 

     

    V/r,

    Gene



  • 13.  Re: Run Parameterised Job via GEL & Process

    Posted Oct 23, 2017 11:30 AM

    Thanks Gene, I did try changing to:

     

    <?xml version="1.0" encoding="UTF-8"?>
    <Process xmlns="http://www.niku.com/xog/InvokeAction">>
    <code>cs_cp_actuals</code>
    <request>
    <objparam objType="costplan">XOG-002350-20171118CO</objparam>
    </request>
    </Process>

     

    but I still don't see in the Initiated Process  window the Object Name