george.goodeluinas Posted January 27, 2010 Share Posted January 27, 2010 I am trying to create a user defined function (rules manual p64). I created a new node and function. I used the example in the book but when i select the the function from the "Building Blocks" into a rule and try to validate....I get the message: Reference Error:Dateyyyymmdd is not defined. How can it not be defined....after all, it is in the "Building Blocks". As my mother would always say to me Where did I go Wrong? Geodine.js Geodine = new Object; Geodine.Dateyyyymmdd = function() { var thedate = new Date(); return FormatDate(thedate, "yyyymmdd"); } Geodine.Dateyyyymmdd.description = "Return Date in the yyyymmdd format"; Geodine.Dateyyyymmdd.syntax ="Dateyyyymmdd()"; Link to comment Share on other sites More sharing options...
Dan Korn Posted January 27, 2010 Share Posted January 27, 2010 The last line should be: Geodine.Dateyyyymmdd.syntax = "Geodine.Dateyyyymmdd()";You're declaring the function as a member of the global Geodine object, not as a global function itself. Link to comment Share on other sites More sharing options...
george.goodeluinas Posted January 28, 2010 Author Share Posted January 28, 2010 Dan, Thanks for the response. I tried your changes, but I get the same error message. I have even tried to comment out the description and syntax lines as it said in the book. but same error. It won't validate. Geodine = new Object; Geodine.Dateyyyymmdd = function() { var thedate = new Date(); return FormatDate(thedate, "yyyymmdd"); } Geodine.Dateyyyymmdd.description = "Return Date in the yyyymmdd format"; Geodine.Dateyyyymmdd.syntax ="Geodine.Dateyyyymmdd()"; Link to comment Share on other sites More sharing options...
Dan Korn Posted January 28, 2010 Share Posted January 28, 2010 Hmm. I copied the syntax above into a .js file in my plug-ins folder, and it showed up in the Building Blocks for me. I typed "return " and then clicked "Insert" and the result was this rule, which validated just fine (result was "20100128"): return Geodine.Dateyyyymmdd()You may need to close and re-open the Rules dialog for the changes to the .js plug-in file to take effect. Can you post the syntax of your actual rule, not just the plug-in syntax? Link to comment Share on other sites More sharing options...
george.goodeluinas Posted January 29, 2010 Author Share Posted January 29, 2010 Thanks Dan, return Geodine.Dateyyyymmdd() fixed it. But why when I insert it from the building blocksdo I only get return Dateyyyymmdd() Thanks George Link to comment Share on other sites More sharing options...
Dan Korn Posted January 29, 2010 Share Posted January 29, 2010 Thanks Dan, return Geodine.Dateyyyymmdd() fixed it. But why when I insert it from the building blocksdo I only get return Dateyyyymmdd() Did you change the last line of the .js file as I suggested? The last line should be: Geodine.Dateyyyymmdd.syntax = "Geodine.Dateyyyymmdd()";You're declaring the function as a member of the global Geodine object, not as a global function itself. And like I said, you may need to close and re-open the Rules dialog for the changes to the .js plug-in file to take effect. Link to comment Share on other sites More sharing options...
george.goodeluinas Posted January 29, 2010 Author Share Posted January 29, 2010 Dan, I did due all yo suggested, and it now works. .js file Geodine = new Object; Geodine.Dateyyyymmdd = function() { var thedate = new Date(); return FormatDate(thedate, "yyyymmdd"); } Geodine.Dateyyyymmdd.description = "Return Date in the yyyymmdd format"; Geodine.Dateyyyymmdd.syntax ="Geodine.Dateyyyymmdd()"; What fixed it was changeing the rule to : return Geodine.Dateyyyymmdd() I was just trying now to understand why when you double click it in the building blocks it returns: return Dateyyyymmdd() instead of return Geodine.Dateyyyymmdd() Thanks again for all your help. George PS...... Is Doug Cogan still around, or Lauren Nakoney? Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.