Alec Posted October 4, 2011 Share Posted October 4, 2011 Hi GuysI have the below script.it sets the previous day of the week in the title of a chart.The If case verfiy if the previous day is Sunday and set it to Friday so we can avoid weekends.Today I noticed I am still seeing Friday on the title!!I tried to put == in the If case, I ended up having Friday as a previous day of tuesday.Anybody can help?!Thanks! <script>/*** Called before generation of chart model to GeneratedChartState.* * @param chart* Chart* @param icsc* IChartScriptContext*/ function beforeGeneration( chart, icsc ){importPackage (Packages.java.text); yesterday = BirtDateTime.addDay(new Date(), -1);df = new SimpleDateFormat("EEEE");stringYesterday = df.format(yesterday).toString();if(stringYesterday = "Sunday"){stringYesterday = "Friday";}chart.getTitle().getLabel().getCaption().setValue("Top 5 Callers on " + stringYesterday);}</Script> Link to comment Share on other sites More sharing options...
thescientist Posted October 4, 2011 Share Posted October 4, 2011 you're if statement should be if(stringYesterday == "Sunday"){ stringYesterday = "Friday";}; note: there's a huge difference between = and ==. It's not like you do one over the other just because the other one doesn't work right. If you know what they are doing, then you will know why to use it, and if something's wrong, then it's probably something else. For the record, you may want to alert or log stringYesterday before the if statement to make sure it's what you think it is. (correct casing, format, etc) Link to comment Share on other sites More sharing options...
Alec Posted October 4, 2011 Author Share Posted October 4, 2011 You rock!it is working perfect now.would you please explain to me what the different and when to be used.I am new to JS and trying to learn quicklyThanks! Link to comment Share on other sites More sharing options...
Drycodez Posted October 4, 2011 Share Posted October 4, 2011 Click here! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.