cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Create a Data Collection with ScriptTask and Log_DC API

steve_stubbs
Participant
0 Likes
1,351

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?

Accepted Solutions (0)

Answers (2)

Answers (2)

Kevin_Hunter1
Product and Topic Expert
Product and Topic Expert

Hi Steve,

You dont need to create the JSON structure if you dont want to, you can map the individual values directly into the input structure. Give me a call and I can show you how.

Thanks

Kevin

steve_stubbs
Participant
0 Likes

Kevin and I worked on this in a joint session and were not successful. Still need some options for creating a 2-parameter Log_DC call with a Script Task and Log_DC services in a Production Process.

Kevin_Hunter1
Product and Topic Expert
Product and Topic Expert
0 Likes

Steve, I tested this on an internal tenant and it worked so I will give you a call tonight and take another look.

Thanks

Kevin

FeRoDM
Explorer
0 Likes
Hi Kevin, hi Steve, how did you prepare your JSON structure to fill out multiple parameters at once?
0 Likes
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 Likes
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 Likes

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

Ask a Question