• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Document Generation API: Conditional test with null values

Community Beginner ,
May 13, 2022 May 13, 2022

Copy link to clipboard

Copied

If my JSON contains null values (see sample below) how do I use that in a conditional test?

I've tried several combinations but none have the results I want - see attached Word document and sample PDF output. 

 

{
"FirstName": "Joe",
"LastName": "Bloggs",
"Address": "1 Acme Drive London SW15 2RQ United Kingdom",
"PolicyNumber": "1234456",
"Premium": "$344.50",
"PaymentMethod": "Credit Card ending 2345",
"PolicyStartDate": "2 April 2022",
"PolicyEndDate": "1 April 2023",
"Coverage": [
{
"TreatmentName": "Crown re-cement",
"TreatmentType": "Major",
"IntervalPeriod": 12,
"Quantity": 1,
"PerTooth": "Not Applicable",
"Coverage": 50,
"MaximumCover": null
},
{
"TreatmentName": "Dental Implant Treatment",
"TreatmentType": "Other",
"IntervalPeriod": 12,
"Quantity": null,
"PerTooth": "Not Applicable",
"Coverage": 100,
"MaximumCover": "$2,000.00"
}
]
}

Views

428

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 16, 2022 May 16, 2022

Copy link to clipboard

Copied

On further testing it appears that the != (not equals) comparison operator does not work when inside a repeating section.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 19, 2023 Jun 19, 2023

Copy link to clipboard

Copied

LATEST

Hi there!

I solved this issue by using the following text, using "Sample_Variable" as the placeholder for what your variable would be.

{{`Sample_Variable`}}{% conditional-section expr(`Sample_Variable` = null) %}None{% end-section %}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources