• Resolved sagarchataut

    (@sagarchataut)


    I’m trying to assign a value of new field to fieldB, if fieldA satisfy the condition equation of fieldB.

    (function(){
    if(fieldname19>=1&&fieldname19<=1.1) {
    return fieldname 35;
    }
    else if(fieldname19>1.1&&fieldname19<=1.2) {
    return fieldname 36;
    } else if(fieldname19>1.2&&fieldname19<=1.3) {
    return fieldname 37;
    } else if(fieldname19>1.3&&fieldname19<=1.4) {
    return fieldname 38;
    } else if(fieldname19>1.4&&fieldname19<=1.5) {
    return fieldname 39;
    } else if(fieldname19>1.5&&fieldname19<=1.75) {
    return fieldname 40;
    } else if(fieldname19>1.75&&fieldname19<=2) {
    return fieldname 41;
    }
    })()

    I used this code, didn’t work so I modified and used

    (function(){
    
    if(fieldname19>=1&&fieldname19<=1.1) 
    return
    fieldname 28;
    
     if(fieldname19>1.1&&fieldname19<=1.2) return
    fieldname 29;
     if(fieldname19>1.2&&fieldname19<=1.3) return
    fieldname 30;
     if(fieldname19>1.3&&fieldname19<=1.4) return
    fieldname 31;
     if(fieldname19>1.4&&fieldname19<=1.5) return
    fieldname 33;
    if(fieldname19>1.5&&fieldname19<=1.75) return
    fieldname 32;
     if(fieldname19>1.75&&fieldname19<=2) return
     fieldname 34;
    
    })()

    and this

    (function(){
    if(fieldname19<=1.1) {
    return fieldname 35;
    }
    else if(fieldname19<=1.2) {
    return fieldname 36;
    } else if(fieldname19<=1.3) {
    return fieldname 37;
    } else if(fieldname19<=1.4) {
    return fieldname 38;
    } else if(fieldname19<=1.5) {
    return fieldname 39;
    } else if(fieldname19<=1.75) {
    return fieldname 40;
    } else {
    return fieldname 41;
    }
    })()
    (function(){
    if(fieldname19>=1&&fieldname19<=1.1) {
    fieldname185 == fieldname 35;
    }
    else if(fieldname19>1.1&&fieldname19<=1.2) {
    fieldname185 == fieldname 36;
    } else if(fieldname19>1.2&&fieldname19<=1.3) {
    fieldname185 == fieldname 37;
    } else if(fieldname19>1.3&&fieldname19<=1.4) {
    fieldname185 == fieldname 38;
    } else if(fieldname19>1.4&&fieldname19<=1.5) {
    fieldname185 == fieldname 39;
    } else if(fieldname19>1.5&&fieldname19<=1.75) {
    fieldname185 == fieldname 40;
    } else if(fieldname19>1.75&&fieldname19<=2) {
    fieldname185 == fieldname 41;
    }
    })()
    
    (function() {
    if(fieldname19>=1&&fieldname19<=1.1) {
    return fieldname185 == fieldname 35;
    }
    else if(fieldname19>1.1&&fieldname19<=1.2) {
    return fieldname185 == fieldname 36;
    } else if(fieldname19>1.2&&fieldname19<=1.3) {
    return fieldname185 == fieldname 37;
    } else if(fieldname19>1.3&&fieldname19<=1.4) {
    return fieldname185 == fieldname 38;
    } else if(fieldname19>1.4&&fieldname19<=1.5) {
    return fieldname185 == fieldname 39;
    } else if(fieldname19>1.5&&fieldname19<=1.75) {
    return fieldname185 == fieldname 40;
    } else if(fieldname19>1.75&&fieldname19<=2) {
    return fieldname185 == fieldname 41;
    }
    })()

    and a few others but none worked, maybe I’m using the wrong syntax?

    Actually, I had used these conditions in “Define Dependencies”, it successfully showed the result, but the displayed result can’t be used for further calculation, so I had to use “set equation”, please help me out with any of these!

    • This topic was modified 3 years, 6 months ago by sagarchataut.
Viewing 1 replies (of 1 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello @sagarchataut

    The fields’ names have the structure fieldname#. Please, remove the spaces characters between the fieldname words and the numbers. The equation would be:

    (function(){
    
    if(1<=fieldname19 && fieldname19<=1.1) return fieldname28;
    if(1.1<fieldname19 && fieldname19<=1.2) return fieldname29;
    if(1.2<fieldname19 && fieldname19<=1.3) return fieldname30;
    if(1.3<fieldname19 && fieldname19<=1.4) return fieldname31;
    if(1.4<fieldname19 && fieldname19<=1.5) return fieldname33;
    if(1.5<fieldname19 && fieldname19<=1.75) return fieldname32;
    if(1.75 < fieldname19 && fieldname19<=2) return fieldname34;
    
    })()

    Note that your equation returns no value when fieldname19 is less than 1 or greater than 2.

    Best regards.

Viewing 1 replies (of 1 total)
  • The topic ‘if else if condition not working’ is closed to new replies.