Skip to main content
krushnapadas0001
February 28, 2023
Question

How can handle null value while passing json data with converting a!tojson() format ?

  • February 28, 2023
  • 3 replies
  • 0 views

Hi All,

I am facing below issue while trying to passed formatted json (a!fromJson()) data as parameter and again converting same json date using a!toJson() format at that time of passing the parameter.

Please find the below code sample and share me if any solution.

step1- Finding enter json data

local!jsonData: if(a!isNullOrEmpty(ri!jsonData),
{},
a!fromJson(ri!jsonData)
),

step2 -  Binging with local variable 

local!exceptionResults:property(local!jsonData, "ScreeningSummary", null),

step3-  Passing the local variable with using a!toJson to child interface (rule!PM_ScreeningExceptionSummary)

rule!PM_ScreeningExceptionSummary(a!toJson(local!exceptionResults)),

Step 4- Binding Json preparties within the Appain ready only grid


a!localVariables(
local!exceptionResultsFound: if(
a!isNullOrEmpty(ri!exceptionResults),
{},
a!fromJson(ri!exceptionResults)
),
{
a!sectionLayout(
label: "Exceptions",
labelSize: "SMALL",
contents: {
a!gridField(
data: local!exceptionResultsFound,
columns: {
a!gridColumn(
label: "Screening Services",
value: fv!row.ScreeningService
),
a!gridColumn(
label: "Exception Found",
value: fv!row.ExceptionMessage
)
},
validations: {}
)
},
)
},
)

Error Screenshot 


Could not display interface. Please check definition and inputs. Interface Definition: Expression evaluation error at function a!toJson [line 420]: The value parameter must not be null.

Note:- Maybe some time my json contain null value. and not storing in CDT .

Json with value


{
"ScreeningSummary": [
{
"ScreeningService": "Service1",
"ExceptionMessage": "Message1"
},
{
"ScreeningService": "Service2",
"ExceptionMessage": "Message2"
},
{
"ScreeningService": "Service3",
"ExceptionMessage": "Message3"
},
{
"ScreeningService": "Service4",
"ExceptionMessage": "Message4"
}
]
}

Json with null value 

"ScreeningSummary": null

3 replies

stefanhelzle0001
Brainy
February 28, 2023

Is this related to your other post?

https://community.appian.com/discussions/f/appian-community-edition/27889/how-can-pass-formatted-json-data-from-one-interface-to-another-interface-to-bind-with-in-the-appian-grid

I still do not understand why you convert data to/from JSON back and forth?!? Especially not inside Appian.

When looking at your 4 steps above, it is clear, that there is a situation in which that data is NULL. You will need to design this in a way it handles this case.

And for better readability

krushnapadas0001
February 28, 2023

Hi Stefan Helzle,

Thanks for your replied. 

Yes, it is related with my previous post.

First the json data stored in the Appian process while work item created and it is contain huge data.

Using from json because of  finding  specific Json node with key value pair. It is working when the Json node contain value but finding error at time of particular json node is null.

Expression evaluation error at function a!toJson : The value parameter must not be null.

now my problem is how can handl the null value time.

Please let me know if any clarification required.

Thanks.

stefanhelzle0001
Brainy
February 28, 2023

"contain huge data" worries me. Make sure to check Appian best practices!

I am not sure how to help here. You know about a!isNullOrEmpty() already. Now you need to decide what to do in that case.