cancel
Showing results for 
Search instead for 
Did you mean: 

Create a Data Collection with ScriptTask and Log_DC API

steve_stubbs
Participant
0 Kudos

I am implementing a Production Process to log a Data Collection for a DC Group with 2 parameters. This process will be called from Plant Connectivity via an Automatic Trigger.

From the current API documentation the JSON structure for Log_DC api is this:

{

"group": {

"dcGroup": "string",

"version": "string"

},

"operation": {

"operation": "string",

"version": "string"

},

"parameterValues": [

{

"comment": "string",

"files": [

{

"fileContent": "string",

"fileId": "string",

"fileMediaType": "string",

"fileName": "string"

}

],

"name": "string",

"value": "string"

}

],

"plant": "string",

"resource": "string",

"sfcs": [

"string"

],

"stepId": "string",

"workCenter": "string"

}

I am attempting to use a Script Task to construct the DC Group structure and parameterValues array structure like this:

$output.group = {
    "dcGroup": $input.dcGroup,
    "version": "A"
};
$output.parameterValues = [];
if ($input.weld_te_Pos_val !== null) {
    $output.parameterValues.push({
        "name": "WELD_TE_POS", "value": $input.weld_te_Pos_val
    });
}
if ($input.weld_align_axial_val !== null) {
    $output.parameterValues.push({
        "name": "WELD_ALIGN_AXIAL", "value": $input.weld_align_axial_val
    });
}

When this script is Run it properly creates the structures:

• group: {"dcGroup":"WELDER","version":"A"}

• parameterValues: [{"name":"WELD_TE_POS","value":25},{"name":"WELD_ALIGN_AXIAL","value":35}]

However, when I try to assign the ScriptTask#parameterValues structure to the Log_DC API parameterValues, I get this:

Assign the script output variable:

Then this appears:

I cannot assign anything to any of the Parameter Definitions and cannot Save either.

What am I missing with this design?

View Entire Topic
0 Kudos
Hi Steve,

you seem to be using the Schema "Schemas>DataCollectionParameter> DataCollectionParameter" which is used for defining data collections and not for filling them.


The required schema is this one: "Schemas>LogRequest>Parameter"

To find out which schema is used for a public API:
  • Go to Manage Service Registry
  • API Services: Search for Name
  • Under "service definition > request body" navigate to the Schema
  • See the different components / subschemas

Kind Regards
Jonas

0 Kudos
When selecting the schema for your script task
  • Search for the Schema Name: eg. "Parameter"
  • Make sure that the Schema Group (eg. "Data Collection") and Schema Name is the same as in the "Manage Service Registry App"
steve_stubbs
Participant
0 Kudos

Hi Jonas,

Thanks for the help.

I found that I had referenced the schema DataCollectionParameter for the parameterValues output of the script task, instead of the Parameters schema, as you indicated. The correct Schema is identified in the Request Body LogRequest Schema in the Service Registry, but the heading for the Schema Definition column is Data Type; Data Type/Schema would be more clear. It would also be more helpful to be able to search by Group Name in the Script Task Schema Selection.

Regards, Steve