Discussion
Tata Consultancy Services
GB
Last activity: 6 Apr 2017 8:01 EDT
Calling activity from HTML in section
Hi, I am trying to call an activity and pass parameter to it from java script in a Section. I am not been able to do this. I'm using below code:
<script>
var varNameOnCard = "Biswajit";
oSafeURL =null;
var oSafeURL = new SafeURL("Grp-Data-Fin-PaymentAccount-Card.PostAuthSemafoneTest",getReqURI());
oSafeURL.put("NameOnCard", varNameOnCard )
//var strReturn = httpRequestAsynch(oSafeURL.toURL(),null, 50, 100);
//pega.util.Connect.asyncRequest('GET', oSafeURL.toURL(),'');
var strResponse = httpRequestAsynch(oSafeUrl.toURL(),"post");
</script>
However if I use the below JSP, activity is invoked correctly but I can't pass the parameter on to it from java script code. So if any body can please help understand why the former is not working. Many thanks for help.
<%
String strNameOnCard = "Biswajit";
ParameterPage newParams = null;
HashStringMap keys= null;
newParams = tools.getParameterPage();
newParams.putString("NameOnCard",strNameOnCard);
keys = new HashStringMap();
keys.putString("pxObjClass", "Rule-Obj-Activity");
keys.putString("pyClassName", "Grp-Data-Fin-PaymentAccount-Card");
keys.putString("pyActivityName", "PostAuthSemafoneTest");
tools.doActivity(keys, tools.getPrimaryPage(), newParams);
%>
***Updated by moderator: Lochan to add Categories***
What version of Pega are you using?
The two statements below should be fixed:
oSafeURL =null;
var oSafeURL = new SafeURL("Grp-Data-Fin-PaymentAccount-Card.PostAuthSemafoneTest",getReqURI());
In the first statement you declare a globally-scoped "oSafeURL" variable but in the next statement immediately declare one that is locally scoped
It the second statement I believe you should begin your URL with "pyActivity=". I could be wrong.
In Pega 7 you can easily call an Activity from the UI but apparently you are looking to do something with the async response yourself within the browser's DOM, or do you simply want to popup a confirm or alert window?