dwhetzel Posted October 26, 2012 Share Posted October 26, 2012 Spent the better part of the day trying to figure this out. Searched and searched the forums still stumped. If I comment out the line with "toTitleCase" in it validation passes and it works fine. I've tried all kinds of variations on the name to no avail. Error when validating scrpt... In an OnRecordStart rule. TypeError:Field("RegTypeB").toTitleCase is not a function Thanks so much for any help with this it's driving me crazy. (short drive that it is) if (Field("RegTypeB") == "Government for the people") { // statements to perform if // expression is true FusionPro.Composition.AddVariable("RegTypeB", Field("RegTypeB").toUpperCase()); FusionPro.Composition.AddVariable("RegTypeB", Field("RegTypeB").toLowerCase()); FusionPro.Composition.AddVariable("RegTypeB", Field("RegTypeB").toTitleCase()); var botBar = FindTextFrame("botBar"); botBar.suppress = false; } else if (Field("RegTypeB") == "Sponsor") { // statements to perform if // expression is true FusionPro.Composition.AddVariable("RegTypeB", Field("RegTypeB").toUpperCase()); var botBar = FindTextFrame("botBar"); botBar.suppress = false; } else if (Field("RegTypeB") == "Staff") { // statements to perform if // expression is true FusionPro.Composition.AddVariable("RegTypeB", Field("RegTypeB").toUpperCase()); var botBar = FindTextFrame("botBar"); botBar.suppress = false; } else if (Field("RegTypeB") == "Press") { // statements to perform if // expression is true FusionPro.Composition.AddVariable("RegTypeB", Field("RegTypeB").toUpperCase()); var botBar = FindTextFrame("botBar"); botBar.suppress = false; } else if (Field("RegTypeB") == "Industry") { // statements to perform if // expression is true FusionPro.Composition.AddVariable("RegTypeB", Field("RegTypeB").toUpperCase()); var botBar = FindTextFrame("botBar"); botBar.suppress = true; } else { // statements to perform if // none of the above expressions is true FusionPro.Composition.AddVariable("RegTypeB", Field("RegTypeB").toUpperCase()); var botBar = FindTextFrame("botBar"); botBar.suppress = true; } Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted October 26, 2012 Share Posted October 26, 2012 The message is correct; toTitleCase is not a method of the String object. However, there is a global function named ToTitleCase, which is part of FusionPro. So you want to do this: FusionPro.Composition.AddVariable("RegTypeB", ToTitleCase(Field("RegTypeB")));Also, why do you have three lines like this in a row? FusionPro.Composition.AddVariable("RegTypeB", Field("RegTypeB").toUpperCase()); FusionPro.Composition.AddVariable("RegTypeB", Field("RegTypeB").toLowerCase()); FusionPro.Composition.AddVariable("RegTypeB", ToTitleCase(Field("RegTypeB")));Only the last one is going to have any effect. It seems that the logic in your rule can be reduced to this: var RegTypeB = Field("RegTypeB"); FusionPro.Composition.AddVariable("RegTypeB", RegTypeB.toUpperCase()); switch (RegTypeB) { case "Government for the people": FusionPro.Composition.AddVariable("RegTypeB", ToTitleCase(RegTypeB)); case "Sponsor": case "Staff": case "Press": break; default: FindTextFrame("botBar").suppress = true; } Quote Link to comment Share on other sites More sharing options...
dwhetzel Posted October 26, 2012 Author Share Posted October 26, 2012 Thanks Dan! That line worked like a charm of course you already knew that. I will work on incorporating your reduced code into my rule instead. Have a great weekend! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.