You are on page 1of 3

Q) How to call an Activity rule from JavaScript?

Try this. In your function write this code.



var oSafeURL = new SafeURL("Class Name Of The Activity.Activity Name");
oSafeURL.put("ABC", parameter); // use it if parameter if required
var strReturn = httpRequestAsynch(oSafeURL.toURL(),null, 50, 100);
In Javascript you can use below command
runActivity("Class Name Of The Activity.Activity Name")
Q) To call an activity using java script :
1)
var bSafeURL= new SafeURL("A-B-C.ActivityName");
bSafeURL.put("param1",value1);
bSafeURL.put("param1",value2);
pega.util.Connect.asyncRequest('GET', bSafeURL.toURL(),'');

2) var oSafeURL = new SafeURL("@baseclass.testActivity");
oSafeURL.put("ClassName", insName);
var strRuleXml = httpRequestAsynch( oSafeURL.toURL(), null, 50, 100);

apart from there there lot other ways to do it.

Some ways that we can achive a call to activity and open popup window / model w
indow

1) openUrlInWindow(pxReqURI + "?pyActivity=A-B-C.ActivityName&Param1=" + value1,
"InteractionData", "status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes
,resizable=yes,left=192,top=51.2,height=500,width=800");
pxReqURI = pxRequestor.pxReqURI value

2)
activityURL = "<pega:reference name="pxRequestor.pxReqURI" mode="normal"/>?pyAct
ivity=Work-myActivity&myParameterName=" + valueToPass;
windowOptions = "width:500;height:600;resizable: yes; scroll: yes; help: no";
openUrlInWindow(activityURL,"WINDOWNAME",windowOptions,false);

3)
var strWindowName = "Popup window title";

var objSafeUrl = new SafeURL("A-B-C.Activity Name");
var contentWin = showModalDialog(objSafeUrl.toURL(), strWindowName , "width:500
;height:600;resizable: yes; scroll: yes; help: no;");

4) var objSafeUrl = new SafeURL("A-B-C.Activity Name");
windowOptions = "width:500;height:600;resizable: yes; scroll: yes; help: no";
openUrlInWindow(objSafeUrl .toURL(),"WINDOWNAME",windowOptions,false);
===============================================================================
======
I am using below code to call the activity from javascript. And I want to receiv
e multiple parameters back inside control.
I am using show-property inside activity to take one parameter back to control.
Is there anything like bSafeURL.put("param3",value3);
to recive output parameter in activity back to control?
var bSafeURL= new SafeURL("A-B-C.ActivityName");
bSafeURL.put("param1",value1);
bSafeURL.put("param1",value2);
you can return mulitple values in show-property Method. you can try like
Param.ReturnValues="Value1 :"+.value1+","+"Value2 :"+.value2
or
Param.ReturnValues=.value1+","+.value2

AND use this Param in the show-property . In java script , you can parse CSV.
================================================================================
=========
Q)how to call a javascript from activity to refresh screen rather than call show
-harness?
pega.u.d.reloadSection(pega.u.d.getSectionByName("<Section Name>","",""),"<Activ
ity Name>",'', false, true, '-1', false);
================================================================================
==========
Q) How to call OOTB utility/function in javascript?
function test (){
<% rulesetname_libraryname.SomeFunctionName (parameters); %>
}
================================================================================
==============
Q) How to call a FlowAction from JavaScript?
<button type='button' class='pzhc' data-ctl data-click='[["setUserStart",["FINIS
HASSIGNMENT"]],["doFormSubmit",["pyActivity=FinishAssignment",":this","Submittin
g...",":event"]]]' title= 'Complete this assignment' >
<div class='pzbtn-lft' ><div class='pzbtn-rgt'><div class='pzbtn-mid' data-click
='...'><img class='pzbtn-i'/> Next >></div></div></div></button>
Or this one on onclick event
'[["setUserStart",["FINISHASSIGNMENT"]],["doFormSubmit",["pyActivity=FinishAssig
nment",":this","Submitting...",":event"]]]'
================================================================================
====================
Q) how to enable Pegadeveloper javascript apiPrint how to enable Pegadeveloper j
avascript api?
Take the private checkout of @baseclass.IsAPegaDeveloper when rule and modify th
e when condition like
@IsInRuleSetList("Pega-RULES") Equal true. Now save the rule it will work.
This is a temporary solution.

You might also like