I was trying to add a row to a business object in add case page by using javascript and come across following code.
collectionController.beginChangeSet();
/* Build the values for the business object members. */
/* Assume all members will contain data for all rows. */
/* In the view, output two rows like the following rows: */
/* 10, Baker Street, Costa Mesa, Oasis, California, USA*/
/* 20, Ebay Street, Costa Mesa, Lotus, California, USA */
var propValues = {};
propValues["PPA_ProjectOwnerType"]= ["Test 1","Test 2"];
propValues["PPA_ProjectOwnerName"]= ["Baker Street","Ebay Street"];
/* Get the property controller of the business object. For instance, SAT_Residence: */
var residenceController = collectionController.getPropertyController(solutionPrefix + "_ProjectOwnersBOProp");
/* Get the members of the business object: */
var children = residenceController.getAttribute("boChildren").get();
/* Set the individual value arrays to the child controllers: */
/* This helps in displaying the changes on Add Case: */
var num_values = propValues["PPA_ProjectOwnerType"].length;
for(var j=0;j < num_values; j++) {
var childController = collectionController.getPropertyController(children[j]);
var propname = solutionPrefix + "_" + childController.getAttribute("name").get();
var prpN = propname.replace(/\s+/g, '');
childController.set("value",propValues[prpN]);
}
/* Loop through the values and set them to the business object controller: */
var values = [];
for(var i=0;i < num_values; i++) {
var updateJson = {};
updateJson.id = null;
var props = [];
updateJson.properties = props;
for(var j=0;j < children.length; j++) {
var prop = {};
var childController = collectionController.getPropertyController(children[j]);
prop.name = solutionPrefix + "_" + childController.getAttribute("name").get();
prop.dataType = childController.type;
prop.cardinality = childController.cardinality;
var prpN = prop.name.replace(/\s+/g, '');
prop.value = propValues[prpN][i] ;
props.push(prop);
}
values.push(updateJson);
}
residenceController.set("value", values);
/* Complete a batch of changes. This tells all subscribed widgets to refresh. */
collectionController.endChangeSet();
And my business object was created as

This code is working when I called it inside beforeloadwidget event action. (without using
ChangeSet())
But when I tried this inside button action, I am getting no response.
in both ways when I tried to click the add button, I am getting following error.
CaseMgmtException: FNRPA0087E An unexpected error occurred.
0000035c SystemErr R CIWEB.ICMAPIPlugin Error: [XXXXXXXXX @ XXXXXXXX] [REQUEST 1013] com.ibm.ecm.extension.icm.services.impl.CaseService.execute()
com.ibm.casemgmt.api.exception.CaseMgmtException: FNRPA0087E An unexpected error occurred.
at com.ibm.casemgmt.api.exception.CaseMgmtException.createException(CaseMgmtException.java:94)
at com.ibm.casemgmt.api.exception.CaseMgmtException.access$1500(CaseMgmtException.java:62)
at com.ibm.casemgmt.api.exception.CaseMgmtException$ClassBridgeImpl.createException(CaseMgmtException.java:442)
at com.ibm.casemgmt.intgimpl.CEObject.findRequiredPropertyDescription(CEObject.java:135)
at com.ibm.ecm.extension.icm.services.utils.PropertiesJSONConverter.getDependentObjectListFromJSONable(PropertiesJSONConverter.java:188)
at com.ibm.ecm.extension.icm.services.utils.PropertiesJSONConverter.addJSONableToPropertiesBag(PropertiesJSONConverter.java:169)
at com.ibm.ecm.extension.icm.services.impl.CaseService.createCase(CaseService.java:380)
at com.ibm.ecm.extension.icm.services.impl.CaseService.onExecute(CaseService.java:95)
at com.ibm.ecm.extension.icm.services.ICMBaseService.execute(ICMBaseService.java:168)
at com.ibm.ecm.util.PluginUtil.invokeService(PluginUtil.java:1386)
I am using BAW 20.0.0.1
I am looking a way to fix this. I just need to add a row to the business object with javascript in add case.
Many thanks in advance.
------------------------------
Alistair Gardner
------------------------------