<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>user hooks Archives | The Curious Technoid</title>
	<atom:link href="https://thecurioustechnoid.com/tag/user-hooks/feed/" rel="self" type="application/rss+xml" />
	<link>https://thecurioustechnoid.com/tag/user-hooks/</link>
	<description>technology made simple</description>
	<lastBuildDate>Fri, 12 Jun 2020 08:58:42 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://thecurioustechnoid.com/wp-content/uploads/2020/06/cropped-fav-1-32x32.png</url>
	<title>user hooks Archives | The Curious Technoid</title>
	<link>https://thecurioustechnoid.com/tag/user-hooks/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>HR API Hooks / User Hooks</title>
		<link>https://thecurioustechnoid.com/hr-api-hooks-user-hooks/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=hr-api-hooks-user-hooks</link>
					<comments>https://thecurioustechnoid.com/hr-api-hooks-user-hooks/#respond</comments>
		
		<dc:creator><![CDATA[Rakshith Chengappa Mullengada]]></dc:creator>
		<pubDate>Mon, 15 Jun 2020 05:00:00 +0000</pubDate>
				<category><![CDATA[Oracle EBS]]></category>
		<category><![CDATA[api hooks]]></category>
		<category><![CDATA[ebs]]></category>
		<category><![CDATA[hcm]]></category>
		<category><![CDATA[hrms]]></category>
		<category><![CDATA[user hooks]]></category>
		<guid isPermaLink="false">https://thecurioustechnoid.com/?p=66</guid>

					<description><![CDATA[<p>What are HR API Hooks ? Hooks enable us to extend the HR APIs&#8217; capabilities to add additional custom features and validations. Hooks are easier to implement and can be used wherever HR APIs are called, be it a custom interface script or a seeded Self-Service request, if APIs are called then your custom validation&#8230;</p>
<p>The post <a href="https://thecurioustechnoid.com/hr-api-hooks-user-hooks/">HR API Hooks / User Hooks</a> appeared first on <a href="https://thecurioustechnoid.com">The Curious Technoid</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h4><strong>What are HR API Hooks ?</strong></h4>
<p>Hooks enable us to extend the HR APIs&#8217; capabilities to add additional custom features and validations. Hooks are easier to implement and can be used wherever HR APIs are called, be it a custom interface script or a seeded Self-Service request, if APIs are called then your custom validation will be invoked.</p>
<p>HR APIs are some times life saver, where-in the business wishes to add custom validations on a form or a self service page, rather than enhancing it, you just add your validation and you are good to go.</p>
<h4><strong>How to use HR API Hooks?</strong></h4>
<p><em><strong>Tested In:</strong> Oracle EBS 12.1.1, 12.1.3, 12.2.6</em></p>
<p>We will take an example to create user hook on HR_EMPLOYEE_API. The sample business case is,<span id="more-66"></span> I should not be able to hire anyone who is single.</p>
<p><strong>1 .Get the Module ID and Hook ID</strong></p>
<p>Query to get the API_MODULE_ID of the API we will be using, in my case HR_EMPLOYEE_API:</p>
<blockquote><p><code><span style="font-size: 10pt;"> SELECT *</span><br />
<span style="font-size: 10pt;"> FROM HR_API_MODULES</span><br />
<span style="font-size: 10pt;"> WHERE module_package = 'HR_EMPLOYEE_API'</span><br />
<span style="font-size: 10pt;"> AND module_name = 'CREATE_EMPLOYEE' ;</span></code></p></blockquote>
<p>Get the API_HOOK_ID for the module ID(1195), in my case BP &#8211; Before Process</p>
<blockquote><p><code><span style="font-size: 10pt;"> SELECT API_HOOK_ID -- 2690</span><br />
<span style="font-size: 10pt;"> FROM HR_API_HOOKS</span><br />
<span style="font-size: 10pt;"> WHERE api_module_id = 1195 --Module ID from the previous query</span><br />
<span style="font-size: 10pt;"> AND API_HOOK_TYPE = 'BP';</span></code></p></blockquote>
<p><strong>2. Create your custom package</strong></p>
<blockquote><p><span style="font-size: 10pt;"><code>CREATE OR REPLACE PACKAGE XXHR_CUSTOM_HOOKS_PKG<br />
AS<br />
-- Make sure to use only those parameters available in the API are used<br />
PROCEDURE validate_status(p_marital_status in varchar2 default null);<br />
--<br />
END XXHR_CUSTOM_HOOKS_PKG;<br />
/<br />
</code></span></p></blockquote>
<blockquote><p><code><span style="font-size: 10pt;">CREATE OR REPLACE PACKAGE BODY XXHR_CUSTOM_HOOKS_PKG</span><br />
<span style="font-size: 10pt;"> AS</span><br />
<span style="font-size: 10pt;">    PROCEDURE validate_status(p_marital_status in varchar2 default null)</span><br />
<span style="font-size: 10pt;"> IS</span><br />
<span style="font-size: 10pt;">    BEGIN</span><br />
<span style="font-size: 10pt;">       --If the marital status is single, throw an error</span><br />
<span style="font-size: 10pt;">       IF p_marital_status = 'S'</span><br />
<span style="font-size: 10pt;">       THEN</span><br />
<span style="font-size: 10pt;">          RAISE_APPLICATION_ERROR(-20006,'Custom Error: Single people cannot join our organization');</span><br />
<span style="font-size: 10pt;">       END IF;</span><br />
<span style="font-size: 10pt;">    END;</span><br />
<span style="font-size: 10pt;"> --</span><br />
<span style="font-size: 10pt;"> END XXHR_CUSTOM_HOOKS_PKG;</span><br />
<span style="font-size: 10pt;"> /</span></code></p></blockquote>
<p><strong>3. Create User Hook</strong></p>
<p>User hooks can be created using the below script by passing the custom package we created the previous step:</p>
<blockquote>
<pre><code><span style="font-size: 10pt;">SET SERVEROUTPUT ON;
--
DECLARE
   l_api_hook_call_id        NUMBER;
   l_object_version_number   NUMBER;
   l_sequence                NUMBER;
BEGIN
   SELECT hr_api_hooks_s.NEXTVAL
     INTO l_sequence
     FROM DUAL;

   hr_api_hook_call_api.create_api_hook_call
       (p_validate                   =&gt; FALSE,
        p_effective_date             =&gt; TO_DATE ('01-JAN-1952', 'DD-MON-YYYY'),
        p_api_hook_id                =&gt; 2690,  -- Retrieved Previously
        p_api_hook_call_type         =&gt; 'PP',
        p_sequence                   =&gt; l_sequence,
        p_enabled_flag               =&gt; 'Y',
        p_call_package               =&gt; 'XXHR_CUSTOM_HOOKS_PKG',
        p_call_procedure             =&gt; UPPER ('validate_status'), -- Custom procedure
        p_api_hook_call_id           =&gt; l_api_hook_call_id,
        p_object_version_number      =&gt; l_object_version_number
       );
   DBMS_OUTPUT.put_line ('l_api_hook_call_id ' || l_api_hook_call_id);
   COMMIT;
END;
/
</span></code></pre>
</blockquote>
<p><strong>4. Register User Hook / Run Pre-Processor</strong></p>
<blockquote><p><span style="font-size: 10pt;"><code>DECLARE</code></span><br />
<span style="font-size: 10pt;"> <code>    l_api_module_id number;</code></span><br />
<span style="font-size: 10pt;"> <code> BEGIN</code></span></p>
<p><span style="font-size: 10pt;"><code>    l_api_module_id := 1195; -- Module ID Retrieved from previous query</code></span></p>
<p><span style="font-size: 10pt;"><code>    --</code></span><br />
<span style="font-size: 10pt;"> <code>     -- Create all hook package body source code for one API module</code></span><br />
<span style="font-size: 10pt;"> <code>     --</code></span><br />
<span style="font-size: 10pt;"> <code>     hr_api_user_hooks_utility.create_hooks_one_module(l_api_module_id);</code></span></p>
<p><span style="font-size: 10pt;"><code>    --</code></span><br />
<span style="font-size: 10pt;"> <code>     -- Build the report text</code></span><br />
<span style="font-size: 10pt;"> <code>     --</code></span><br />
<span style="font-size: 10pt;"> <code>     hr_api_user_hooks_utility.write_one_errors_report(l_api_module_id);</code></span><br />
<span style="font-size: 10pt;"> <code> END;</code></span><br />
<span style="font-size: 10pt;"> <code> /</code></span></p></blockquote>
<p>Don&#8217;t forget to check the status of the hook call after running the pre-processor by using the below query:</p>
<p><span style="font-size: 10pt;"><code>SELECT status, encoded_error<br />
FROM HR_API_HOOK_CALLS<br />
where call_package = 'XXHR_CUSTOM_HOOKS_PKG'<br />
and call_procedure = 'VALIDATE_STATUS';</code></span></p>
<h4><span style="font-size: 12pt;"><strong>What does the status mean?</strong></span></h4>
<p>N &#8211; New / Not Active<br />
I &#8211; Invalid / Errored<br />
V &#8211; Valid</p>
<p>If the pre-processor succeeded in registering your Hook call, then the status will be <strong>V</strong> if not then the status will be <strong>I</strong>. There is no direct way of finding the reason for the pre-processor to have failed. There is a script which can help you to find the error details which we will look into now. Run the below scripts in the <strong>same session where you ran pre-processor</strong> script to find the errors if any:</p>
<p><em>Note: This will only work if you have ran the hr_api_user_hooks_utility.write_one_errors_report(l_api_module_id); package call when you ran pre-processor as seen in the pre-processor script above.</em></p>
<p><span style="font-size: 10pt;"><code>/* Run the below script to get the error output */<br />
set heading off<br />
set feedback off<br />
select text<br />
from hr_api_user_hook_reports<br />
where session_id = userenv('SESSIONID')<br />
order by line;</code></span></p>
<p><span style="font-size: 10pt;"><code>/* Don't forget to clear the data from report tables by running the below script */<br />
execute hr_api_user_hooks_utility.clear_hook_report;</code></span></p>
<p><strong>5. Delete User Hook</strong></p>
<p>If you wish to delete the user hook, you can use the below script by passing api_hook_call_id and object_version_number:</p>
<blockquote><p><span style="font-size: 10pt;"><code>SET SERVEROUTPUT ON;</code><br />
<code>DECLARE</code><br />
<code>    --</code><br />
<code>     ln_object_version_number NUMBER;</code><br />
<code>     --</code><br />
<code>BEGIN</code><br />
<code>     /* You can get the api_hook_call_id by using the below query:</code><br />
<code>     SELECT api_hook_call_id, object_version_number</code><br />
<code>     FROM HR_API_HOOK_CALLS</code><br />
<code>     where call_package = 'XXHR_CUSTOM_HOOKS_PKG'</code><br />
<code>     and call_procedure = 'VALIDATE_STATUS';</code><br />
<code>     */</code><br />
<code>     hr_api_hook_call_api.delete_api_hook_call (p_api_hook_call_id =&gt; 1112,</code><br />
<code>                                               p_object_version_number =&gt; 1);</code><br />
<code>     DBMS_OUTPUT.put_line ('DELETED HOOK...');</code><br />
<code>EXCEPTION</code><br />
<code>     WHEN OTHERS</code><br />
<code>     THEN</code><br />
<code>        DBMS_OUTPUT.put_line (SUBSTR ('Error: ' || SQLERRM, 1, 255));</code><br />
<code>END;</code><br />
<code>/</code></span></p></blockquote>
<p><strong>Important tables of Hooks:</strong></p>
<p><span style="font-size: 10pt;"><code>SELECT * FROM HR_API_MODULES -- All Hook Modules can be found here</code></span></p>
<p><span style="font-size: 10pt;"><code>SELECT * FROM HR_API_HOOKS -- All hooks can be found here</code></span></p>
<p><span style="font-size: 10pt;"><code>SELECT * FROM HR_API_HOOK_CALLS -- All custom hook package calls can be found here</code></span></p>
<p><span style="color: #ff0000; font-size: 12pt;"><strong>Caution:</strong></span><br />
<span style="font-size: 12pt;"> 1. API Hooks gets invoked if and only if HR API&#8217;s are called.</span><br />
<span style="font-size: 12pt;"> 2. In quite a few cases HR API Hooks cannot be used where APIs aren&#8217;t called, few examples are:</span></p>
<ul>
<li style="list-style-type: none;">
<ul>
<li><span style="font-size: 12pt;">Certain forms like People Screen does not call API hence hooks will not work. (That&#8217;s where custom.pll or forms personalization comes into play)</span></li>
<li><span style="font-size: 12pt;">If you have configured a Special Information Type(SIT) with approvals, in Employee Self Service for employee&#8217;s to request for something, then don&#8217;t use hooks as API&#8217;s gets invoked only at the time of approval</span></li>
</ul>
</li>
</ul>
<p>The post <a href="https://thecurioustechnoid.com/hr-api-hooks-user-hooks/">HR API Hooks / User Hooks</a> appeared first on <a href="https://thecurioustechnoid.com">The Curious Technoid</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://thecurioustechnoid.com/hr-api-hooks-user-hooks/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/

Page Caching using Disk: Enhanced 
Database Caching 28/37 queries in 0.004 seconds using Disk

Served from: thecurioustechnoid.com @ 2026-06-19 01:25:10 by W3 Total Cache
-->