If then calculations across apps

Comments

5 comments

  • Rainer Grabowski

    Hi Paul,

    for the 2 calculation fields in WO you can use:
    Field 1 for Programmers:

    var type = @all of category field;
    var dur = @all of duration field;
    
    var proghrs = 0
    for(var i = 0; i < type.length; i++){
    if(type[i] == "Programmer Hours"){
    proghrs += dur[i]
    }
    };
    

    Field 2 for Technicians:

    var type = @all of category field;
    var dur = @all of duration field;
    
    var techhrs = 0
    for(var i = 0; i < type.length; i++){
    if(type[i] == "Technician Hours"){
    techhrs += dur[i]
    }
    };
    

    Rainer
    rg@delos-consulting.com

    0
    Comment actions Permalink
  • Paul Lyet

    Rainer, Thank you for the quick response. I added it to my calculations and it works but I seem to be calculating "1" if not time is entered. Once a value has been added it works great.

    0
    Comment actions Permalink
  • Rainer Grabowski

    Can that happen that a duration field is empty? When a time slip is created both fields (type and duration) should have a value (even if the value is 0).
    If it can happen, that duration is empty, it can rise problems for the whole calculation. You can a avoid these issues by
    a) making the duration field a required field or
    b) creating a calcution field (e.g. called "Duration Mirror") in the Time slip app, which checks if the duration field is empty and then shows 0:

     @duration field == null ? 0 : @duration field
    

    And then use this field "Duration mirror" in the calcluation fields in WO: instead "@all of duration field" use "@all of duration mirror"

    Rainer
    rg@delos-consulting.com

    0
    Comment actions Permalink
  • Paul Lyet

    Thanks again Rainer.. The duration field is a required field as is the category field. I'm not sure what's up but for both Prog and Tech fields if there has not yet been a value associated it is showing 1.00.. Any ideas?

    0
    Comment actions Permalink
  • Rainer Grabowski

    You mean, if there's no time slip related then 1 is showed? Simply said it's a kind of error notification that the for-loop doesn't find any item.

    You can avoid it by adding this line (as last line in your calculation):

    type.length == 0 ? 0 : proghrs   
    

    respectively : techhrs

    Rainer

    0
    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk