0% found this document useful (0 votes)
117 views7 pages

Activity Rules - Calling A Sub-Activity

This document discusses different ways to call one activity from within another activity in Pega. It describes using call, branch, a Java step, or HTML. Call is the most common and resumes execution of the calling activity after the called activity finishes. Branch halts execution of the calling activity. A Java step can also call an activity and resume the calling activity. HTML rules are preferred when further UI processing is needed from the called activity. An activity can also be called from a different class than the calling activity's class by specifying the class name.

Uploaded by

vineela05
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
117 views7 pages

Activity Rules - Calling A Sub-Activity

This document discusses different ways to call one activity from within another activity in Pega. It describes using call, branch, a Java step, or HTML. Call is the most common and resumes execution of the calling activity after the called activity finishes. Branch halts execution of the calling activity. A Java step can also call an activity and resume the calling activity. HTML rules are preferred when further UI processing is needed from the called activity. An activity can also be called from a different class than the calling activity's class by specifying the class name.

Uploaded by

vineela05
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Activity Rules - Calling a Sub-Activity - GuidePost: KR Collaborative Learning Envir...

Page 1 of 7

Activity Rules - Calling a Sub-Activity


Summary¶
The Primary focus of this page is to explain different ways of calling an activity inside another
activity. For the detailed understanding of this page make sure to complete the lessons on PRPC
Basics, Method calls, Tracer and Clipboard prior to the start of this lesson.

Software version: PRPC 5.5 SP1


Prerequisites: ActivityRules-Introduction, Standard Activities and Methods, Tracer and Clipboard.
What next: Standard Activities and Methods
See also: PDN Intro to Activities

Table of Contents [Hide/Show]

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

Back to Roadmap: Roadmap to System Architect Certification

Introduction¶
Calling Activities Inside an Activity¶

An activity can be called inside another activity in the following ways:

 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.

Figure 1. ActivitiesPractice1 Configuration #2

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

Figure 2. Branch Example

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

Figure 4. Viewing Results on the Clipboard

Top

Using a Java Step¶

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

Figure 5. Java Step

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.

Figure 6. Pages & Classes Tab

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:

Figure 7. Specifying the Class for a Called Activity

So an activity named AddTwoValues, created in the Data-Admin-Operator-ID class, can be executed


and returns the result (PropertyC) which can be seen in the above figure 7 on clipboard. So in this
way an activity from any class can be called as subactivity by just using the class name follwed by a
period.
call <classname to which activity belongs>.<activity name>

Now you should read about the Standard Activities and Methods.

Top

Next Lesson >>Standard Activities and Methods

http://knowledge-rules.com/(S(ssleim55mq4labyxknpqak45))/PRPC%20Dev.Print.asp... 9/10/2010

You might also like