Activity Rules - Calling A Sub-Activity
Activity Rules - Calling A Sub-Activity
Page 1 of 7
Summary
Introduction
Calling Activities Inside an Activity
Using Call
Using Branch
Using a Java Step
Using HTML
Calling activity from class other than Primary page or Step page
Introduction¶
Calling Activities Inside an Activity¶
Call
Branch
Inside a java step
Inside HTML code
Top
Using Call¶
http://knowledge-rules.com/(S(ssleim55mq4labyxknpqak45))/PRPC%20Dev.Print.asp... 9/10/2010
Activity Rules - Calling a Sub-Activity - GuidePost: KR Collaborative Learning Envir... Page 2 of 7
Using call causes the execution to jump back to the point where it started after finishing the called
activity. In the Activities-Introduction lesson, the execution of the activity will come back to
ActivitiesPractice1 activity at the next step after executing AddActivity. Call method is the most
commonly used method of calling an activity inside another activity.
As shown in Figure 1, when the AddActivity is called in the ActivitiesPractice1 activity using the
Call option, at Step 3 after completing the execution of AddActivity, execution of the
ActivitiesPractice1 will resume in Step 4.
Top
Using Branch¶
Using Branch will cause the execution of the main activity to halt after executing the sub-activity.
To see how using Branch works, in the activity ActivitiesPractice1 instead of Call use Branch as
shown in Figure 2:
http://knowledge-rules.com/(S(ssleim55mq4labyxknpqak45))/PRPC%20Dev.Print.asp... 9/10/2010
Activity Rules - Calling a Sub-Activity - GuidePost: KR Collaborative Learning Envir... Page 3 of 7
If you Run the activity, the result of the activity is not shown, instead, you will see a traditional
“Status Good” notification as shown in Figure 3.
Figure 3. StatusGood
This is because the execution of the activity ActivitesPractice1 has not resumed after executing the
AddActivity activity.
As shown in Figure 4, check the value held in .Property C on the AddPage clipboard page to see that
it is still set.
http://knowledge-rules.com/(S(ssleim55mq4labyxknpqak45))/PRPC%20Dev.Print.asp... 9/10/2010
Activity Rules - Calling a Sub-Activity - GuidePost: KR Collaborative Learning Envir... Page 4 of 7
Top
An activity can also be called inside another Java step, though using Java is not guardrail compliant.
Using Java to call a sub-activity will resume the execution of the calling activity after executing the
called activity. An activity is called inside Java using the Pega API method called doActivity This is
mostly used in cases where the activity name has to be passed dynamically and is not known at the
time of coding. It can be obtained at runtime. Java can also be used if an activity needs to be called
in the middle of a Java step embedded in a JSP. So, even though using Java is not guardrail
compliant, Java is still being used to call sub-activities. Figure 5 shows an example of using Java to
call a sub-activity.
http://knowledge-rules.com/(S(ssleim55mq4labyxknpqak45))/PRPC%20Dev.Print.asp... 9/10/2010
Activity Rules - Calling a Sub-Activity - GuidePost: KR Collaborative Learning Envir... Page 5 of 7
Place the following Java code in a Java step as shown in the Figure 5:
HashStringMap params = new HashStringMap();
ParameterPage newParamsPage = new ParameterPage();
String a = myStepPage.getProperty("PropertyA").toString();
String b = myStepPage.getProperty("PropertyB").toString();
newParamsPage.putString("A", a);
newParamsPage.putString("B", b);
params.putString("pxObjClass", "Rule-Obj-Activity");
params.putString("pyClassName", "PegaSample-Task");
params.putString("pyActivityName", "AddActivity");
try {
tools.doActivity(params, myStepPage, newParamsPage);
}
catch (Exception e) {
}
Now because we passed the values Param.A = 5 and Param.B = 5 as we learned in the Introduction
lesson, the result of the AddActivity will be "10". We can confirm this on the clipboard as we
learned in the Clipboard lesson.
Top
Using HTML¶
http://knowledge-rules.com/(S(ssleim55mq4labyxknpqak45))/PRPC%20Dev.Print.asp... 9/10/2010
Activity Rules - Calling a Sub-Activity - GuidePost: KR Collaborative Learning Envir... Page 6 of 7
The same activity can be called in an HTML rule. Using HTML rules to call sub-activities is
preferred when further UI processing is required. For example for some of the UI controls like
dynamic select, iframes, etc we may need to call an activity to execute and obtain the results. These
UI controls are discussed in detail in the lessons and exercises regarding HTML and UI.
When using HTML, the called activity needs to be in the same class as of the step page class. You
will learn more about coding in the lessons and exercises regarding HTML and UI.
Calling activity from class other than Primary page or Step page¶
Usually the called activity belongs to the class of the primary page or Step page as shown in the
Figure 6.
http://knowledge-rules.com/(S(ssleim55mq4labyxknpqak45))/PRPC%20Dev.Print.asp... 9/10/2010
Activity Rules - Calling a Sub-Activity - GuidePost: KR Collaborative Learning Envir... Page 7 of 7
However, an activity from a class other than that of the Step Page or Primary Page can be called by
using the class name explicitly as shown in Figure 7 below example:
Example:
Now you should read about the Standard Activities and Methods.
Top
http://knowledge-rules.com/(S(ssleim55mq4labyxknpqak45))/PRPC%20Dev.Print.asp... 9/10/2010