Output contract values not allowing me to create variables to store data

I have the following output contacts defined, when I try to store items like createdon@OData.Community.Display.V1.FormattedValue, it won't allow me to create a variable or select any:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "statecode": {
      "type": "integer"
    },
    "leadid": {
      "type": "string"
    },
    "Lead_Phonecalls": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "createdon@OData.Community.Display.V1.FormattedValue": {
            "type": "string"
          },
          "subject": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "_ownerid_value@OData.Community.Display.V1.FormattedValue": {
            "type": "string"
          },
          "directioncode@OData.Community.Display.V1.FormattedValue": {
            "type": "string"
          }
        }
      }
    }
  }
}

When I click create new variable, this gets thrown in my browser console

bundle.js:24 scripter: window.error caught unhandled error (5) ["Uncaught TypeError: Cannot read property 'data' of undefined", "https://apps.mypurecloud.com/scripter?locale=en-US", 33, 13342, TypeError: Cannot read property 'data' of undefined
at n (https://dhqbrvplips7x.cloudfront.net/s…]
c @ bundle.js:24
(anonymous) @ bundle.js:24
n @ bundle.js:41
r @ bundle.js:24
(anonymous) @ bundle.js:24
window.onerror @ bundle.js:62
scripter?locale=en-US:33 Uncaught TypeError: Cannot read property 'data' of undefined
at n (editMode.bundle.js:1)
at ScriptEditorToolbarViewModel.r.addNewVariableTypes (editMode.bundle.js:1)
at ze.t.editNewVariable (editMode.bundle.js:1)
at Object.r.createNewVariable [as click] (editMode.bundle.js:1)
at HTMLDivElement. (bundle.js:62)
at HTMLDivElement.dispatch (bundle.js:24)
at HTMLDivElement._.handle (bundle.js:24)
at HTMLDivElement.nrWrapper (scripter?locale=en-US:33)
n @ editMode.bundle.js:1
r.addNewVariableTypes @ editMode.bundle.js:1
t.editNewVariable @ editMode.bundle.js:1
r.createNewVariable @ editMode.bundle.js:1
(anonymous) @ bundle.js:62
dispatch @ bundle.js:24
_.handle @ bundle.js:24
nrWrapper @ scripter?locale=en-US:33
[Violation] Forced reflow while executing JavaScript took 33ms

That sounds like a bug with the scripting product. Please open a ticket with PureCloud Support to report this product issue. Thanks.

I wonder if the dot's in the property names might be causing some problem with the schema flattening. It might be best to extract those values out and build a result of simple properties.

Do you have an example? I am not completely following.

You have properties with a period in the name. Example: createdon@OData.Community.Display.V1.FormattedValue. He's saying to change your service to not send periods in property names. That's generally a bad practice since periods are reserved characters in most languages. Sticking with alphanumeric characters is a general best practice for property/variable naming.

I am not sure if I can change that, that is Microsoft Dynamics doing that when you want to look up values from IDs when you pass this header:

"Prefer": "odata.include-annotations=\"*\""

https://msdn.microsoft.com/en-us/library/gg334767.aspx

I was suggesting using a response translationMap and successTemplate to map the values so names, and then build a result using those names that is simpler. Some of the built in

{
"translationMap": {
"createdon": ".createdon@OData.Community.Display.V1.FormattedValue", "subject": ".subject",
"_ownerid": "._ownerid_value@OData.Community.Display.V1.FormattedValue", "directioncode": ".directioncode@OData.Community.Display.V1.FormattedValue"
},
"successTemplate": "{ "createdon": {cratedon}, \"subject\": {subject}, "_ownerid": {_ownerid}, \"directioncode\": {directioncode} }"
}

Giving that a try, now it is throwing an error in the translation map process:

  "code": "invalid.extraction.into.translation.map",
  "message": "There was an issue extracting a value from the remote endpoint's response into the response translation map.  Cause: Missing property in path $['createdon@OData']",

Response Section:

{
  "translationMap": {
    "createdonFormatted": "$.createdon@OData.Community.Display.V1.FormattedValue",
    "subject": "$.subject",
    "ownerid": "$.ownerid_value@OData.Community.Display.V1.FormattedValue",
    "directioncode": "$.directioncode@OData.Community.Display.V1.FormattedValue"
  },
  "successTemplate": "{ \"createdonFormatted\": ${createdonFormatted}, \"subject\": ${subject}, \"ownerid\": ${ownerid}, \"directioncode\": ${directioncode} }"
}

The dot notation is messing up the translation maps JSON path processing, but we found a way around that. A value can be looked up with ['attribute_name'] which will keep it from processing the dot notation.
We testing this with a mock web site and a test action.
{
"translationMap": {
"createdonFormatted": ".['createdon@OData.Community.Display.V1.FormattedValue']", "subject": ".subject",
"ownerid": ".['ownerid_value@OData.Community.Display.V1.FormattedValue']", "directioncode": ".['directioncode@OData.Community.Display.V1.FormattedValue']"
}

I tried this and it fixed the recent issues. The script is still not allowing me to create a variable to store this data in. I have to shift gears for a day or two but I plan on coming back to this. I will update this if I figure it out or make more progress. Thanks for all of your help.

Did you change your contract to be the simple names? There should be no reason to have a problem with scripter with a simple name.

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.