Legacy Dev Forum Posts

 View Only

Sign Up

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

  • 1.  Output contract values not allowing me to create variables to store data

    Posted 06-05-2025 19:09

    jlee | 2018-01-09 15:05:50 UTC | #1

    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" }, "LeadPhonecalls": { "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.<anonymous> (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


    tim.smith | 2018-01-09 16:20:27 UTC | #2

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


    Greg_Cunningham | 2018-01-09 17:07:35 UTC | #3

    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.


    jlee | 2018-01-09 18:31:10 UTC | #4

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


    tim.smith | 2018-01-09 18:46:07 UTC | #5

    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.


    jlee | 2018-01-09 18:53:01 UTC | #6

    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


    Greg_Cunningham | 2018-01-09 19:09:46 UTC | #7

    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": "$.owneridvalue@OData.Community.Display.V1.FormattedValue", "directioncode": "$.directioncode@OData.Community.Display.V1.FormattedValue" }, "successTemplate": "{ \"createdon\": ${cratedon}, \"subject\": ${subject}, \"ownerid\": ${_ownerid}, \"directioncode\": ${directioncode} }" }


    jlee | 2018-01-09 19:38:16 UTC | #8

    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} }" }


    Greg_Cunningham | 2018-01-09 21:10:57 UTC | #9

    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 ['attributename'] 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": "$.['owneridvalue@OData.Community.Display.V1.FormattedValue']", "directioncode": "$.['directioncode@OData.Community.Display.V1.FormattedValue']" }


    jlee | 2018-01-10 13:59:10 UTC | #10

    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.


    Greg_Cunningham | 2018-01-10 14:35:26 UTC | #11

    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.


    system | 2018-02-10 14:49:51 UTC | #12

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


    This post was migrated from the old Developer Forum.

    ref: 2322