Need help with sintax

Comments

9 comments

  • Stefan Ukena

    Hi Luis,

    you cannot actually ASSIGN a value to the category field, but you can make the calculation output the result you want. This should work:

    var num = @Number;
    
    if (num < 2) || (num >= 5) {
      "NOT OK";
    } else {
      "OK";
    }
    

    Please note: this will output "NOT OK" for any number smaller 2 (i.e. num < 2) as well as numbers greater or equal 5 (i.e. num >= 5). -- That is how I understood your question...

    Best,
    Stefan

    dieKollaborateure.com - Podio Training+Consulting+Development English & Deutsch

    0
    Comment actions Permalink
  • Luis Diego Flores

    Hello Stefan,
    Thank you for your prompt reply.
    missing somethign here, so basically the calculation will return a value but it will not trigger any change to values on the category field (OK & NOT OK), Is this correct?

    I am getting error message: Preview: Script syntax error: Unexpected token ILLEGAL.

    Thanks
    Luis

    0
    Comment actions Permalink
  • Matt Werner

    Luis,

    Copy and paste won't work for the relationship to define your variable. You will have to type that section in by hand. I assume that is where the syntax error is coming from. Podio doesn't like random @ floating around in calculation fields.

    0
    Comment actions Permalink
  • Luis Diego Flores

    I did all I was told and still not working.

    if (num < 2) || (num >= 5) {
    "NOT OK";
    } else {
    "OK";
    }

    0
    Comment actions Permalink
  • Luis Diego Flores

    I think I am close, however I need to be able to use the calculation and the result needs to be "string" and not numeric, I read multiple articles and it says that output can be Date, Numeric or text, any ideas?

    0
    Comment actions Permalink
  • Mike Adams

    Hi Luis,

    The first time you run a calculation sets the field type; text, number, date etc. Quite often if you are experimenting with code you inadvertently output the wrong format.

    To get around this problem, create a new calculation field and just output @A Text Field, save the template and go ahead with your calculation. From then on Podio will know that this calculation is a text field.

    BTW, do you also need help with spelling? Your subject heading is quite amusing for an English speaker because you spell it syntax. ;-)

    0
    Comment actions Permalink
  • Luis Diego Flores

    Dont think I need help with spelling since you and pretty much everyone understood my writing.
    But thanks for asking ;-)

    On the other hand Im not following what you mean, I am trying to reference a numeric field but want calculation output to be text, is it posible or not ?

    0
    Comment actions Permalink
  • Mike Adams

    Hi Luis, my apologies for the language comment, it only makes sense to native English spellers.

    It is possible to reference a numeric field (or a date, relationship, number field) and output the calculation in your choice of text, number, date

    The trick is to avoid doing any output in the calculation while you are constructing it which is not the output field type that you need.

    The safe way to make sure this happens is. Make a new calculation field and do a very simple one line fake calculation which outputs the type of data you want. So if you need your output to be text just do a @Text where "tect' s one of your text fields. Then save the template, reopen it and delete the @Text line. From now on this calculation is configured to output text.

    Does it make sense?

    0
    Comment actions Permalink
  • Luis Diego Flores

    Hello Mike, no need to worry, I was just joking. I do apreciate your help on this. Thank you again.

    Here is how I solved it:
    @Title
    if (@CO2 Level < 2) {
    "NOT OK"
    } else {
    if (@Nivel de Ozono >= 5) {
    "NOT OK"
    } else {
    "OK"
    }
    }

    0
    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk