Question
Accenture
IN
Last activity: 30 Mar 2017 7:43 EDT
How to run an activity through JavaScript.
How to run an activity through JavaScript. I dont want to use OpenURLInSpace,
I just want to run the activity from the back end and nothing should be visible in the UI.
-
Likes (2)
Rim CHTOUROU Gopala krishnudu Marri -
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
Accepted Solution
Pegasystems Inc.
IN
Please find the sample code below and let us know if this helps.
var oSafeUrl = new SafeURL("@baseclass.ActivityName");
var request = pega.u.d.asyncRequest('GET',oSafeUrl);
-
Sri Lakshmi Nilagiri Prateek Patnaik Lekha Chandra Putcha Anu Priya C
TATA CONSULTANCY SERVICES
IN
Just adding to whatever Pankaj Rawal replied.
Added Success/Failure functions as well. Incase due to some reason if the asyncRequest call to the Activity fails we can handle it in a better way.
<script>
function FunctionName(e) {
var oSafeURL = new SafeURL("ClassName.ActivityName");
oSafeURL.put("pzPrimaryPageName", "pyWorkPage");
pega.util.Connect.asyncRequest("POST", oSafeURL.toURL(), {
success: function (o) {
<<Do Something>>
},
failure: function (o) {
<<Do Something>>
}
}, '');
}
</script>
Thanks
Hari Kumar Alampuru
-
Sri Lakshmi Nilagiri Prateek Patnaik
Capgemini
SE
Hi Hari,
We are using below control for adding notes in case notes tab by click on submit button in pop up window which will trigger activity for attaching notes.
<script>
function SaveAndClose()
{
var successMessage = "";
var failureMessage = "";
var oSafeBaseUrl = new SafeURL("ActivityClassName.ActivityName");
var request = pega.util.Connect.asyncRequest('POST', oSafeBaseUrl.toURL());
/*window.opener = self; */
window.close();
}
</script>
<input type = 'Button' value = 'Submit' onclick = "SaveAndClose()" />
But activity is not triggering in Prod environment only for some reason. Will it be environmental issue or any configuration needs to be done for triggering activity.
Accenture
IN
Thanks for the reply Pankaj and Hari âº, Will try the above mentioned method and share the result.
Accenture
IN
Thanks Pankaj Rawal and Hari Kumar, Both the method worked âºâº
Accenture
IN
Also is it possible to return values from the calling url ?
JPMC
IN
Yes, in the above post by Hari, he mentioned about callback functions like success as
success: function (o)
here o refers respObject which can be further used as appropriate.
say var retHTML = respObject.responseText;
-
Sri Lakshmi Nilagiri Ishara Wickramausrya
Accenture
IN
okay thanks for the response,i have one more doubt, to set the response we use something like pxRequestor.pyHTTPResponse Header in the activity that was called through url?