Focal Point Banner


As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.

Join the TIBCO Community
TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.

  • From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
  • Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
  • Request access to the private WebFOCUS User Group (login required) to network with fellow members.

Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.


Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [CLOSED]JS for first day of current month

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[CLOSED]JS for first day of current month
 Login/Join
 
Member
posted
Good Morning all,

I have written a js function to add to my html page to populate a calendar with the first day of the current month. I think I have the code correct I get the alert when I run it outside of WF however when I put it in the html composer it doesn't do anything. Here is the code. Any help would be appreciated.

if(typeof(bRuntime) != 'undefined') {
// TODO: Add your inline runtime code here
}
//Begin function window_onload
function window_onload() {
UpdateData();
// TODO: Add your event handler code here
//add onInitialUpdate() function to make changes before initial run of the reports
function newdate_start() {
var date = new Date();var firstDay = new Date(date.getFullYear(), date.getMonth(), 1);
var startdate = (firstDay.getMonth() + 1) + '/' + (firstDay.getDate()) + '/' + firstDay.getFullYear();
alert(startdate);}
}

This message has been edited. Last edited by: <Emily McAllister>,


WebFOCUS 8.05
Windows , Excel, PDf, HTML
 
Posts: 27 | Location: Nashville Tn | Registered: January 12, 2010Report This Post
Expert
posted Hide Post
How are you calling your function? If you do not call it then it will not execute.

If you need this to run after the document is fully loaded then look at the line above your function - there's a big clue there!

Alternatively you could use a $(document).ready() call.

If none of this means anything to you then you may benefit by visiting w3schools.com and running through some tutorials on HTML, JavaScript and jQuery.

T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
 
Posts: 5694 | Location: United Kingdom | Registered: April 08, 2004Report This Post
Master
posted Hide Post
If we take your code and clean it up so we can see possible issues, we get this:

if(typeof(bRuntime) != 'undefined') {
	// TODO: Add your inline runtime code here
}

//Begin function window_onload
function window_onload() {
	UpdateData();

	// TODO: Add your event handler code here
	//add onInitialUpdate() function to make changes before initial run of the reports
	
	function newdate_start() {
		var date = new Date();var firstDay = new Date(date.getFullYear(), date.getMonth(), 1);
		var startdate = (firstDay.getMonth() + 1) + '/' + (firstDay.getDate()) + '/' + firstDay.getFullYear();
		alert(startdate);
	}
}


Did you mean to put newdate_start() method inside of the window_onload() method?

Maybe you meant to do this:
if(typeof(bRuntime) != 'undefined') {
	// TODO: Add your inline runtime code here
}

//Begin function window_onload
function window_onload() {
	UpdateData();

	// TODO: Add your event handler code here
	//add onInitialUpdate() function to make changes before initial run of the reports
	
	newdate_start();
}

function newdate_start() {
	var date = new Date();var firstDay = new Date(date.getFullYear(), date.getMonth(), 1);
	var startdate = (firstDay.getMonth() + 1) + '/' + (firstDay.getDate()) + '/' + firstDay.getFullYear();
	alert(startdate);
}



- FOCUS Man, just FOCUS!
-----------------------------
Product: WebFOCUS
Version: 8.1.04
Server: Windows 2008 Server
 
Posts: 578 | Registered: October 01, 2014Report This Post
Member
posted Hide Post
Gavin,
Thank you and sorry if the code pasted in poorly.
My explanation of my issue sucked, What I need to do is get the first day of the current month, load it into the calendar1 box in my html form so that all reports in my portal run with that as the default start date. I already have the end date set the way I need it, I just don't know anything about where to add JS inside the composer to make it work, and the solutions I found in the knowledge base don't do what I need. Thanks again for the information I think if I understand your answer and do it this way it should do what I want to do.


WebFOCUS 8.05
Windows , Excel, PDf, HTML
 
Posts: 27 | Location: Nashville Tn | Registered: January 12, 2010Report This Post
Virtuoso
posted Hide Post
That function can be reduced to:
function newdate_start() {
	var date = new Date();	// Current day, this month
	date.setDate(1);	// Start of current month

	// I concatenate strings like this; the result is the same as your concat.
	var startdate = ([date.getMonth() +1, date.getDate(), date.getFullYear()]).join('/');
//	alert(startdate);

	// Use it in an IBI date control using JQuery (don't forget the leading #)
	$('#uniqueIdentifierOfYourDateControl').val(startdate);
}


Now it is possible that the value you set this way on load gets overwritten by the IBI chaining code, which runs code to fill controls on load as well. If that happens, move the call to this function into a (new) function onInitialUpdate().


WebFOCUS 8.1.03, Windows 7-64/2008-64, IBM DB2/400, Oracle 11g & RDB, MS SQL-Server 2005, SAP, PostgreSQL 11, Output: HTML, PDF, Excel 2010
: Member of User Group Benelux :
 
Posts: 1669 | Location: Enschede, Netherlands | Registered: August 12, 2010Report This Post
Silver Member
posted Hide Post
Hi MG

Try this

function newdate_start() {
var date = new Date();var firstDay = new Date(date.getFullYear(), date.getMonth(), 1);
var startdate = (firstDay.getMonth() + 1) + '/' + (firstDay.getDate()) + '/' + firstDay.getFullYear();
alert(startdate);
IbComposer_setCurrentSelection('calendar1',startdate, false);

}

Best of Luck
Barry


WebFOCUS 8
Windows, All Outputs
 
Posts: 34 | Registered: September 08, 2015Report This Post
Member
posted Hide Post
Hi Barry,
Long time no talk to....... It is great to hear from you. Thanks for the suggestion, it didn't fix the issue I was having however your input is always welcome.


WebFOCUS 8.05
Windows , Excel, PDf, HTML
 
Posts: 27 | Location: Nashville Tn | Registered: January 12, 2010Report This Post
Member
posted Hide Post
Thanks for all the information and suggestions, I now have my calendar control displaying the first day of the current month in the control,,,, YEA, only one issue left to resolve. All of the reports in the portal are running on the default date in the fexes rather than with the new default in the cal control...... can't just remove the default, that doesn't work either.... I am sure this is something real simple that I am just missing..... oh Monday... how I lov you...NOT


WebFOCUS 8.05
Windows , Excel, PDf, HTML
 
Posts: 27 | Location: Nashville Tn | Registered: January 12, 2010Report This Post
Guru
posted Hide Post
MG,

I see you asked another question. If the parameters are not being passed to the report add in the following at the top of the focexec:

-SET &ECHO=ALL;
-? &

Once the report appears - right mouse click and select view source, scroll until you see the list of variables appear ( usually green text). Check to see if your variables are listed.
Check within the code to see if the values are being picked up.


WebFOCUS Version 8 Technical Library
Above is the link to the document library. Click the "+" to open the links. Assuming you are using Dev Studio along with BI Portal - refer to the Developer Studio, Reporting Language, Reporting Tools and Business Inteligence Poral links for further documentation.

Post another topic for this specific question - this might generate more assistance for you too.

Thank you for participating in the Focal Point Forum.

Kind Regards,
Tamra Colangelo
IBI Focal Point Moderator


WebFOCUS 8x - BI Portal, Developer Studio, App Studio, Excel, PDF, Active Formats and HTML5
 
Posts: 487 | Location: Toronto | Registered: June 23, 2009Report This Post
Expert
posted Hide Post
In an HTML Composer edited HTML file, you will find these two comments:

// TODO: Add your event handler code here
	//add onInitialUpdate() function to make changes before initial run of the reports


As Wep5622 mentioned, heed them.

Create a function called onInitialUpdate(), then put all the JS that needs to be executed upon load.

Something like:

...
function onInitialUpdate()
{
    newdate_start();
}
...


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [CLOSED]JS for first day of current month

Copyright © 1996-2020 Information Builders