Announcement

Collapse
No announcement yet.

Error when making a custom String.prototype function

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Error when making a custom String.prototype function

    Hi All,

    I have made a function within the code templates

    Code:
    String.prototype.padLeft = function(str,len) {
    	var padded = this;
    	while (padded.length < len)
    		padded = str + padded;
    	return padded;
    }
    this I gave the type: Code and context: messages

    the function works fine within destination connectors but when I used it within another code template it gives the error :
    TypeError: Cannot find function leftPad in object 296770

    I've tried several other types and contexts but of no avail.

    Is this a bug or is it not possible to use prototyping within code templates
    If somebody can shed some light on this I will be very happy

    with kind regards
    Stefan Scholte

    btw: Mirth Connect 3.0.1
    Stefan

    Mirth Certified|Epic Bridges Certified|Cloverleaf Level 2 Certified

  • #2
    Your code as padLeft but the error is for leftPad. Looks like you have typed in incorrectly.

    Comment


    • #3
      Originally posted by cory_cole View Post
      Your code as padLeft but the error is for leftPad. Looks like you have typed in incorrectly.
      OMG

      Thank you Cory
      I feel like an complete idiot, I completely missed that.
      Trying so hard that I missed such a small typo
      Stefan

      Mirth Certified|Epic Bridges Certified|Cloverleaf Level 2 Certified

      Comment


      • #4
        Happens to all of us.

        Comment

        Working...
        X