esmith Posted March 15, 2010 Share Posted March 15, 2010 Any ideas why the following code validates fine, correctly replacing all placeholders in a tagged resource file, but seems to return nothing when rule is assigned to a text frame on the template? // custom superscript code function superSize ( str ) { str = str.replace(/(\(r\))/ig,"<superscript>®</superscript>"); str = str.replace(/(\(c\))/ig,"<superscript>©</superscript>"); str = str.replace(/(\(tm\))/ig,"<superscript>™</superscript>"); str = str.replace(/(\(sm\))/ig,"<superscript>™</superscript>"); return str; } var disclaimer = Resource("disclaimer-english-1").content; // only the CPDS signs have a unique disclaimer if (Field("page") == "buckslip") { disclaimer = Resource("disclaimer_english_2").content; } // replace [period] placeholder with correct number of months if (Field("campaign").indexOf("12") > -1) { disclaimer = disclaimer.replace("[period]","12"); } else disclaimer = disclaimer.replace("[period]","6"); // insert departments for 12PS signs if (Field("department") != "") { var departments = Field("department").split("<br>"); var deptString = departments.join(", "); disclaimer = disclaimer.replace("[department]",deptString + " "); } else disclaimer = disclaimer.replace("[department]",""); return superSize(disclaimer); I thought it had something to do with the .content property, but if I remove that I can't validate at all. I have the tagged value box checked, and yes, the record in question should return something as it falls under the Resource("disclaimer-english-1") condition. Link to comment Share on other sites More sharing options...
esmith Posted March 16, 2010 Author Share Posted March 16, 2010 While I'd still like to figure out how to make the original code work, my workaround for this project was to copy the contents of the text resources and paste them into JavaScript Globals as separate vars. Then, instead of assigning a rule's variable to a text file, I assigned it to the global variable. So this: var disclaimer = Resource("disclaimer-english-1").content; becomes this: var disclaimer = eng_disc_1; with eng_disc_1 being defined as a global variable available to multiple rules. Link to comment Share on other sites More sharing options...
Dan Korn Posted March 16, 2010 Share Posted March 16, 2010 It's hard to diagnose without having the job to run. The general way to debug a rule at composition time is to add some Print function calls at various points in the code, compose, and then look in the log (.msg) file. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.