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!
Discussion posts and replies are publicly visible
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.
What is your exact issue?
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)
Value in test data
This took me a while to decode .....
That AI response is just a JSON string. So your first step must be a fromJson().
Even If I put it that way it does't even recognize it as JSON that why I gave it as toJSON first and from json next but still I'm unable to get the output it throws error. in one or other form.
Sure, a "List of Text" cannot be valid JSON. That rule input must be just "Text" and contain valid JSON.
same error even when its list. And this list was takes from output of promt builder
The value I see is not valid JSON ...
{ "doctorName": "Dr Mohsina Ahmed", "doctorAddress": "102a Haldon Street, Lakemba NSW 2195", "doctorPhone": "02 9759 5436", "doctorEmail": "info@isramedical.com.au", "doctorProviderNo": "5720463A", "documentType": "Mental Health Care Plan", "patientName": "Not Provided", "medicalCondition": "Anxiety and Depression", "effectiveDate": "24/8/2024", "treatmentPlan": "Regular follow-up, psychologist referral, crisis management review", "durationOfTreatment": "Not Provided", "doctorSignature": "Yes", "fileContent": "This letter is to confirm that the patient has attended Isra Medical service complaining of depressed mood, anxiety, sleep disturbance, difficulty concentration, headaches, and low self-esteem. The patient's K10 assessment score was 31, indicating distress. The doctor provided counselling, relaxation techniques, and a referral to a psychologist for further management. In the doctor's opinion, the patient is most likely suffering from anxiety and depression, and might benefit from reducing their study load to enable completing the management plan.", "recommendation": "approved", "reasoning": "The document includes all required details, including a valid doctor's signature, treatment plan, and medical condition. No missing information was detected."}This is what the AI prompt Builder is giving as output.
This is not valid JSON. I suggest to clear out that field "Expression" and paste the text directly into the field "Value".
Text pasted into "Expression" is first evaluated as an Appian expression.
I have attached 3 images over here. I'm trying to pass the json data from the process model to this rule via script task.the output in the expression rule is working fine but im trying to store the value in extractedData PV in the Script Task but it show{}. How to fix this?Prompt Builder Issue: It shows an inappropriate text at times when testing and gives it as an output which breaks the JSON in the Process model
Can you share the setup of that script task?
Are you sure you need that toJson?
The AI returns a string, which you store to a PV. Then you call your expression which expects a string, which you already have.
I Tried it without toJSON now my PV extract data return {} attached 3 images
It feels like the data you feed into your expression is not what you expect. I suggest to validate this.
this is what im expecting and im getting it in rule but not in script task