Friday, July 25, 2008

Customizing Forms in HRMS-Part1(Custom Form)

Hi All,
Quite often we get the requirements for restricting access and fuctionalites in form which is normally done either by formspersonalization or custom.pll or standard form modification
In HRMS quite often i have seen the restrictions like create applicant ,create placment ,create employement functionalities to certain responsibilities...For these forms there is no need to do forms personalization ...because oracle have developed these forms in a architecture to allow common customisations by doing setup..
1.Custom form functionality
2.Task Flows..
First let us look at the custom Form Functionality..
For example
For some responsibility I want to allow the user to create Employees, Contingent workers and Other but not Applicants..Lets see how implement this requirement
1: Define custom form
Responsibility: Global HR Manager (or alike)
Navigation : Security > CustomFormSelect 'Combined Person & Assignment Form'
as Form to be customized


Customized version
Give your custom form a unique name and titles.
SaveRestrictions
Type: Restrict by person action
Value: Create employmentAdd any actions you want to have enabled on the form.

2. Define form function that uses this custom function
Responsibility: System AdministratorNavigation: Application > functionCreate a new form functionType: FormForm: Combined Person & Assignment FormParameters: HR_CUSTOMIZATION="xx_your_custom_form" in our case it will beHR_CUSTOMIZATION="CREATE ACTION"

3. Add this new function in your menuResponsibility: System Administrator
Navigation: Application > menuQuery the menu your responsibility is using and replace the existing function with the newly created custom function.
Please note that HR_CUSTOMIZATION parameter does not work in conjunction with WORKFLOW_NAME (Task Flow)parameter

Tuesday, July 1, 2008

Sending mails from PLSQL..UTL_SMTP

Hi All,
Recently we got a requirement for sending mail..on a business logic..we tried to set the mail system on alerts..but still not succesful due to some other reasons..which we are still figuring out..
In the mean time we tried to send mail functionality from PLSQL..This is one package we found out in asktom.oracle.com...use this one directly to compile ..and send mail...it works...

create or replace package XX_DOF_mail_pkg as
type array1 is table of varchar2(255);
procedure send( p_sender_email in varchar2,
p_from in varchar2,
p_to in array default array(),
p_cc in array default array(),
p_bcc in array default array(),
p_subject in varchar2,
p_body in long );
end;


create or replace package body mail_pkg as
g_crlf char(2) default chr(13)chr(10);
g_mail_conn utl_smtp.connection;
g_mailhost varchar2(255) := 'govmail1.gov.com;--Give your smtp mail address..check whether it exists in teh host file or not...
function address_email( p_string in varchar2,
p_recipients in array ) return varchar2 is
l_recipients long;
begin for i in 1 .. p_recipients.count loop
utl_smtp.rcpt(g_mail_conn, p_recipients(i) );
if ( l_recipients is null ) then
l_recipients := p_string p_recipients(i) ;
else
l_recipients := l_recipients ', ' p_recipients(i);
end if;
end loop;
return l_recipients;
end;
procedure send( p_sender_email in varchar2,
p_from in varchar2 ,
p_to in array default array(),
p_cc in array default array(),
p_bcc in array default array(),
p_subject in varchar2 ,
p_body in long ) is
l_to_list long;
l_cc_list long;
l_bcc_list long;
l_date varchar2(255) default to_char( SYSDATE, 'dd Mon yy hh24:mi:ss' );
procedure writeData( p_text in varchar2 ) as
begin
if ( p_text is not null ) then
utl_smtp.write_data( g_mail_conn, p_text g_crlf );
end if;
end;
begin
g_mail_conn := utl_smtp.open_connection(g_mailhost, 25);
utl_smtp.helo(g_mail_conn, g_mailhost);
utl_smtp.mail(g_mail_conn, p_sender_email);
l_to_list := address_email( 'To: ', p_to );
l_cc_list := address_email( 'Cc: ', p_cc );
l_bcc_list := address_email( 'Bcc: ', p_bcc );
utl_smtp.open_data(g_mail_conn );
writeData( 'Date: ' l_date );
writeData( 'From: ' nvl( p_from, p_sender_email ) );
writeData( 'Subject: ' nvl( p_subject, '(no subject)' ) );
writeData( l_to_list ); writeData( l_cc_list );
utl_smtp.write_data( g_mail_conn, '' g_crlf );
utl_smtp.write_data(g_mail_conn, p_body );
utl_smtp.close_data(g_mail_conn );
utl_smtp.quit(g_mail_conn); end;
end;
/*******************************************************/
use this script to test the error....
begin mail_pkg.send
( p_sender_email => 'murthyganjam@gmail.com',
p_from => 'Oracle Database Account <mailto:murthyganjam@gmail.com,
p_to => mail_pkg.array( 'murthyganjam@gmail.com', 'murthyganjam@gmail.com' ),
p_cc => mail_pkg.array( 'murthyganjam@gmail.com' ),
p_bcc => mail_pkg.array( 'murthyganjam@gmail.com' ),
p_subject => 'Testing mailing package',
p_body => 'Hello murthy, this is the mail you need' );
end;
in case you want to handle the exception block for this program use the following exception block in the package...


EXCEPTION
WHEN UTL_SMTP.INVALID_OPERATION THEN
dbms_output.put_line(' Invalid Operation in SMTP transaction.');
WHEN UTL_SMTP.TRANSIENT_ERROR THEN
dbms_output.put_line(' Temporary problems with sending email - try again later.');
WHEN UTL_SMTP.PERMANENT_ERROR THEN
dbms_output.put_line(' Errors in code for SMTP transaction.');