How to send notification (494 Views)
Reply
Regular Advisor
Blue_1
Posts: 160
Registered: ‎12-01-2010
Message 1 of 5 (494 Views)
Accepted Solution

How to send notification

I have a weekly running scheduler, which queries all the expired docs. I need to send them as tabular format in an email

 

something like

 

KM Documents Expired                              Expiration Date

 

KM10011                                                         09/01/2013

KM10012                                                         09/02/2013

 

Any thoughts ?

Please use plain text.
Advisor
AlexRussell
Posts: 11
Registered: ‎10-31-2011
Message 2 of 5 (477 Views)

Re: How to send notification

Instead of a report schedule records that runs once per record found, you can
make a schedule record that calls some javscript that does the whole job.

schedule record:
class: problem
expiration: next date/time to run
scheduled class: problem
name: a nice name
status: rescheduled
repeat interval: the one you want
description: a useful description
javascript:
lib.bchAJRTest.SearchAndEmail();

but replace bchAJRTest with the name of your ScriptLibrary

in the bchAJRTest ScriptLibrary is the following code:

 

/ the to has to be contact name in the operator file with a valid email
function SendMailOne(subject, body, to)
{
var rteReturnValue = new SCDatum();
var argNames = new SCDatum();
var argVals = new SCDatum();
var temp = new SCDatum();

	argVals.setType( 8 );  // 8 is array
	argNames.setType( 8 );
	temp.setType(2);
	
	temp.setValue("query");
	argNames.push(temp);
	temp.setValue("names");
	argNames.push(temp);
	temp.setValue("string1");
	argNames.push(temp);
	
	temp.setValue(to);
	argVals.push(temp);
	temp.setValue(body);
	argVals.push(temp);
	temp.setValue(subject);
	argVals.push(temp);
	
	system.functions.rtecall( "callrad", rteReturnValue, "macro.mail1", argNames, argVals, false );
}

//SendMailOne("test subject", "test body\r\nline2\r\n;line with tab\taftertab\r\nast line", "alrussel");

function SearchAndEmail()
{
var file=new SCFile("probsummary");  // pick the file you want to search here
var query;
var body;

	query="number # \"IM000404\"";  // put in the real query here
	if ( file.doSelect(query) == RC_SUCCESS )
		{
		body="The first line of this email\r\n\r\n"; // \r = CR \n = new line \t = tab
		do
			{
			body+="Number: " + file.number + "\t\tCategory: " + file.category + "\r\n";
			}
		while ( file.getNext() == RC_SUCCESS );
		
		body+="\r\n";
		body+="The last line\r\n";
		
		SendMailOne("Test email subject line", body, "alrussel"); // alrussel is a valid contact name in the contacts file
		}
	
}

 

Please use plain text.
Regular Advisor
Blue_1
Posts: 160
Registered: ‎12-01-2010
Message 3 of 5 (474 Views)

Re: How to send notification

hi

 

Thanks for the reply, small question

 

what does javascript:  mean ?

are you calling lib.bchAJRTest.SearchAndEmail(); from the javascript tabof scheduler ? Do we need to mention anything in the application field, like 'script.execute' ?

Please use plain text.
Advisor
AlexRussell
Posts: 11
Registered: ‎10-31-2011
Message 4 of 5 (445 Views)

Re: How to send notification

javascript&colon is the web interface replacing a : with the word &colon.

 

You just have to put the valid javascript in the javscript tab, no application is required for the schedule record. yor javascript lilbrary will likely not be called bchAJRTest, just repalce that with your library name.

 

the line

 

lib.libname.functionname();

 

is just telling javascript to run the function. lib is where all the javscript libraries are. libname is the name of one particular lilbrary that you wrote or updated, and functioname is a function in libname.

Please use plain text.
Regular Advisor
Blue_1
Posts: 160
Registered: ‎12-01-2010
Message 5 of 5 (359 Views)

Re: How to send notification

Hell0 Alex

i need a small help on fixing alignment of this email

My email body is pretty much good, but i have a column called subcategory, because values of subcategory is dynamic( some are long and some are short) my aligment is not working


KM DOC Date Subcat KM doc expiring Date Subcat

KM10000669 11/30/13 00:00:00 AAAAAAAAAAAA KM10000669 11/30/13 00:00:00 BBBBBBBBBBB
KM10000669 11/30/13 00:00:00 AAAA KM10000669 11/30/13 00:00:00 BBBBBBBBBBB
KM10000669 11/30/13 00:00:00 CCCCCCCCCCCCCCCCCCCC KM10000669 11/30/13 00:00:00 BBBBBBBBBBB

Because the subcategory column is having different length, alignment is not working, please help me fix this

Thanks
Please use plain text.
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation