count category items and assigning values

Answered

Comments

4 comments

  • Rainer Grabowski (FVM)

    Hi Alex,

    values you can assign this way:

    var cat = @category-field;
    var valN = cat.indexOf("N") >= 0 ? 1 : 0
    var valE = cat.indexOf("E") >= 0 ?  1 : 0
    var valW = cat.indexOf("W") >= 0 ? 1 : 0
    var  valHome = cat.indexOf("NW") >=  0 ? 10 : 0  
    
    var sum = valN + valE + valW + valHome
    sum
    

    To get the value of how man categories have been selected use:

    @category-field.length
    

    That counts the selected categories in a multi choice category field (also usable for @all of category-field for counting categories in a related app).

    Rainer

    2
    Comment actions Permalink
  • Alex White

    great thanks

    0
    Comment actions Permalink
  • Rainer Grabowski (FVM)

    Good. Did you see my solution (much better for your needs then this solution, I think) for the same problem in the Globiflow user forum (your topic: "search & match category fields")?

    0
    Comment actions Permalink
  • Alex White

    I did thanks, I have not had a chance to implement it yet. Have some other simpler projects to finish off first. When i get it up and running I'll let you know.

    0
    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk