Skip to main content
bruceb92825582
Participant
May 13, 2022
Question

Document Generation API: Conditional test with null values

  • May 13, 2022
  • 2 replies
  • 1127 views

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

    2 replies

    Participant
    June 19, 2023

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

    bruceb92825582
    Participant
    May 16, 2022

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

    Known Participant
    May 8, 2025

    Uff.. this is really limiting. I see this post is from 2022 and it still seems to be an issue. Does anyone know if Adobe plans to address this? We frequently have documents where the field value is blank i.e. 

     

    "testField": "",

     

    in which case I don't want to show a certain section. I only want to show the section when it is NOT "" thus making it difficult to not have this logic available. It's not practical to set up a section for every possible value that might appear in "testField" as they are often picklist value sets that are altered or amended by the users in the source system.

     

    Known Participant
    May 8, 2025

    OK...so we found a workaround for this... if you are trying exclude blank values and cannot get the != to work; use the following conditional statment:

     

    {% conditional-section expr($length(yourfield) > 0) %}

    Print this section whenever 'yourfield' is not blank 

    {% end-section %}

     

    This appears to work within repeating sections for scenarios when you have blank field values. If your payload looks like the below., the section above will NOT print. If there is a value in yourfield, the section will print. 

    "Model": "Citation X",
    "yourfield": "",

    "Seats": 8,