AnsweredAssumed Answered

Need help with Gel script: what to do when a field is empty?

Question asked by BradGibson on Dec 10, 2012
Latest reply on Dec 11, 2012 by Dave
Need help with Gel script: what to do when a field is empty?
the field odf_ca_inv.man_champion is not a required field, can be empty. I find when that's true that the whole process errors out and stops. I don't want that... if the business owner isn't set I want the process to continue...
I want a way to check for the value being empty, gel doesn't seem to provide a lot of options for that.. I haven't even gotten NVL to work in these queries...
I either need a way to check for empty and NOT execute the script, or to substitute other values in when the field is null..

Has anyone fixed this when you've run into it?

Thanks!

Script below...



<gel:script xmlns:j="jelly:core"
xmlns:gel="jelly:com.niku.union.gel.GELTagLibrary"
xmlns:sql="jelly:sql">
<gel:setDataSource dbId="niku"/>

-- who is running the script

<sql:query var="whoami">
select INITIATED_BY from BPM_RUN_PROCESSES proc where proc.ID=${gel_processInstanceId}
</sql:query>
<j:forEach items="${whoami.rowsByIndex}" trim="true" var="whoami">
<gel:log>whoami: ${whoami[0]}</gel:log>
</j:forEach>


<!--department -->

<sql:query var="department">
select u.name from prj_obs_units u, prj_obs_associations a where a.unit_id=u.id and u.type_id='5000003' and a.record_id=${gel_objectInstanceId}
</sql:query>

<j:forEach items="${department.rowsByIndex}" trim="true" var="department">
<gel:log>department ${department[0]}</gel:log>
</j:forEach>



<!--Get ID and Name of Idea -->

<sql:query var="Id">
select code from Inv_investments i where i.id=${gel_objectInstanceId}
</sql:query>

<j:forEach items="${Id.rowsByIndex}" trim="true" var="Id">
<gel:log>ID ${Id[0]}</gel:log>
</j:forEach>


<sql:query var="Name">
select name from Inv_investments i where i.id=${gel_objectInstanceId}
</sql:query>

<j:forEach items="${Name.rowsByIndex}" trim="true" var="Name">
<gel:log>ID ${Name[0]}</gel:log>
</j:forEach>

<!--Get name of business owner-->

<sql:query var="bizowner">
select full_name from SRM_RESOURCES srm, odf_ca_inv ii where srm.ID=ii.man_champion and ii.id=${gel_objectInstanceId}
</sql:query>


<j:forEach items="${bizowner.rowsByIndex}" trim="true" var="bizowner">
<gel:log>biz owner ${bizowner[0]}</gel:log>
</j:forEach>



<!--Send email to business owner -->

-- business owner email
<sql:query var="BOEmail">
select srm.email from SRM_RESOURCES srm, odf_ca_inv ii where srm.ID=ii.man_champion and ii.id=${gel_objectInstanceId}
</sql:query>
<j:forEach items="${BOEmail.rowsByIndex}" trim="true" var="BOEmail">
<gel:log>BO email ${BOEmail[0]}</gel:log>
</j:forEach>



<gel:email from = "NoReply@ClarityAdmin.Com" fromName = "Clarity" to = "${BOEmail[0]}" subject= "New Business Case Submitted: ${Id[0]} ${Name[0]}" >


<![CDATA[

<br>Greetings,</br>
<br> A new Business Case has been submitted that names you as Business Owner. This Business Case will be forwarded to the appropriate manager for review and approval to estimate. </br>

Business Case: ${Name[0]}

ID: ${Id[0]}

Department: ${department[0]}

Regards,

Mission Control
]]>


</gel:email>




</gel:script>

Outcomes