AnsweredAssumed Answered

Locking Start Date of multiple projects via system action in one script

Question asked by giriraj.gupta1 on Apr 29, 2017
Latest reply on May 4, 2017 by giriraj.gupta1

Hello, 

I have made a object base process which locks the Start date and calling it in another non-object base process which triggers this process multiple times to lock start date of multiple projects. I am calling process(Start date lock) in for loop based on object id fetched from sql query. 

 

This process is running fine without any issues and able to lock start date of multiple instances in single script.

 

Could you please review this code and let me know it causes any issue? I don't want to lock start date via DB script.

 

<gel:script xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:bpm="jelly:com.niku.bpm.gel.BPMTagLibrary"
xmlns:core="jelly:core"
xmlns:gel="jelly:com.niku.union.gel.GELTagLibrary"
xmlns:sql="jelly:sql"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<gel:setDataSource dbId="niku"/>

<!-- Take the target processCode as a parameter -->
<gel:parameter var="processCode"/> <!-- Object based process which having a system action to lock Start date -->

<!-- we will launch the next process as admin to avoid rights issues -->
<core:set var="targetUserId" value="1"/>

<core:choose>

<!-- Make sure we've supplied the processCode parameter -->
<core:when test="${processCode != null &amp;&amp; processCode.length() &gt; 0}">

<sql:query var="results">
SELECT
bdpv.id process_version_id,
bdo.object_name
FROM
bpm_def_processes bdp,
bpm_def_process_versions bdpv,
bpm_def_objects bdo
WHERE bdpv.process_id = bdp.id
and bdo.pk_id = bdpv.id
and bdp.process_code = ?
and (bdo.is_system = 0 or bdo.is_system is null)
<sql:param value="${processCode}"/>
</sql:query>

<!-- Extract the process_version_id, targetObjectKey from the query -->
<core:set var="targetProcessId" value="${results.rows[0].process_version_id}"/>
<core:set var="targetObjectKey" value="${results.rows[0].object_name}"/>

<core:choose>

<sql:query var="Project_id">
Select id from inv_investments where...<!-- query to get project DB instance id where start date needs to be locked-->
</sql:query>

<core:forEach items=project_id.rowbyindex var="result">
<core:set var="ProjectId" value="${result.rows[0]}"/>

<!-- Here i am running a proess which locks the start date of a project -->
<core:when test="${targetProcessId != null}">
<bpm:startProcess processVersionId="${targetProcessId}" initObjectKey="${targetObjectKey}" initObjectId="${ProjectId}" initUserId="${targetUserId}"/>
</core:when>

</core:forEach>

<core:otherwise>
<gel:log level="ERROR">Cannot find process code '${processCode}' to launch. </gel:log>
</core:otherwise>

</core:choose>

</core:when>

<core:otherwise>
<gel:log level="ERROR">processCode parameter has not been supplied</gel:log>
</core:otherwise>

</core:choose>

</gel:script>

Outcomes