Support Article
FilePath control OnChange Event does not work as expected
Summary
Configuration: A FilePath control is configured to have an OnChange event coupled with a Refresh Action following a Run activity. Here this activity is used to perform Property-Set of property to true. This property is used in the visible condition of other dynamic layout , which displays its contents if the property is "true".
Issue: OnChange event is not causing the section to refresh and does not display the layout, but the same works fine that is, as expected if the event used is OnClick or OnBlur.
Error Messages
Not Applicable.
Steps to Reproduce
- Create a section and configure a FilePath control inside a dynamic layout.
- Below the FilePath control, place another dynamic layout with Visible condition.
- In the Actions tab of the FilePath control, configure the event OnChange, Refresh section-RunActivity.
- The activity must set a Flag value such that the dynamic layout Visible condition is set to true.
- Navigate to the UI in the portal and try to attach a file using FilePath control and tab out.
- Observe whether the layout in step2 is now visible.
Root Cause
A defect in Pegasystems’ code or rules. The control is setting onchange="updateDescription(this);" for it's input and the onChange event Refresh action, runactivity which generates onchange = "handleClientEvent()" causing the problem.
Resolution
Perform the following local-change:
Make few changes in the saveLocalFilePath API and also in the control.
Remove below code for the input:
<pega:when java='<%= !tools.getParamValue("pySetValueFromFileName").equals("")%>'>
onchange="updateDescription(this);"
</pega:when>
Add similar code in the saveLocalFilePath API, which turns the function.
function saveLocalFilePath(ids) {
var fileId = ids["thisId"];
var fileObj = document.getElementById(fileId);
if(fileObj != null) {
var targetId = ids["targetId"];
var targetObj = document.getElementById(targetId);
if(targetObj != null) {
var fileName = fileObj.getAttribute("value");
if(!fileName || fileName=="") {
fileName= fileObj.value;
}
if(fileName) {
targetObj.setAttribute("value", fileName);
}
}
<pega:when java='<%= !tools.getParamValue("pySetValueFromFileName").equals("")%>'>
updateDescription(fileObj);
</pega:when>
}
}
Published May 13, 2016 - Updated October 8, 2020
Have a question? Get answers now.
Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.