Creating a custom workflow in VMware vRealize Orchestrator (formerly known as VMware vCenter Orchestrator) fails with the error: date argument must be a date and non null
search cancel

Creating a custom workflow in VMware vRealize Orchestrator (formerly known as VMware vCenter Orchestrator) fails with the error: date argument must be a date and non null

book

Article ID: 340158

calendar_today

Updated On:

Products

VMware Aria Suite

Issue/Introduction

Symptoms:
  • Creating a custom workflow in vRealize Orchestrator fails (formerly known as VMware vCenter Orchestrator).
  • Your script to create a custom workflow fails with an error in vRealize Orchestrator:

    [<YYY-MM-DD HH:MM:SS>] [I] creating request...
    date argument must be a date and non null
  • The server.log file (located at install_directory\app-server\server\vmo\log) contains an entry similar to:

    [<YYY-MM-DD HH:MM:SS>] [I] + parameter name: 'messages.message[0]', value: 'scxmlapi(41) - The data in the 'header,planned.start' field of record C10132 - of file cm3r contains data that does not conform to the SOA datatype in datadict' [<YYY-MM-DD HH:MM:SS>] [I] + parameter attribute name: 'messages.message[0](type)', value: 'String' [<YYY-MM-DD HH:MM:SS>] [I] + parameter attribute name: '.(message)', value: 'Data Type Mismatch Error' [<YYY-MM-DD HH:MM:SS>] [I] + parameter attribute name: '.(returnCode)', value: '41'


Environment

VMware vCenter Orchestrator 5.1.x

Cause

This issue occurs for two reasons:
  1. You must explicitly provide the fixed value attribute type as a script input to avoid an an error.
  2. If you use a different date format than vRealize Orchestrator is expecting, an error can occur.

    Note: vRealize Orchestrator uses RFC822 formatted dates when providing parameter values of the type Date. If the SOAP service is expecting a date parameter in the ISO 8601 format, you must convert the value to the RFC822 format.

Resolution

To resolve this issue if it occurs because you have not explicitly provided a fixed value attribute type, edit the script for each date parameter. For example:

The original type attribute value in script is:

request.setInParameter("model.instance.header.DateEntered", System.formatDate(model_D_instance_D_header_D_DateEntered, "yyyy-MM-dd' T' HH:mm:ssZ"));
request.addInParameterAttribute("model.instance.header.DateEntered", "mandatory", model_D_instance_D_header_D_DateEntered_OP_mandatory_CP_);
request.addInParameterAttribute("model.instance.header.DateEntered", "readonly", model_D_instance_D_header_D_DateEntered_OP_readonly_CP_);
request.addInParameterAttribute("model.instance.header.DateEntered", "type", model_D_instance_D_header_D_DateEntered_OP_type_CP_);

In this script, the type attribute is modifed by adding an if statement to ensure the date parameter is only used if it is not null:

if (model_D_instance_D_header_D_DateEntered != null) {
request.setInParameter("model.instance.header.DateEntered", System.formatDate(model_D_instance_D_header_D_DateEntered, "yyyy-MM-dd' T' HH:mm:ssZ"));
request.addInParameterAttribute("model.instance.header.DateEntered", "mandatory", model_D_instance_D_header_D_DateEntered_OP_mandatory_CP_);
request.addInParameterAttribute("model.instance.header.DateEntered", "readonly", model_D_instance_D_header_D_DateEntered_OP_readonly_CP_);
request.addInParameterAttribute("model.instance.header.DateEntered", "type", "DateTime");
}

To resolve this issue when you use the specific script parameters in the example above, you must add a JavaScript function at the top of the script. For example:

function convertToIso8601 (dateRfc822) {
return dateRfc822.substr(0, dateRfc822.length-2 ) + ":" + dateRfc822.substr(dateRfc822.length-2);
}

Search for the entry:

System.formatDate(XXXX_DATE_PARAM, "yyyy-MM-dd'T'HH:mm:ssZ");

Replace it with:

convertToIso8601 (System.formatDate(XXXX_DATE_PARAM, "yyyy-MM-dd'T'HH:mm:ssZ"));