0

I want to check for null values in Scriban.

{{ if (o_model.address.id) }}
<div  style="text-align: center;"><h5>Address {{ o_model.address.id}}</h5><br /></div>
{{ end }}

I am getting this error

error : Object `o_model.address` is null. Cannot access member: o_model.address.id

What I am doing wrong here?

5
  • 3
    Have you tried something like if (o_model.address && o_model.address.id)? Aug 7 '20 at 7:30
  • Not sure what part of Object o_model.address is null is unclear
    – Mark Cassidy
    Aug 7 '20 at 11:37
  • @MarkCassidy thanks it works
    – user2980
    Aug 10 '20 at 2:49
  • @MarkCassidy Marek solutions works thanks
    – user2980
    Aug 10 '20 at 2:49
1

This works

{{ if (o_model.address)}}
    {{ if (o_model.address.id)}}
    {{ end }} 
{{ end }}

Thanks Marek

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy