Question
![](https://accounts.pega.com/sites/default/files/styles/user_image/public/1689956000/beb231f3-72b6-4111-b16c-7c2d7fa17a30.jpg?itok=fzTYfjcu)
![](https://accounts.pega.com/sites/default/files/styles/user_image/public/1689956000/beb231f3-72b6-4111-b16c-7c2d7fa17a30.jpg?itok=fzTYfjcu)
Areteans Technology Solutions
AU
Last activity: 3 Aug 2019 3:13 EDT
Javascript APIs
Can some give a working example of a Javascript API?
For example:
refreshSection - API
var options = {
section: sectionName,
event: eventObject,
dataTransform: dataTransformJSObject,
activity: activityJSObject,
submitOnRefresh: booleanVal
};
pega.api.ui.actions.refreshSection(options);
Can someone give a working example of this syntax?
Thanks in advance.
Ratan
***Edited by Moderator Marissa to update platform capability tags; add SR Details****
-
Like (0)
-
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
Accepted Solution
![](https://accounts.pega.com/sites/default/files/styles/user_image/public/2023-07/f7f35052-5e7d-4ed9-ada9-87594f1d3c63.png?itok=bz3Ms_gZ)
![](https://accounts.pega.com/sites/default/files/styles/user_image/public/2023-07/f7f35052-5e7d-4ed9-ada9-87594f1d3c63.png?itok=bz3Ms_gZ)
Pegasystems Inc.
US
Upon reviewing the associated Support Request, this is the resolution:
Perform the following local-change:
As per your requirement add type as button in the custom control. Please find the same below:
<button onclick="myFunction()" type=button>Click-----me</button>
![](https://accounts.pega.com/sites/default/files/pega-user-image/39/REG-38808.png?source=PUMINIT)
![](https://accounts.pega.com/sites/default/files/pega-user-image/39/REG-38808.png?source=PUMINIT)
Pegasystems Inc.
IN
Hi,
let me take the example of runDataTransform() API.
Here I want to trigger this to run one of my custom DT. The sample code will be something like this.
function onHarnessLoadHandler() {
![](https://accounts.pega.com/sites/default/files/styles/user_image/public/1689956000/beb231f3-72b6-4111-b16c-7c2d7fa17a30.jpg?itok=fzTYfjcu)
![](https://accounts.pega.com/sites/default/files/styles/user_image/public/1689956000/beb231f3-72b6-4111-b16c-7c2d7fa17a30.jpg?itok=fzTYfjcu)
Areteans Technology Solutions
AU
Hi @Santanu,
Thanks for the quick reply. On implementing the same, i can see the below behaviour in Pega.
<button onclick="myFunction()">Click me</button>
<script>
function myFunction() {
var e = window.event;
var options = {
name: "TestDT",
event: e
};
pega.api.ui.actions.runDataTransform(options);
}
</script>
When i click the button, the javascript API gets executed but i can see that it not only executes the data transform but also tries to finish the assignment. So, the above code is not equal to refresh section and run data transform, but refresh section, run data transform and Finish assignment.
Hi @Santanu,
Thanks for the quick reply. On implementing the same, i can see the below behaviour in Pega.
<button onclick="myFunction()">Click me</button>
<script>
function myFunction() {
var e = window.event;
var options = {
name: "TestDT",
event: e
};
pega.api.ui.actions.runDataTransform(options);
}
</script>
When i click the button, the javascript API gets executed but i can see that it not only executes the data transform but also tries to finish the assignment. So, the above code is not equal to refresh section and run data transform, but refresh section, run data transform and Finish assignment.
Is this an expected behaviour?
Thanks in advance.
Ratan Balaji
![](/profiles/pega_profile/modules/pega_user_image/assets/user-icon.png)
![](/profiles/pega_profile/modules/pega_user_image/assets/user-icon.png)
BlueRose Technologies
IN
Hi,
How did you included the js script in pega?
Which rule?
![](https://accounts.pega.com/sites/default/files/pega-user-image/39/REG-38808.png?source=PUMINIT)
![](https://accounts.pega.com/sites/default/files/pega-user-image/39/REG-38808.png?source=PUMINIT)
Pegasystems Inc.
IN
Hi
I tried similar code and cant see the refresh section happening. What your data transform is trying to perform at your end?
![](https://accounts.pega.com/sites/default/files/styles/user_image/public/1689956000/beb231f3-72b6-4111-b16c-7c2d7fa17a30.jpg?itok=fzTYfjcu)
![](https://accounts.pega.com/sites/default/files/styles/user_image/public/1689956000/beb231f3-72b6-4111-b16c-7c2d7fa17a30.jpg?itok=fzTYfjcu)
Areteans Technology Solutions
AU
Hey @Santanu
Since you took the example of running a data transform at the java script level, i thought of trying the same. Instead of just running the data transform, the system tries to finish the assignment. Can you please run the code that i posted above to check why the system does a "Run data transform","finish assingment" instead of just "run data transform"? Also, the test data transform that i execute has "exit data transform" as the only step in it.
![](https://accounts.pega.com/sites/default/files/pega-user-image/39/REG-38808.png?source=PUMINIT)
![](https://accounts.pega.com/sites/default/files/pega-user-image/39/REG-38808.png?source=PUMINIT)
Pegasystems Inc.
IN
Yeah, found similar issue as reported by you. I recommend you to raise an SR and let our support professional review and debug it further.
![](https://accounts.pega.com/sites/default/files/pega-user-image/442/REG-442498.png?source=PUMINIT)
![](https://accounts.pega.com/sites/default/files/pega-user-image/442/REG-442498.png?source=PUMINIT)
Pegasystems Inc.
IN
Hello @Ratan,
Do share the SR ID if you decide to create it. We will connect the SR with this post and track it for you.
Thanks,
![](https://accounts.pega.com/sites/default/files/styles/user_image/public/1689956000/beb231f3-72b6-4111-b16c-7c2d7fa17a30.jpg?itok=fzTYfjcu)
![](https://accounts.pega.com/sites/default/files/styles/user_image/public/1689956000/beb231f3-72b6-4111-b16c-7c2d7fa17a30.jpg?itok=fzTYfjcu)
Areteans Technology Solutions
AU
Accepted Solution
![](https://accounts.pega.com/sites/default/files/styles/user_image/public/2023-07/f7f35052-5e7d-4ed9-ada9-87594f1d3c63.png?itok=bz3Ms_gZ)
![](https://accounts.pega.com/sites/default/files/styles/user_image/public/2023-07/f7f35052-5e7d-4ed9-ada9-87594f1d3c63.png?itok=bz3Ms_gZ)
Pegasystems Inc.
US
Upon reviewing the associated Support Request, this is the resolution:
Perform the following local-change:
As per your requirement add type as button in the custom control. Please find the same below:
<button onclick="myFunction()" type=button>Click-----me</button>