Wikis - Page

Formio - Submitting the form fails because the data is not the correct data type

1 Likes

I recently was creating a sample request form and was getting an error when I submitted the form.

In the Tomcat catalina.out log I see these errors:

08:05:40.435 [https-jsse-nio-8543-exec-3] ERROR com.novell.soa.af.rest.controller.WfRestController - [WORKFLOW] Workflow request has failed.  
com.novell.soa.af.WorkException: Workflow request has failed. 
Caused by: com.novell.srvprv.apwa.APWAException: Failed to process data item name = [selectMake]. 
Caused by: com.novell.soa.af.DataItemException: Attempt to set value on Data item [selectMake] using incorrect type; expecting [java.lang.String] got [java.lang.Integer] 
08:05:40.445 [https-jsse-nio-8543-exec-5] ERROR com.netiq.idm.rest.access.PermissionRequestService - [RBPM] Failed to start the workflow.  
com.novell.soa.af.ProvisioningException: Failed to start the workflow. 

When I look at the Workflow Data Item Mapping info, sure enough, the selectMake and selectModel have a data type of String.

In my request form, I added some console logging so I could see the requestPayload when the form gets submitted. I put that code in the Submit button's "Button Custom Logic".

console.log(requestPayload);
 

In the console log, I was able to verify that selectMake and selectModel were both being submitted as integers.

I was able to recast those integers as strings using this code in the Submit button Button Custom Logic right before the form data gets posted:

try{
  dataItems.forEach(item => {
    switch (item.key) {
      case 'selectMake':
      case 'selectModel':
       item['value'] = [String(item.value)];
       break;
    }
  });
} catch(err) {
  console.log("Error: " + err);
}

requestPayload.data = dataItems; 
console.log(requestPayload); 

util.post('IDM','/rest/access/requests/permissions/v2',requestPayload,{}, function(res){util.requestNotificationHandler(res);}, function(err){util.failureNotification(err);}); 

Now those form values are in String format and get sent to the workflow successfully.

Labels:

Support Tips/Knowledge Docs
Comment List
Related
Recommended