Facility Control

 View Only
  • 1.  automatic suffix

    Posted 01-19-2015 20:43

    Hi there, I'm trying to write a script that will automatically add a suffix into a text field. Here's what I've got so far, based on Javascript, but I get an error that says it can't find the "indexOf" function.

    var self = this.getValue();

    // if text string already contains '%', then we're done

    if (this.indexOf("%") >= 0){

    ogscript.debug('done');

    }

    // otherwise, add the '%'

    else {this.setValue(self + '%');

    }

    What am I missing here?


    Thanks!



  • 2.  RE: automatic suffix

    Posted 01-19-2015 20:47

    "this" is a Param object and has no indexOf function.

    Strings objects do have that function.

    `var self = this.getValue();

    // if text string already contains '%', then we're done

    if (self .indexOf("%") >= 0){

    ogscript.debug('done');

    }

    // otherwise, add the '%'

    else {this.setValue(self + '%');

    }`

    #DashBoard