Getting Started with GEL Scripts in Clarity Educational Community

undefined
Updates and Automation
Getting Started with GEL Scripts
Presented by : Virginia DeCeglia & Chris Shaffer
Agenda
Overview
Introducing GEL
Scripting
Scripting Exercises
Q&A
Prerequisites
Basic knowledge creating CA PPM processes
Oracle/SQL language
CA PPM data model
Power of Automation
Time Spent
Task Size
Non-Geek
Geek
Does it manually
Does it manually
Gets annoyed
Writes script
to automate
Makes fun of geek’s
complicated method
Runs script
Wins
Loses
What is GEL?
GEL stands for Generic Execution Language
Based on Jelly, a jakarta.apache.org Commons project
Extended and embedded into CA PPM to enable custom logic
to solve business problems
GEL is the basis for the enterprise application integration
framework within CA PPM
GEL scripts can be executed from within CA PPM by installing
them as processes, or from the command line
GEL scripts are executed top down
What is GEL?, cont.
Additional information can be found in the CA Documentation
(CAClarityPPM_XOG_DeveloperGuide_ENU.pdf) and at the
Apache Jelly website at
http://jakarta.apache.org/commons/jelly/index.html
.
GEL Data Sources
Web Services
GEL can read or write to any SOAP based web service including
XOG
File System
GEL can read or write to any delimited file accessible on the
application server
FTP
GEL can upload or download to FTP servers
JDBC
 
GEL uses JDBC to read and write to databases
GEL Script Structure
<?xml version="1.0" encoding="UTF-8"?>
<gel:script xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
 
xmlns:core="jelly:core"
 
xmlns:gel="jelly.com.niku.union.gel.GELTagLibrary"
 
xmlns:file="jelly.com.niku.union.gel.FileTagLibrary"
 
xmlns:soap=" jelly.com.niku.union.gel.SOAPTagLibrary"
 
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
 
xmlns:sql="jelly.sql"
 
xmlns:xog="http://www.niku.com/xog"
 
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
 
xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance">
<!-- Code goes here -->
</gel:script>
Header
Comment
Footer
Header – Tag Namespaces
Header contains GEL namespace
A GEL script is built from qualified elements bound to java
code called tags
Tags are organized into tag libraries that dictate what can be
used in the script
CA PPM ships with many out of the box tag libraries.
Header – Tag Namespaces, cont.
<
gel:script
 xmlns:core
="
jelly:core
"
 
xmlns:gel
="
jelly:com.niku.union.gel.GELTagLibrary
"
 xmlns:soap
="
jelly:com.niku.union.gel.SOAPTagLibrary
"
 xmlns:soapenv
="
http://schemas.xmlsoap.org/soap/envelope/
"
 
xmlns:sql
="
jelly:sql
"
 xmlns:xog
="
http://www.niku.com/xog
"
 xmlns:xsd
="
http://www.w3.org/2001/XMLSchema
"
 xmlns:xsi
="
http://www.w3.org/2001/XMLSchema-instance
">
 
<!--
 Code goes here.. 
-->
 
</
gel:script
>
Tags
Tags are grouped in pairs, similar to HTML
<
core:
????><
/
core:
????>
<
core:
????/>
Each tag should have a closing tag
Tag name comes from the library definition
xmlns:
core
="jelly:core"
Core, SQL, GEL are most common libraries
Syntax
<namespace:tag attribute="attribute value"/>
Logging
The gel:log tag allows for logging of messages viewable from the
CA PPM application
You can declare the log to be INFO (Yellow flag) or WARN (Red X)
Syntax
<gel:log level="INFO">Log Message</gel:log>
Comments
Commenting your code will save a number of headaches later
on.
Comment syntax is the same as HTML.
Syntax
<!--  comment here
-->
Creating Your First Script – Follow Along
Create a process
Go to Studio / Processes / New
Creating Your First Script, cont.
Add Primary Object
Select Project object, Save and Return
Creating Your First Script, cont.
Left click Start Step
Creating Your First Script, cont.
Create a new action
Creating Your First Script, cont.
Select Custom Script
Click Next
Creating Your First Script, cont.
Enter action name and id
Enter the script into the custom script window
<gel:script
 xmlns:gel="jelly:com.niku.union.gel.GELTagLibrary">
 <!-- Code goes here.. -->
 <gel:log level="INFO">My first GEL worked!</gel:log>
</gel:script>
Validate, then Save and Return
Creating Your First Script, cont.
Under Post-Conditions, click Select Step
Select Finish step, click add
Creating Your First Script, cont.
Click Save and Return
Select the Validation tab
Creating Your First Script, cont.
Select Validate All and Activate
Creating Your First Script, cont.
1.
Go to project list and select a project
2.
Click the Processes tab
3.
Select the Available sub-page
4.
Select the test script, then click Start
Creating Your First Script, cont.
5.
Screen flips to initiated processes
6.
Click the messages flag
7.
Your log entry appears
8.
The BPM message shows for each step; this is normal
Questions
Variables
Variables are widely used in GEL scripts
Declared at the time of use
Most tags can set variables
Setting a variable
<core:set var="var_name">variable
value</core:set>
Reading a variable
${var_name}
Variables are valid for current script only
Persisting Variables
Persisting a variable allows makes it accessible throughout the
entire process
Persisted variables are only valid for the initiated instance.
<gel:persist var="var_name">variable_value</gel:persist>
Built-in Variables
Each process has three built in variables
${gel_objectInstanceId}
Object instance ID of the instance the process is executing on
Great for project or idea processes
${gel_processId}
ID of the Process itself
${gel_processInstanceId}
Process instance ID
Process Parameters
<gel:parameter>
Allows passing of values into a GEL script from a CA PPM process
Inside the GEL script, you can refer to the parameter as you would any
other variable by using ${variablename}
The optional attribute secure="true" causes CA PPM to hide the actual
value with asterisks (*) in the user interface
<gel:parameter var="XOGUsername" default="admin"/>
<gel:parameter var="XOGPassword" default="password" secure="true"/>
 
Case Sensitivity
Information contained within GEL tags is case sensitive
For example, if you declare a variable as follows:
 
<core:set var="v_ProjectID">PRJ-123456</core:set>
Then reference the variable as follows:
 
<gel:log>${v_projectid}</gel:log>
PRJ-123456 will not output
This will 
not
 cause an actual error to occur, so you can’t “catch” this
error.
Add the Database Data Source
1.
Add the SQL tag library to the header
xmlns:sql="jelly:sql"
2.
Add the niku data source at the beginning of the script
<gel:setDataSource dbId="niku"/>
Multiple Data Sources
Adding the var tag to the data source allows for multiple data
sources
<gel:setDataSource dbId="niku" var="clarity"/>
<gel:setDataSource dbId="ps_ora" var="peoplesoft"/>
Query the Database
Query structure
<sql:query dataSource="${clarity}"
escapeText="0" var="qry_task">
 
<![CDATA[
 
SELECT PRNAME from PRTASK
 
]]>
</sql:query>
The VAR is the array this query will be stored as
dataSource is the variable of the data source to be used
If only one data source, this tag is not needed
Always wrap sql statements in the CDATA tag so you can use <
and > characters
Query Parameters
Passing parameters
<sql:query dataSource="${clarity}"
escapeText="0" var="qry_task">
<![CDATA[
SELECT PRNAME from PRTASK
WHERE PRPROJECTID = ?
]]>
<sql:param value="${gel_objectInstanceId}"/>
</sql:query>
Parameters are in the order of the ? from the query
This creates a bind parameter and is more efficient for the
database
Helps with escaped characters and data types.
Query Results
Two ways to get the data out
By Index (Order of columns)
<core:forEach trim="true" items="${
qry_task
.rowsByIndex}"
var="
row
">
 
<gel:log level="INFO">Task Name: ${
row
[0]
}</gel:out>
</core:forEach>
By column name (Preferred Method)
<core:forEach trim="true" items="${
qry_task
.rows}" var="
row
">
 
<gel:log level="INFO">Task Name: ${
row
.prname
}</gel:log>
</core:forEach>
Update Query
<
sql:update
 dataSource="${clarity}" escapeText="0"
var="updateCnt">
 
<![CDATA[
 
UPDATE
 
odf_ca_project ocp
 
SET
  
ocp.rego_appr_date = sysdate
 
WHERE
 
ocp.id = ?
 
]]>
<sql:param value="${gel_objectInstanceId}"/>
</
sql:update
>
The variable ${updateCnt} contains the number of rows the update statement
affects
Note
: Using CDATA tags in update statements is preferred
Update Query, cont.
Processes often require updating the values of specific
attributes
You can to do this is with a SQL Update statement
Keep the following in mind when performing direct database
updates
Avoid Insert statements – these are best suited for XOG
Direct database updates will not trigger a process to start; XOG
updates will typically trigger processes to start
Avoid updating OOTB tables when possible; using XOG will ensure
all CA PPM business rules are followed
It is generally safe to update custom attributes with a SQL update
(these are typically found in tables beginning with odf_ca)
Use extra caution within On-demand environments
Delete Query
<
sql:update
 dataSource="${clarity}" escapeText="0"
var="updateCnt">
 
<![CDATA[
 
DELETE FROM Z_CUSTOM_TABLE
 
WHERE id = ?
 
]]>
<sql:param value="${gel_objectInstanceId}"/>
</
sql:update
>
The update tag is also used for delete statements
Looping – forEach
Use forEach to loop through database result sets
 
<core:forEach 
trim="true" items="${queryResult.rows}"
var="row">
 
.. Do something 
..
 
.. Do something ..
</core:forEach
>
Looping – While Loop
A While Loop can also be create
.
 
<core:while
 test="${v_counter &lt; 0}">
 
.. Do Something..
 
.. Don’t forget to update the counter
</core:while>
Conditional If/Then
Core:if is a simple if/then statement
 
<core:if test="${debug == 1}">
 
<gel:log level="INFO">XOG URL: ${xogUrl}</gel:log>
</core:if>
Conditional Expressions
==
 
Equals
!=
 
Not Equals
&gt;
 
Greater Than
&lt:
 
Less Than
&ge;
 
Greater Than or Equal To
&le;
 
Less Than or Equal To
Operational Expressions
||
  
Or
&& 
  
And
Conditional – Core/Choose/Otherwise
core:choose allows you to choose the right path
Otherwise is the default action when conditions are not met
<core:choose>
 
<core:when test="${row[6] == 'test'}">
  
 
</core:when>
 
<core:otherwise>
  
 
</core:otherwise>
</core:choose>
Sending Email
GEL can send HTML formatted email
<gel:email
from="Clarity@noreply.com" fromName="Clarity"
subject="Subject Line ${invCode}" to="${toEmail}">
<![CDATA[
 
Hello,<br>
 
<strong>this is bolded</strong>
]]>
</gel:email>
Gel:Email uses the mail server set up in the CSA
To address can be multiple separated by ;
If the address is listed twice it will fail
Uses the 
xmlns:email="jelly:email"
 
namespace
Sending Email, cont.
Email can be split up with database queries in the middle
<gel:email
from="Clarity@noreply.com" fromName="Clarity"
subject="Subject Line ${invCode}" to="${toEmail}">
<![CDATA[
 
Hello,<br><strong>this is bolded</strong>
]]>
<sql:query dataSource="${clarity}" escapeText="0" var="qry_res">
 
<![CDATA[
 SELECT …
 PRT.PRPROJECTID = ?
 
]]>
<sql:param value="${gel_objectInstanceId}"/>
</sql:query>
<core:forEach trim="true" items="${
qry_res
.rows}" var="row">
 
${
row.full_name} 
<br/>
</core:forEach>
</gel:email>
Exercise
Create an on-demand GEL script on the Project object
The GEL script should send a single email that contains a list of
resources on the project
Create the GEL script, and execute it manually on a project
Don’t forget to add the data source and namespaces
Use your own email address
Exercise, cont.
Namespaces to use
xmlns:core="jelly:core"
xmlns:gel="jelly:com.niku.union.gel.GELTagLibrary"
xmlns:sql="jelly:sql"
SQL Script to use
<![CDATA[
SELECT FULL_NAME FROM PRTEAM PRT
INNER JOIN SRM_RESOURCES SRMR ON PRT.PRRESOURCEID =
SRMR.ID
WHERE PRT.PRPROJECTID = ?
 
]]>
<sql:param value="${gel_objectInstanceId}"/>
Solution – Shell
Create the GEL shell structure with namespaces
<gel:script
 
xmlns:core="jelly:core"
 
xmlns:gel="jelly:com.niku.union.gel.GELTagLibrary"
 
xmlns:sql="jelly:sql">
</gel:script>
Solution – Data Source
Add the Data Source
<gel:script
 
xmlns:core="jelly:core"
 
xmlns:gel="jelly:com.niku.union.gel.GELTagLibrary"
 
xmlns:sql="jelly:sql">
 
<gel:setDataSource dbId="niku"/>
</gel:script>
Solution – SQL Query
Add the SQL query after the data source
<sql:query var="qry_team">
 
<![CDATA[
 
SELECT FULL_NAME FROM PRTEAM PRT
 
INNER JOIN SRM_RESOURCES SRMR
       
ON PRT.PRRESOURCEID = SRMR.ID
 
WHERE PRT.PRPROJECTID = ?
 
ORDER BY FULL_NAME
 
]]>
<sql:param value="${gel_objectInstanceId}"/>
</sql:query>
Solution – Email Body
After the data source
<gel:email
from="clarity_noreply@clarity.com"
fromName="Clarity"
subject="Project Team Members"
to="Your.Email@here.com">
<![CDATA[
Greetings, the following resources on assigned to the
project.<br/>
]]>
</gel:email>
Solution – Email Loop
After the data source
<gel:email
from="clarity_noreply@clarity.com"
fromName="Clarity"
subject="Project Team Members"
to="Your.Email@here.com">
<![CDATA[
Greetings, the following resources on assigned to the
project.<br/>
]]>
 
<core:forEach items="${qry_team.rows}" var="row">
 
${row.FULL_NAME} <br/>
 
</core:forEach>
</gel:email>
Solution – Completed Script
<gel:script
 
xmlns:core="jelly:core"
 
xmlns:email="jelly:email"
 
xmlns:gel="jelly:com.niku.union.gel.GELTagLibrary"
 
xmlns:sql="jelly:sql">
 
<gel:setDataSource dbId="niku"/>
 
<sql:query var="qry_team">
  
SELECT FULL_NAME FROM PRTEAM PRT
  
INNER JOIN SRM_RESOURCES SRMR ON PRT.PRRESOURCEID = SRMR.ID
  
WHERE PRT.PRPROJECTID = ?
  
ORDER BY FULL_NAME
 
<sql:param value="${gel_objectInstanceId}"/>
 
</sql:query>
 
<gel:email
 
from="clarity_noreply@clarity.com" fromName="Clarity"
 
subject="Project Team Members"
 
to="chris.shaffer@regoconsulting.com">
 
<![CDATA[
 
Greetings, the following resources on assigned to the project.<br/>
 
]]>
 
<core:forEach items="${qry_team.rows}" var="row">
   
${row.FULL_NAME}<br/>
  
</core:forEach>
  
</gel:email>
</gel:script>
Things to Consider
When working with GEL it is important to keep a few things in
mind
Be careful when hard coding URLs as refreshes from
production to non-prod will not automatically update scripts
Refreshes can play havoc with email processes
Ensure non-prod systems have email disabled or update email
addresses to a dummy address
Questions
 
Virginia DeCegilia
Virginia.DeCegilia@RegoConsulting.com
Chris Shaffer
Chris.Shaffer@RegoConsulting.com
Thank you for your time.
Contact US
888.813.0444
Email Contact
info@regoconsulting.com
Web Site
www.regoconsulting.com
Slide Note
Embed
Share

Explore the power of GEL scripting in Clarity Educational Community with sessions on script exercises, prerequisites, automation benefits, and data sources. Understand what GEL is, its execution language, and how it enables custom logic in CA PPM. Dive into GEL basics, automation advantages, and script structure using SOAP, JDBC, file systems, and web services.


Uploaded on Sep 20, 2024 | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. Download presentation by click this link. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

E N D

Presentation Transcript


  1. www.regouniversity.com Clarity Educational Community Getting Started with GEL Scripts Updates and Automation Presented by : Virginia DeCeglia & Chris Shaffer

  2. Agenda Overview Introducing GEL Scripting Scripting Exercises Q&A 2 Clarity Educational Community

  3. Prerequisites Basic knowledge creating CA PPM processes Oracle/SQL language CA PPM data model 3 Clarity Educational Community

  4. Power of Automation Loses Runs script Writes script to automate Time Spent Wins Gets annoyed Does it manually Makes fun of geek s complicated method Does it manually Task Size 4 Clarity Educational Community

  5. What is GEL? GEL stands for Generic Execution Language Based on Jelly, a jakarta.apache.org Commons project Extended and embedded into CA PPM to enable custom logic to solve business problems GEL is the basis for the enterprise application integration framework within CA PPM GEL scripts can be executed from within CA PPM by installing them as processes, or from the command line GEL scripts are executed top down 5 Clarity Educational Community

  6. What is GEL?, cont. Additional information can be found in the CA Documentation (CAClarityPPM_XOG_DeveloperGuide_ENU.pdf) and at the Apache Jelly website at http://jakarta.apache.org/commons/jelly/index.html. 6 Clarity Educational Community

  7. GEL Data Sources Web Services GEL can read or write to any SOAP based web service including XOG File System GEL can read or write to any delimited file accessible on the application server FTP GEL can upload or download to FTP servers JDBC GEL uses JDBC to read and write to databases 7 Clarity Educational Community

  8. GEL Script Structure <?xml version="1.0" encoding="UTF-8"?> <gel:script xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:core="jelly:core" xmlns:gel="jelly.com.niku.union.gel.GELTagLibrary" xmlns:file="jelly.com.niku.union.gel.FileTagLibrary" xmlns:soap=" jelly.com.niku.union.gel.SOAPTagLibrary" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sql="jelly.sql" xmlns:xog="http://www.niku.com/xog" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance"> <!-- Code goes here --> </gel:script> Header Comment Footer 8 Clarity Educational Community

  9. Header Tag Namespaces Header contains GEL namespace A GEL script is built from qualified elements bound to java code called tags Tags are organized into tag libraries that dictate what can be used in the script CA PPM ships with many out of the box tag libraries. 9 Clarity Educational Community

  10. Header Tag Namespaces, cont. <gel:script xmlns:core="jelly:core" xmlns:gel="jelly:com.niku.union.gel.GELTagLibrary" xmlns:soap="jelly:com.niku.union.gel.SOAPTagLibrary" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sql="jelly:sql" xmlns:xog="http://www.niku.com/xog" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <!-- Code goes here.. --> </gel:script> 10 Clarity Educational Community

  11. Tags Tags are grouped in pairs, similar to HTML <core:????></core:????> <core:????/> Each tag should have a closing tag Tag name comes from the library definition xmlns:core="jelly:core" Core, SQL, GEL are most common libraries Syntax <namespace:tag attribute="attribute value"/> 11 Clarity Educational Community

  12. Logging The gel:log tag allows for logging of messages viewable from the CA PPM application You can declare the log to be INFO (Yellow flag) or WARN (Red X) Syntax <gel:log level="INFO">Log Message</gel:log> 12 Clarity Educational Community

  13. Comments Commenting your code will save a number of headaches later on. Comment syntax is the same as HTML. Syntax <!-- comment here--> 13 Clarity Educational Community

  14. Creating Your First Script Follow Along Create a process Go to Studio / Processes / New 14 Clarity Educational Community

  15. Creating Your First Script, cont. Add Primary Object Select Project object, Save and Return 15 Clarity Educational Community

  16. Creating Your First Script, cont. Left click Start Step 16 Clarity Educational Community

  17. Creating Your First Script, cont. Create a new action 17 Clarity Educational Community

  18. Creating Your First Script, cont. Select Custom Script Click Next 18 Clarity Educational Community

  19. Creating Your First Script, cont. Enter action name and id Enter the script into the custom script window <gel:script xmlns:gel="jelly:com.niku.union.gel.GELTagLibrary"> <!-- Code goes here.. --> <gel:log level="INFO">My first GEL worked!</gel:log> </gel:script> Validate, then Save and Return 19 Clarity Educational Community

  20. Creating Your First Script, cont. Under Post-Conditions, click Select Step Select Finish step, click add 20 Clarity Educational Community

  21. Creating Your First Script, cont. Click Save and Return Select the Validation tab 21 Clarity Educational Community

  22. Creating Your First Script, cont. Select Validate All and Activate 22 Clarity Educational Community

  23. Creating Your First Script, cont. 1. Go to project list and select a project 2. Click the Processes tab 3. Select the Available sub-page 4. Select the test script, then click Start 23 Clarity Educational Community

  24. Creating Your First Script, cont. 5. Screen flips to initiated processes 6. Click the messages flag 7. Your log entry appears 8. The BPM message shows for each step; this is normal 24 Clarity Educational Community

  25. Questions 25 Clarity Educational Community

  26. Variables Variables are widely used in GEL scripts Declared at the time of use Most tags can set variables Setting a variable <core:set var="var_name">variable value</core:set> Reading a variable ${var_name} Variables are valid for current script only 26 Clarity Educational Community

  27. Persisting Variables Persisting a variable allows makes it accessible throughout the entire process Persisted variables are only valid for the initiated instance. <gel:persist var="var_name">variable_value</gel:persist> 27 Clarity Educational Community

  28. Built-in Variables Each process has three built in variables ${gel_objectInstanceId} Object instance ID of the instance the process is executing on Great for project or idea processes ${gel_processId} ID of the Process itself ${gel_processInstanceId} Process instance ID 28 Clarity Educational Community

  29. Process Parameters <gel:parameter> Allows passing of values into a GEL script from a CA PPM process Inside the GEL script, you can refer to the parameter as you would any other variable by using ${variablename} The optional attribute secure="true" causes CA PPM to hide the actual value with asterisks (*) in the user interface <gel:parameter var="XOGUsername" default="admin"/> <gel:parameter var="XOGPassword" default="password" secure="true"/> 29 Clarity Educational Community

  30. Case Sensitivity Information contained within GEL tags is case sensitive For example, if you declare a variable as follows: <core:set var="v_ProjectID">PRJ-123456</core:set> Then reference the variable as follows: <gel:log>${v_projectid}</gel:log> PRJ-123456 will not output This will not cause an actual error to occur, so you can t catch this error. 30 Clarity Educational Community

  31. Add the Database Data Source 1. Add the SQL tag library to the header xmlns:sql="jelly:sql" 2. Add the niku data source at the beginning of the script <gel:setDataSource dbId="niku"/> 31 Clarity Educational Community

  32. Multiple Data Sources Adding the var tag to the data source allows for multiple data sources <gel:setDataSource dbId="niku" var="clarity"/> <gel:setDataSource dbId="ps_ora" var="peoplesoft"/> 32 Clarity Educational Community

  33. Query the Database Query structure <sql:query dataSource="${clarity}" escapeText="0" var="qry_task"> <![CDATA[ SELECT PRNAME from PRTASK ]]> </sql:query> The VAR is the array this query will be stored as dataSource is the variable of the data source to be used If only one data source, this tag is not needed Always wrap sql statements in the CDATA tag so you can use < and > characters 33 Clarity Educational Community

  34. Query Parameters Passing parameters <sql:query dataSource="${clarity}" escapeText="0" var="qry_task"> <![CDATA[ SELECT PRNAME from PRTASK WHERE PRPROJECTID = ? ]]> <sql:param value="${gel_objectInstanceId}"/> </sql:query> Parameters are in the order of the ? from the query This creates a bind parameter and is more efficient for the database Helps with escaped characters and data types. 34 Clarity Educational Community

  35. Query Results Two ways to get the data out By Index (Order of columns) <core:forEach trim="true" items="${qry_task.rowsByIndex}" var="row"> <gel:log level="INFO">Task Name: ${row[0]}</gel:out> </core:forEach> By column name (Preferred Method) <core:forEach trim="true" items="${qry_task.rows}" var="row"> <gel:log level="INFO">Task Name: ${row.prname}</gel:log> </core:forEach> 35 Clarity Educational Community

  36. Update Query <sql:update dataSource="${clarity}" escapeText="0" var="updateCnt"> <![CDATA[ UPDATE odf_ca_project ocp SET ocp.rego_appr_date = sysdate WHERE ocp.id = ? ]]> <sql:param value="${gel_objectInstanceId}"/> </sql:update> The variable ${updateCnt} contains the number of rows the update statement affects Note: Using CDATA tags in update statements is preferred 36 Clarity Educational Community

  37. Update Query, cont. Processes often require updating the values of specific attributes You can to do this is with a SQL Update statement Keep the following in mind when performing direct database updates Avoid Insert statements these are best suited for XOG Direct database updates will not trigger a process to start; XOG updates will typically trigger processes to start Avoid updating OOTB tables when possible; using XOG will ensure all CA PPM business rules are followed It is generally safe to update custom attributes with a SQL update (these are typically found in tables beginning with odf_ca) Use extra caution within On-demand environments 37 Clarity Educational Community

  38. Delete Query <sql:update dataSource="${clarity}" escapeText="0" var="updateCnt"> <![CDATA[ DELETE FROM Z_CUSTOM_TABLE WHERE id = ? ]]> <sql:param value="${gel_objectInstanceId}"/> </sql:update> The update tag is also used for delete statements 38 Clarity Educational Community

  39. Looping forEach Use forEach to loop through database result sets <core:forEach trim="true" items="${queryResult.rows}" var="row"> .. Do something .. .. Do something .. </core:forEach> 39 Clarity Educational Community

  40. Looping While Loop A While Loop can also be create. <core:while test="${v_counter &lt; 0}"> .. Do Something.. .. Don t forget to update the counter </core:while> 40 Clarity Educational Community

  41. Conditional If/Then Core:if is a simple if/then statement <core:if test="${debug == 1}"> <gel:log level="INFO">XOG URL: ${xogUrl}</gel:log> </core:if> Conditional Expressions == Equals != Not Equals &gt; Greater Than &lt: Less Than &ge; Greater Than or Equal To &le; Less Than or Equal To Operational Expressions || && Or And 41 Clarity Educational Community

  42. Conditional Core/Choose/Otherwise core:choose allows you to choose the right path Otherwise is the default action when conditions are not met <core:choose> <core:when test="${row[6] == 'test'}"> </core:when> <core:otherwise> </core:otherwise> </core:choose> 42 Clarity Educational Community

  43. Sending Email GEL can send HTML formatted email <gel:email from="Clarity@noreply.com" fromName="Clarity" subject="Subject Line ${invCode}" to="${toEmail}"> <![CDATA[ Hello,<br> <strong>this is bolded</strong> ]]> </gel:email> Gel:Email uses the mail server set up in the CSA To address can be multiple separated by ; If the address is listed twice it will fail Uses the xmlns:email="jelly:email"namespace 43 Clarity Educational Community

  44. Sending Email, cont. Email can be split up with database queries in the middle <gel:email from="Clarity@noreply.com" fromName="Clarity" subject="Subject Line ${invCode}" to="${toEmail}"> <![CDATA[ Hello,<br><strong>this is bolded</strong> ]]> <sql:query dataSource="${clarity}" escapeText="0" var="qry_res"> <![CDATA[ SELECT PRT.PRPROJECTID = ? ]]> <sql:param value="${gel_objectInstanceId}"/> </sql:query> <core:forEach trim="true" items="${qry_res.rows}" var="row"> ${row.full_name} <br/> </core:forEach> </gel:email> 44 Clarity Educational Community

  45. Exercise Create an on-demand GEL script on the Project object The GEL script should send a single email that contains a list of resources on the project Create the GEL script, and execute it manually on a project Don t forget to add the data source and namespaces Use your own email address 45 Clarity Educational Community

  46. Exercise, cont. Namespaces to use xmlns:core="jelly:core" xmlns:gel="jelly:com.niku.union.gel.GELTagLibrary" xmlns:sql="jelly:sql" SQL Script to use <![CDATA[ SELECT FULL_NAME FROM PRTEAM PRT INNER JOIN SRM_RESOURCES SRMR ON PRT.PRRESOURCEID = SRMR.ID WHERE PRT.PRPROJECTID = ? ]]> <sql:param value="${gel_objectInstanceId}"/> 46 Clarity Educational Community

  47. Solution Shell Create the GEL shell structure with namespaces <gel:script xmlns:core="jelly:core" xmlns:gel="jelly:com.niku.union.gel.GELTagLibrary" xmlns:sql="jelly:sql"> </gel:script> 47 Clarity Educational Community

  48. Solution Data Source Add the Data Source <gel:script xmlns:core="jelly:core" xmlns:gel="jelly:com.niku.union.gel.GELTagLibrary" xmlns:sql="jelly:sql"> <gel:setDataSource dbId="niku"/> </gel:script> 48 Clarity Educational Community

  49. Solution SQL Query Add the SQL query after the data source <sql:query var="qry_team"> <![CDATA[ SELECT FULL_NAME FROM PRTEAM PRT INNER JOIN SRM_RESOURCES SRMR ON PRT.PRRESOURCEID = SRMR.ID WHERE PRT.PRPROJECTID = ? ORDER BY FULL_NAME ]]> <sql:param value="${gel_objectInstanceId}"/> </sql:query> 49 Clarity Educational Community

  50. Solution Email Body After the data source <gel:email from="clarity_noreply@clarity.com" fromName="Clarity" subject="Project Team Members" to="Your.Email@here.com"> <![CDATA[ Greetings, the following resources on assigned to the project.<br/> ]]> </gel:email> 50 Clarity Educational Community

More Related Content

giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#