web stats
Error when making a custom String.prototype function - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 01-03-2014, 03:03 AM
StefanScholte StefanScholte is offline
 
Join Date: May 2009
Location: Netherlands, Harderwijk
Posts: 321
StefanScholte is on a distinguished road
Default 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
Reply With Quote
  #2  
Old 01-03-2014, 06:01 AM
cory_cole cory_cole is offline
Mirth Guru
 
Join Date: Mar 2012
Posts: 1,311
cory_cole is on a distinguished road
Default

Your code as padLeft but the error is for leftPad. Looks like you have typed in incorrectly.
Reply With Quote
  #3  
Old 01-03-2014, 06:11 AM
StefanScholte StefanScholte is offline
 
Join Date: May 2009
Location: Netherlands, Harderwijk
Posts: 321
StefanScholte is on a distinguished road
Default

Quote:
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
Reply With Quote
  #4  
Old 01-03-2014, 06:27 AM
cory_cole cory_cole is offline
Mirth Guru
 
Join Date: Mar 2012
Posts: 1,311
cory_cole is on a distinguished road
Default

Happens to all of us.
Reply With Quote
Reply

Tags
code template, prototype, string

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 11:27 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Mirth Corporation