Community

Detect value is either zero or negative Answered

Hi,

i want to detect a value in a field either as zero or negative so that i can decide value of another field depending upon it. How to do that?

Was this article helpful?

0 out of 0 found this helpful

Comments

6 comments

  • Avatar
    Vladimir Dimitrijević

    Hi Sara,

    It is a little bit confusing. Maybe there is no need to fill new field with 0 or -1, but it depends on your requirements. What kind of value you want to detect?

    Best regards,
    Vladimir

    0
  • Avatar
    Sara

    Hi vladimir.....

    For eg. a field "pqr" has a value  -54.18. I want to detect this field as negative value and export "not ok" if negative or " ok" if positive..Hope it is clear.

    0
  • Avatar
    Vladimir Dimitrijević

    Hi Sara,

    Easiest solution is if you are using export script, you can assign the value in script. If not, you can create new field, add script rule (warning) to this field to check if value is less than 0 and assign a value, for example:

    double pqr = Convert.ToDouble(Context.Field("pqr").Text);
    if(pqr < 0)
       Context.Field("YOURFIELD").Text = "not ok";
    else
       Context.Field("YOURFIELD").Text = "ok";

     

    Best regards,
    Vladimir

    0
  • Avatar
    Sara

    Hi Vladimir,

    When i execute that code in  c#, i get an error  "The name convert does not exist in the current context". 

    0
  • Avatar
    Vladimir Dimitrijević

    Hi Sara,

    System.Convert.ToDouble(....

    Best regards,
    Vladimir

    1
  • Avatar
    Sara

    Thanks Vladimir. Its working fine. Thanks very much

    1

Please sign in to leave a comment.