How to show one field in a calculation, and another if it is blank (IF / THEN)

Comments

2 comments

  • Rainer Grabowski

    HI Jeremy, 

    it must be: @All of Contract Code != "" - not != null.
    If you want to check a field in the same item if it is not empty you must use != null (@Contract Code != null)
    But it you want to check it in a related item that you reference with @All of  fieldname it's !=""
    The call @All of fieldname returns an array [], it doesn't matter if you pull the field value from one item or multiple items. Example:
    A) Only one item related: @All of code returns ["Code A"] - one element in the array -  not empty
    B) Multiple items related: returns ["Code A","Code B","Code C"] - three elements in the array - not empty.
    C) No item related: [] - empty array. 
    And  wether an array is empty or has elements: if array == "" or if array != ""

    Rainer

    0
    Comment actions Permalink
  • Jeremy Taylor

    Hi Rainer,

    Thanks very much for your support! I was struggling a bit to make this work but your advice around !=null and !="" really helped.

    I managed to get the issue fixed with the below:

    var grantcode1 = @All of Contract code


    if(@All of Contract code!= ""){
    grantcode1 = @All of Contract code;
    }
    else{
    grantcode1 = @All of Title
    }

    @Report type + " | " + grantcode1 + " | "+ moment(@Due date).format("DD/MM/YYYY");

    Really appreciate it!
    Jeremy

    0
    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk