Skip to main content
Known Participant
Sep 6, 2024 4:24 PM UTC
Solved

How to convert Text Data returned from an Execute Gen AI Skill into a Map/Dictionary

Hi Experts,

Please help me to resolve my issue.

I want to convert the following data returned in "Text" format into a list of dictionary/map and afterwards map these fields to a CDT.

{ "IPAddress": "111.101.1111.11", "StartDate": "2024/06/26", "StartTime": "23:24:49", "StartTimezone": "UTC", "EndDate": "2024/06/28", "EndTime": "17:38:12", "EndTimezone": "UTC" }& { "IPAddress": "111.111.1101.11", "StartDate": "2024/07/02", "StartTime": "02:52:07", "StartTimezone": "UTC" }& { "IPAddress": "111.111.1110.11", "StartDate": "2024/07/07", "StartTime": "18:10:37", "StartTimezone": "UTC", "EndDate": "2024/07/09", "EndTime": "03:50:30", "EndTimezone": "UTC" }& { "IPAddress": "111.111.1111.10", "StartDate": "2024/07/16", "StartTime": "07:36:39", "StartTimezone": "UTC", "EndDate": "2024/07/17", "EndTime": "23:01:19", "EndTimezone": "UTC" }

Appreciate your help!

    kumara0180
    Participating Frequently
    Sep 8, 2024 11:30 PM UTC

    In my experience if your prompt is written properly, you would get the values in JSON format it self. 
    Example could be

    when I pass a text, map my text to below json schema.


    {
    "$schema": "">json-schema.org/.../schema
    "type": "array",
    "items": {
    "type": "object",
    "properties": {
    "IPAddress": {
    "type": "string"
    },
    "StartDate": {
    "type": "string",
    "format": "date"
    },
    "StartTime": {
    "type": "string",
    "format": "time"
    },
    "StartTimezone": {
    "type": "string"
    },
    "EndDate": {
    "type": "string",
    "format": "date"
    },
    "EndTime": {
    "type": "string",
    "format": "time"
    },
    "EndTimezone": {
    "type": "string"
    }
    },
    "required": [
    "IPAddress",
    "StartDate",
    "StartTime",
    "StartTimezone"
    ],
    "additionalProperties": false
    }
    }

    33 replies

    kumara0180
    Participating Frequently
    Sep 8, 2024 11:30 PM UTC

    In my experience if your prompt is written properly, you would get the values in JSON format it self. 
    Example could be

    when I pass a text, map my text to below json schema.


    {
    "$schema": "">json-schema.org/.../schema
    "type": "array",
    "items": {
    "type": "object",
    "properties": {
    "IPAddress": {
    "type": "string"
    },
    "StartDate": {
    "type": "string",
    "format": "date"
    },
    "StartTime": {
    "type": "string",
    "format": "time"
    },
    "StartTimezone": {
    "type": "string"
    },
    "EndDate": {
    "type": "string",
    "format": "date"
    },
    "EndTime": {
    "type": "string",
    "format": "time"
    },
    "EndTimezone": {
    "type": "string"
    }
    },
    "required": [
    "IPAddress",
    "StartDate",
    "StartTime",
    "StartTimezone"
    ],
    "additionalProperties": false
    }
    }

    Known Participant
    Sep 9, 2024 9:10 AM UTC

    All Right, Let me check my prompt again.

    Thank you [mention:d71dc0922a44411db41369c6058e69ad:e9ed411860ed4f2ba0265705b8793d05] for your answer, Appreciate it!

    kumara0180
    Participating Frequently
    Sep 9, 2024 10:19 PM UTC

    if it helps please mark this answer as verified

    Known Participant
    Mar 6, 2025 8:46 AM UTC

    I'm to facing same issue with the prompt builder noting helps in adding comments to the prompt builder. KIndly let me know the steps to sort this issue.

    stefanhelzle0001
    Brainy
    Mar 6, 2025 9:46 AM UTC

    What is your exact issue?

    Known Participant
    Mar 6, 2025 9:54 AM UTC

    	An error occurred while evaluating expression: extractedData:a!localVariables(
     local!data:a!toJson(pv!TestData),
     
     local!appdata:{a!flatten(a!fromJson(local!data))},
    
     a!forEach(
       items: local!appdata,
       expression: 'recordType!{5c360892-b7b1-4569-a96c-9f6a59a24f49}AG RSL IDP Extraction'(
         'recordType!{5c360892-b7b1-4569-a96c-9f6a59a24f49}AG RSL IDP Extraction.fields.{882cd204-82d1-41d5-857f-147364852129}documentType':fv!item.documentType,
         'recordType!{5c360892-b7b1-4569-a96c-9f6a59a24f49}AG RSL IDP Extraction.fields.{15cbb624-16a6-4915-b165-fea772bdc237}practitionerName':fv!item.doctorName
       )
     ),
    
    
    )
    (Expression evaluation error at function a!forEach [line 6]: Error in a!forEach() expression during iteration 1: Expression evaluation error : Invalid index: Cannot index property 'documentType' of type Text into type Text) (Data Outputs)


    In TestData[Data Type : Text] pv! im getting JSON data as input from prompt builder but at time though its not in format I converted to to Json. My issues I want to map the data in record type with their respective fields but unable to achieve that in appian im putting the same login in expression rule it gives me correct out but if I put it in script task it throws error as. I have tried almost all possible ways but it fails unable to write to record type.