Tuesday, December 27, 2011

How to Download attachments from table using OAMessageDownloadBean

In OA Framework JDeveloper add a message Download Button 

Please Specify 
Data Type: BLOB
View Instance : DocumentsVO [Corresponding VO name]
View Attribute: FileName [File Name Column in the VO]
File View Attribute: FileData [Blob column containing the data]

Add the below lines in code to specify MIME Type
// OA Table
OATableBean tableBean =(OATableBean) webBean.findChildRecursive("AllDocumentsTable");
// message Download 
    OAMessageDownloadBean downloadBean = (OAMessageDownloadBean)tableBean.findChildRecursive("downloadFile");
    OADataBoundValueViewObject contentBoundValue = new OADataBoundValueViewObject(downloadBean,"FileContentType");
    downloadBean.setAttributeValue(FILE_CONTENT_TYPE, contentBoundValue);


Please note that there should be a primary column in the query. If there is no primary column all the rows will download a same file.

Wednesday, November 16, 2011

Error Error while caling AS_OPPORTUNITY_PUB.Update_Opp_Header API Current resource does not have a login user assigned. Please use resource manager to assign a login user to this resource

Error: Error while caling AS_OPPORTUNITY_PUB.Update_Opp_Header API Current resource does not have a login user assigned. Please use resource manager to assign a login user to this resource

    headerRec.close_reason     := 'DROPPED';
        headerRec.last_update_date := lastUpdatedDate;
        headerRec.last_updated_by  := FND_GLOBAL.USER_ID;

        AS_OPPORTUNITY_PUB.Update_Opp_Header(p_api_version_number     => '2.0',
                                             p_commit                 => fnd_api.G_FALSE,
                                             p_header_rec             => headerRec,
                                             p_check_access_flag      => 'Y',
                                             p_admin_flag             => 'N',
                                             p_admin_group_id         => null,
                                             p_identity_salesforce_id => null,
                                             p_partner_cont_party_id  => null,
                                             x_return_status          => x_return_status,
                                             x_msg_count              => x_msg_count,
                                             x_msg_data               => x_msg_data,
                                             x_lead_id                => x_lead_id);
        IF (x_return_status != 'S') THEN
          IF (fnd_msg_pub.count_msg > 0) THEN
            FOR i IN 1 .. fnd_msg_pub.count_msg LOOP
              fnd_msg_pub.get(p_msg_index     => i,
                              p_encoded       => 'F',
                              p_data          => x_msg_data,
                              p_msg_index_out => x_msg_count);
              DBMS_OUTPUT.put_line(x_msg_data);
            END LOOP;

Solution: Pass the sales_force_id  into  p_identity_salesforce_id

Wednesday, November 09, 2011

Error - You have encountered an unexpected error. Please contact the System Administrator for assistance.


We have to turn on diagnostics to see the error
Go to Application Developer --> Profiles -- System
Set FND: Diagnostics to Yes . This will display ther details link to show the full error where you can see the error

Friday, September 30, 2011

Create / Update Contact points

- This creates a contact point phone for the given party
 PROCEDURE createcontactpointphone(
  partyid          IN       hz_contact_points.owner_table_id%TYPE,
  countrycode      IN       hz_contact_points.phone_country_code%TYPE,
  phonenumber      IN       hz_contact_points.phone_number%TYPE,
  contacttype      IN       VARCHAR2,
  contactpurpose   IN       VARCHAR2,
  extn             IN       hz_contact_points.phone_extension%TYPE,
  isprimary        IN       CHAR,
  status           IN       CHAR,
  errormessage     OUT      VARCHAR2
 )
 IS
  currentdate           TIMESTAMP                             := SYSTIMESTAMP;
  x_return_status       VARCHAR2(1);
  x_msg_count           NUMBER;
  x_msg_data            VARCHAR2(2000);
  x_contact_point_id    NUMBER;
  objectversionnumber   NUMBER;
  contact_point_rec     hz_contact_point_v2pub.contact_point_rec_type;
  contacttypecode       hz_contact_points.contact_point_type%TYPE;
  purposetypecode       hz_contact_points.contact_point_purpose%TYPE;
  phonerec              hz_contact_point_v2pub.phone_rec_type;
 BEGIN
--     errormessage:=partyid;
--     return;
      -- This create Phone Contact point
  fnd_msg_pub.delete_msg;

  BEGIN
   SELECT lookup_code
     INTO contacttypecode
     FROM ar_lookups
    WHERE lookup_type = 'PHONE_LINE_TYPE' AND meaning = contacttype;
  EXCEPTION
   WHEN NO_DATA_FOUND
   THEN
    errormessage := ' No Lookup value for the given meaning found in Lookups';
    RETURN;
  END;

  IF (contactpurpose IS NOT NULL)
  THEN
   BEGIN
    SELECT lookup_code
      INTO purposetypecode
      FROM ar_lookups
     WHERE lookup_type = 'CONTACT_POINT_PURPOSE' AND meaning = contactpurpose;
   EXCEPTION
    WHEN NO_DATA_FOUND
    THEN
     errormessage :=
                    ' No Lookup value for the given meaning found in Lookups';
     RETURN;
   END;

   contact_point_rec.contact_point_purpose := purposetypecode;
  END IF;

  contact_point_rec.contact_point_type := 'PHONE';
  phonerec.phone_extension := extn;
  contact_point_rec.status := 'A';
  contact_point_rec.owner_table_name := 'HZ_PARTIES';
  contact_point_rec.owner_table_id := partyid;
  contact_point_rec.primary_flag := isprimary;
  contact_point_rec.created_by_module := l_created_by_module;

  IF (phonerec.phone_country_code IS NULL)
  THEN
   phonerec.phone_country_code := '91';
  ELSE
   phonerec.phone_country_code := countrycode;
  END IF;

  phonerec.phone_number := phonenumber;
  phonerec.phone_line_type := contacttypecode;
  hz_contact_point_v2pub.create_phone_contact_point
                                    (p_init_msg_list        => fnd_api.g_false,
                                     p_contact_point_rec    => contact_point_rec,
                                     p_phone_rec            => phonerec,
                                     x_contact_point_id     => x_contact_point_id,
                                     x_return_status        => x_return_status,
                                     x_msg_count            => x_msg_count,
                                     x_msg_data             => x_msg_data
                                    );

  IF (fnd_msg_pub.count_msg > 0)
  THEN
   FOR i IN 1 .. fnd_msg_pub.count_msg
   LOOP
    fnd_msg_pub.get(p_msg_index        => i,
                    p_encoded          => 'F',
                    p_data             => x_msg_data,
                    p_msg_index_out    => x_msg_count
                   );
   END LOOP;
  END IF;

  IF (x_return_status <> 'S')
  THEN
   errormessage := x_msg_data;
   ROLLBACK;
  ELSE
   COMMIT;
  END IF;
 EXCEPTION
  WHEN OTHERS
  THEN
   errormessage := SQLERRM;
 END createcontactpointphone;



 -- This updates contact point phone
PROCEDURE updatecontactpointphone(
  contactpointid   IN       NUMBER,
  countrycode      IN       hz_contact_points.phone_country_code%TYPE,
  phonenumber      IN       hz_contact_points.phone_number%TYPE,
  contacttype      IN       VARCHAR2,
  contactpurpose   IN       VARCHAR2,
  extn             IN       hz_contact_points.phone_extension%TYPE,
  isprimary        IN       CHAR,
  status           IN       CHAR,
  errormessage     OUT      VARCHAR2
 )
 IS
  currentdate           TIMESTAMP                             := SYSTIMESTAMP;
  x_return_status       VARCHAR2(1);
  x_msg_count           NUMBER;
  x_msg_data            VARCHAR2(2000);
  objectversionnumber   NUMBER;
  contact_point_rec     hz_contact_point_v2pub.contact_point_rec_type;
  contacttypecode       hz_contact_points.contact_point_type%TYPE;
  purposetypecode       hz_contact_points.contact_point_purpose%TYPE;
  phonerec              hz_contact_point_v2pub.phone_rec_type;
  x_edi_rec             hz_contact_point_v2pub.edi_rec_type;
  x_email_rec           hz_contact_point_v2pub.email_rec_type;
  x_web_rec             hz_contact_point_v2pub.web_rec_type;
  x_telex_rec           hz_contact_point_v2pub.telex_rec_type;
 BEGIN
  -- This create Phone Contact point
  fnd_msg_pub.delete_msg;

  BEGIN
   SELECT lookup_code
     INTO contacttypecode
     FROM ar_lookups
    WHERE lookup_type = 'PHONE_LINE_TYPE' AND meaning = contacttype;
  EXCEPTION
   WHEN NO_DATA_FOUND
   THEN
    errormessage := ' No Lookup value for the given meaning found in Lookups';
    RETURN;
  END;

  -- Get object version number of contact point
  BEGIN
   SELECT object_version_number
     INTO objectversionnumber
     FROM hz_contact_points
    WHERE contact_point_id = contactpointid;
  EXCEPTION
   WHEN NO_DATA_FOUND
   THEN
    errormessage := ' No Such contact pointcfound';
    RETURN;
  END;

  -- get the purpose meaning
  IF (contactpurpose IS NOT NULL)
  THEN
   BEGIN
    SELECT lookup_code
      INTO purposetypecode
      FROM ar_lookups
     WHERE lookup_type = 'CONTACT_POINT_PURPOSE' AND meaning = contactpurpose;
   EXCEPTION
    WHEN NO_DATA_FOUND
    THEN
     errormessage :=
                    ' No Lookup value for the given meaning found in Lookups';
     RETURN;
   END;

   contact_point_rec.contact_point_purpose := purposetypecode;
  END IF;

  hz_contact_point_v2pub.get_contact_point_rec
                                    (p_contact_point_id     => contactpointid,
                                     x_contact_point_rec    => contact_point_rec,
                                     x_edi_rec              => x_edi_rec,
                                     x_email_rec            => x_email_rec,
                                     x_phone_rec            => phonerec,
                                     x_telex_rec            => x_telex_rec,
                                     x_web_rec              => x_web_rec,
                                     x_return_status        => x_return_status,
                                     x_msg_count            => x_msg_count,
                                     x_msg_data             => x_msg_data
                                    );
  phonerec.phone_extension := extn;
  contact_point_rec.status := status;
  phonerec.raw_phone_number := NULL;
  contact_point_rec.primary_flag := isprimary;

  IF (phonerec.phone_country_code IS NULL)
  THEN
   phonerec.phone_country_code := '91';
  ELSE
   phonerec.phone_country_code := countrycode;
  END IF;

  phonerec.phone_number := phonenumber;
  phonerec.phone_line_type := contacttypecode;
  hz_contact_point_v2pub.update_phone_contact_point
                              (p_init_msg_list            => fnd_api.g_false,
                               p_contact_point_rec        => contact_point_rec,
                               p_phone_rec                => phonerec,
                               p_object_version_number    => objectversionnumber,
                               x_return_status            => x_return_status,
                               x_msg_count                => x_msg_count,
                               x_msg_data                 => x_msg_data
                              );

  IF (fnd_msg_pub.count_msg > 0)
  THEN
   FOR i IN 1 .. fnd_msg_pub.count_msg
   LOOP
    fnd_msg_pub.get(p_msg_index        => i,
                    p_encoded          => 'F',
                    p_data             => x_msg_data,
                    p_msg_index_out    => x_msg_count
                   );
   END LOOP;
  END IF;

  IF (x_return_status <> 'S')
  THEN
   errormessage := x_msg_data;
   ROLLBACK;
  ELSE
   COMMIT;
  END IF;
 EXCEPTION
  WHEN OTHERS
  THEN
   errormessage := SQLERRM;
 END updatecontactpointphone;

Tuesday, September 20, 2011

How to give Debug Grants to a schema

GRANT DEBUG CONNECT SESSION TO <schema>

Tuesday, September 06, 2011

Find List of Referenced dependencies for a package or procedure or view


select referenced_owner,referenced_name from all_dependencies where  lower(name)='package Name'

Friday, August 26, 2011

Error : timeout occurred while waiting to lock object

I am getting error timeout occurred while waiting to lock object when i Compile a package. I want to remove the lock.
SELECT * FROM v$access  where object='package_name'
Take that SID and pass it to the below query and take sid and serial#
SELECT s.inst_id,
       s.sid,
       s.serial#,
       p.spid,
       s.username,
       s.program
FROM   gv$session s
       JOIN gv$process p ON p.addr = s.paddr AND p.inst_id = s.inst_id
WHERE  s.type != 'BACKGROUND' and
s.sid=?
Kill Session
Use the below  query to kill the corresponding session
ALTER SYSTEM KILL SESSION 'sid,serial#'

Thursday, August 25, 2011

Get Financial Year Week no for given date

Financial Week start from 01-Apr each year. So for 01-Apr of that year i should get week number as 1.

select
to_char(SYSDATE) the_date,
to_char(add_months(SYSDATE,-3),'WW') fiscal_week
from dual

Wednesday, August 24, 2011

Change Password using API for e-Business Suite Login

You can change password and also disable the change password which will be asked when the password change limit days has crossed  as given below.


No need to pass the old password for the below.

begin
fnd_user_pkg.updateuser(
                x_user_name => 'fnd_user.User_NAME',
                x_unencrypted_password => 'password',
                x_password_date => (sysdate+31)
                );
commit;
end;

Bulk Collect Example

Declare
  Type emprec IS RECORD(
    empno Number,
    name  varchar2(40));
  TYPE emptab IS TABLE OF emprec;
  cursor empcur IS
    select * from emp1;
  emptable emptab;

BEGIN
  OPEN empcur;
  FETCH empcur BULK COLLECT
    INTO emptable;

  if (nvl(emptable.LAST 0) > 0) then
    FOR i in emptable.FIRST .. emptable.LAST LOOP
      BEGIN
           INSERT INTO EMP1(empno,name) values (emptable(i).empno,emptable(i).name);
      END;
    END LOOP;
  END IF;

  COMMIT;
 END;

Monday, August 22, 2011

Connect By Root Example

I have a Table person_map which will have 2 columns,
Person_id,Mapped_person_id

For Example
Person_ID Mapped_Person_id
1 2
2 3
3 4
5 6
6 7

I require a query which will give output like below
1 2
1 3
1 4
2 3
2 4
3 4
5 6
5 7
6 7

Scripts
Create table Person (person_id Number, Mapped_person_id Number);

INSERT INTO PERSON VALUES ( 1,2);
INSERT INTO PERSON VALUES ( 2,3);
INSERT INTO PERSON VALUES ( 3,4);
INSERT INTO PERSON VALUES ( 5,6);
INSERT INTO PERSON VALUES ( 6,7);

Solution:

SELECT level, person_id AS original_person_id, 
CONNECT_BY_ROOT person_id AS root_person_id, mapped_person_id
      FROM person
 CONNECT BY person_id = prior mapped_person_id;

Friday, August 12, 2011

Error - Another user has updated Opportunity header record in AS_OPPORTUNITY_PUB.Update_Opp_Header

Cause: 
While Updating opportunities using AS_OPPORTUNITY_PUB.Update_Opp_Header I am getting the below error


Another user has updated Opportunity header record. please re-query to see the changes.


The Code is 
headerRec.lead_id := leadId;
headerRec.owner_salesforce_id := resourceid;
headerRec.owner_sales_group_id :=salesGroupid;
headerRec.status :='Dropped';
headerRec.status_code :='Dropped';
headerRec.close_reason:='NOT_SPECIFIED';
headerRec.last_update_date := sysdate;
headerRec.last_updated_by := FND_GLOBAL.USER_ID;
-- dbms_output.put_line (headerRec.last_update_date );
AS_OPPORTUNITY_PUB.Update_Opp_Header(p_api_version_number => '2.0',
p_commit => fnd_api.G_FALSE,
p_header_rec => headerRec,
p_check_access_flag => 'Y',
p_admin_flag => 'N',
p_admin_group_id => null,
p_identity_salesforce_id => resourceid,
p_partner_cont_party_id => null,
x_return_status => x_return_status,
x_msg_count => x_msg_count,
x_msg_data => x_msg_data,
x_lead_id => x_lead_id);
DBMS_OUTPUT.put_line('--' || x_return_status);
IF (x_return_status != 'S') THEN
IF (fnd_msg_pub.count_msg > 0) THEN
FOR i IN 1 .. fnd_msg_pub.count_msg LOOP
fnd_msg_pub.get(p_msg_index => i,
p_encoded => 'F',
p_data => x_msg_data,
p_msg_index_out => x_msg_count);
DBMS_OUTPUT.put_line(x_msg_data);
END LOOP;


Solution:
  Get the Last_updated_date from the opportunity table for the selected opportunity and pass it to the headerRec.last_update_date

SELECT last_update_date
FROM as_leads_all
WHERE lead_id = opportunity_id;

Error - Close reason with value: does not exist. in Update Opportunities

Cause:
While Updating opportunities using AS_OPPORTUNITY_PUB.Update_Opp_Header I am getting the below error


Close reason with value: BUYING DEFERRED does not exist.

The code is


headerRec.lead_id := leadId;
headerRec.owner_salesforce_id := resourceid;
headerRec.owner_sales_group_id :=salesGroupid;
headerRec.status :='Dropped';
headerRec.status_code :='Dropped';
headerRec.close_reason:='BUYING DEFERRED';
headerRec.last_update_date := lastUpdatedDate;
headerRec.last_updated_by := FND_GLOBAL.USER_ID;
-- dbms_output.put_line (headerRec.last_update_date );
AS_OPPORTUNITY_PUB.Update_Opp_Header(p_api_version_number => '2.0',
p_commit => fnd_api.G_FALSE,
p_header_rec => headerRec,
p_check_access_flag => 'Y',
p_admin_flag => 'N',
p_admin_group_id => null,
p_identity_salesforce_id => resourceid,
p_partner_cont_party_id => null,
x_return_status => x_return_status,
x_msg_count => x_msg_count,
x_msg_data => x_msg_data,
x_lead_id => x_lead_id);
DBMS_OUTPUT.put_line('--' || x_return_status);
IF (x_return_status != 'S') THEN
IF (fnd_msg_pub.count_msg > 0) THEN
FOR i IN 1 .. fnd_msg_pub.count_msg LOOP
fnd_msg_pub.get(p_msg_index => i,
p_encoded => 'F',
p_data => x_msg_data,
p_msg_index_out => x_msg_count);
DBMS_OUTPUT.put_line(x_msg_data);

Solution:
You have to pass one of the values from column lookup_code from below query

select lookup_code from fnd_lookup_values  where lookup_type='CLOSE_REASON'

Tuesday, August 09, 2011

How to find Table Last Altered Date/Time in Oracle

select * from dba_objects
where owner='<Table Schema Owner>'
and object_name ='<Table Name>'

Thursday, July 14, 2011

How to get first day and last date of week, month, quarter, year in Oracle

--First day of current week(sunday)
select TRUNC(SYSDATE, 'Day') from dual;
--First day of next week(sunday)
select TRUNC(SYSDATE+7 , 'Day') from dual;
--First day of previous week(sunday)
select TRUNC(SYSDATE-7 , 'Day') from dual;
--First day of current month
select TRUNC(SYSDATE , 'Month') from dual;
--First day of previous month
select TRUNC(TRUNC(SYSDATE , 'Month')-1 , 'Month') from dual;
--First day of next month
select TRUNC(LAST_DAY(SYSDATE)+1 , 'Month') from dual;
--First day of current year
select TRUNC(SYSDATE , 'Year') from dual;
--First day of previous year
select TRUNC(TRUNC(SYSDATE , 'Year')-1 , 'Year') from dual;
--First day of next year
select ADD_MONTHS(TRUNC(SYSDATE , 'Year'),12) from dual;
-- First Day of Current quater
select TRUNC(SYSDATE , 'Q') from dual;
--  First Day of Previous Quarter
select ADD_MONTHS(TRUNC(SYSDATE , 'Q'),-3) from dual;
--  First Day of Next Quarter
select ADD_MONTHS(TRUNC(SYSDATE , 'Q'),3) from dual;

--Last day of current week(sunday)
select TRUNC(SYSDATE, 'Day')+6 from dual;
--Last day of next week(sunday)
select TRUNC(SYSDATE+7 , 'Day')+6 from dual;
--Last day of previous week(sunday)
select TRUNC(SYSDATE-7 , 'Day')+6 from dual;
--Last day of current month
select LAST_DAY(TRUNC(SYSDATE , 'Month')) from dual;
--Last day of previous month
select LAST_DAY(TRUNC(TRUNC(SYSDATE , 'Month')-1 , 'Month')) from dual;
--Last day of next month
select LAST_DAY(TRUNC(LAST_DAY(SYSDATE)+1 , 'Month')) from dual;
--Last day of current year
select LAST_DAY(ADD_MONTHS(TRUNC(SYSDATE , 'Year'),11)) from dual;
--Last day of previous year
select LAST_DAY(ADD_MONTHS(TRUNC(TRUNC(SYSDATE , 'Year')-1 , 'Year'),11)) from dual;
--Last day of next year
select LAST_DAY(ADD_MONTHS(TRUNC(TRUNC(SYSDATE , 'Year')-1 , 'Year'),-13)) from dual;
-- Last Day of Current quater
select LAST_DAY(ADD_MONTHS(TRUNC(SYSDATE , 'Q'),2)) from dual;
--  Last Day of Previous Quarter
select TRUNC(SYSDATE , 'Q')-1 from dual;
--  Last Day of Next Quarter
select LAST_DAY(ADD_MONTHS(TRUNC(SYSDATE , 'Q'),5)) from dual;

Wednesday, July 13, 2011

How to see Last Refreshed Date Time of Materialized View


select * from USER_MVIEWS
 where mview_name = 'MYVIEW';

Wednesday, July 06, 2011

Personalize page view panels Search page in e-Business Suite

Go to System Administrator --> Profile --> System

To Enable Personalize region links for each region in a page
FND: Personalization Region Link Enabled -- Set to Yes

To Enable About this page
FND: Diagnostics -- Set to Yes

To Enable Global Personalize Page Link
Personalize Self-Service Defn --> Yes

Go to Sales Dashboard --> Personalize Page.
Select Content and go to the corresponding Search and click pen(Personalize properties)

Go down to the field and you will see an icon in seeded user views corresponding to the table.

In here create user views and map it to the responsibilities

Thursday, March 31, 2011

How to display carriage return in oa framework web page table.

   I am having a column in a table which has carriage return chr(13) in the value. oracle will take care of this in forms by giving a line break. But OA Framework does not allow it.

I searched for many places in the net and couldnt find a solution. so i tried and found an alternative. Go to that column in the Region of type table and make the item style as raw text. While getting the code from VO object, change the column in the query to Replace(column_name,chr(13),'<br>')
If you have used chr(10) you can also replace it with


So when showing in table, there will be a line break for each chr(13)

Wednesday, March 02, 2011

Error "You cannot change the owner of this service request because there is an active workflow in progress" in E-business Suite

   In Create SR Page, When a SR is created for a particular SR type. the task gets created after that usually[Tasks are defined in Task Template].
But currently it is taking 10 to 15 minutes to automatically create. During this time, if we try to update sr we get error “You cannot change the owner of this service request because there is an active workflow in progress”. 

Solution: Go to Setup Service Requests -> Request Types   
Select the service type you are facing problem and you would see that the workflow contains
"@Duplicate Check and Auto Task Create for Web/EMC created SR"

Clear the workflow field and save. Now the issue will not come

Tuesday, February 22, 2011

How to check which LOV Event is pressed

I have many Lov in page and when a specific lov is getting selected, it should do some actions or call some dependent lov, Then below is the code to do so.

String lovInputSourceId = pageContext.getLovInputSourceId();

if (pageContext.isLovEvent())
{
if (lovInputSourceId.equals("CustomerSearch"))
{
Call AM Function

}
}

Monday, February 21, 2011

How to open a oracle form from OA Framework web page

The below is an example to open a form from oa web page

String destination = "form:CS:SIFY ENTERPRISE SUPPORT USER:STANDARD:CSXSRISR:open_flag=Y G_QUERY_FIND='FALSE'";
pageContext.forwardImmediatelyToForm(destination);

where the below represents what to give where
"form:APPLICATION_SHORT_NAME:RESPONSIBILITY:STANDARD:FORM NAME:PARAMETERS";

Tuesday, February 01, 2011

Batch program to change your pc computer name using Shell/Batch Script in Registery

If you need to change the computer name to a new name with help of batch script then
Step 1: Open Notepad
Step 2: Please copy the below content to the Notepad
Step 3: Save it as Change_Computer_Name.bat
Step 4: Execute the script and enter the name you want to change to.

SET /P PCNAME=Please enter your name:
REG ADD HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName /v ComputerName /t REG_SZ /d %PCNAME% /f
REG ADD HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ActiveComputerName\ /v ComputerName /t REG_SZ /d %PCNAME% /f
REG ADD HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\ /v Hostname /t REG_SZ /d %PCNAME% /f
REG ADD HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\ /v "NV Hostname" /t REG_SZ /d %PCNAME% /f
@echo off
echo Please Restart your computer Manually. The Program will exit now.
echo.
echo.
pause

Add / Delete user and include as administrator member in Windows XP Windows 7 using shell/Registery in registory

Add User
Open Notepad and add the below
net user username password /add
net localgroup Administrators /add username
pause

Save it as Create_User.bat

If your operating system is Windows Xp
Double click Create_User.bat and execute it

If your operating system is Windows 7
Right click Create_User.bat and select run as administrator

Delete User
Open Notepad and add the below
net user UserName /del

Save it as Delete_User.bat

If your operating system is Windows Xp
Double click Delete_User.batand execute it

If your operating system is Windows 7
Right click Delete_User.bat and select run as administrator

Thursday, January 20, 2011

Advanced Search Bean to get Criteria and Load based on it OA Framework

Controller Code

public void SetQuery(OAPageContext pageContext, OAWebBean webBean)
{
AllianceTeamAMImpl MyRequestAm =(AllianceTeamAMImpl) pageContext.getApplicationModule(webBean);
OAQueryBean queryBean =(OAQueryBean)webBean.findIndexedChildRecursive("SearchRn");
Dictionary[] dic = queryBean.getCriteria(pageContext);
// If the dictionary is empty, then it means that no non-view criteria
// is available, so return.
if(pageContext.getParameter(queryBean.getGoButtonName()) != null )
{
// When Button is pressed it will go in below loop
if (dic != null && !dic.toString().equals(""))
{
// Otherwise process the dictionary to build your where clause.
Hashtable params = new Hashtable();
int size = dic.length;
int clauseCount = 0;
int bindCount = 2;
StringBuffer whereClause = new StringBuffer();
Vector parameters = new Vector();
ViewObject allTeamVO = MyRequestAm.findViewObject("MyAllianceTeamVO2");

// Iterate through the dictionary to set your where clauses
for (int i=0; i < size; i++) { // Item for which the criteria is defined. String itemName = (String) dic[i].get(OAViewObject.CRITERIA_ITEM_NAME); String viewAttributename = (String)dic[i].get(OAViewObject.CRITERIA_VIEW_ATTRIBUTE_NAME); String columnName = allTeamVO.findAttributeDef(viewAttributename).getColumnNameForQuery(); // Condition is the SQL condition - examples: like , = etc String condition = (String) dic[i].get(OAViewObject.CRITERIA_CONDITION); // String criteriaDataType = (String)dic[i].get(OAViewObject.CRITERIA_DATATYPE); // Value is the value entered with the appropriate % based on condition Object value = dic[i].get(OAViewObject.CRITERIA_VALUE); // Join condition is either AND or OR depending on what user chooses String joinCondition = (String) dic[i].get(OAViewObject.CRITERIA_JOIN_CONDITION); if(value != null) { if(clauseCount > 0)
{
whereClause.append(" AND ");
}
whereClause.append(columnName + " " + condition + " :");
whereClause.append(++bindCount);
parameters.addElement(value);
clauseCount++;
}
}
// If where clause and criteria then get query
if(dic != null && whereClause != null)
{
MyRequestAm.initMyAllianceTeamUserVOQuery("" +pageContext.getUserId(), pageContext.getTransactionTransientValue("Team").toString(),whereClause.toString(),parameters);
}
}
// When Criteria is null Bring all
else
{
MyRequestAm.initMyAllianceTeamUserVOQuery("" +pageContext.getUserId(), pageContext.getTransactionTransientValue("Team").toString());
}
}
}



AM Code
public void initMyAllianceTeamUserVOQuery(String user,String team,String WhereClause, Vector parameters)
  {
    MyAllianceTeamVOImpl vo=  getMyAllianceTeamVO2();
    if(vo==null)
    {
      MessageToken[] errTokens = {new MessageToken("OBJECT_NAME", "MyAllianceTeamVO")};
      throw new OAException("AK", "FWK_TBX_OBJECT_NOT_FOUND", errTokens);
    }

    vo.setWhereClauseParams(null);
    vo.setWhereClauseParam(0,user);
    if(team.equals("AllianceTeam"))
    {
       vo.setWhereClauseParam(1,"1");
    }
    else
    {
      vo.setWhereClauseParam(1,"2");
    }
  
    if(WhereClause != null)
    {
      vo.setWhereClause(WhereClause);
      int cnt = parameters.size();
      for(int i=0;i
      {
         vo.setWhereClauseParam(i+2,parameters.get(i));
      }
    }
    vo.executeQuery();
    vo.setWhereClause(null);
  }
Controller code
1. We are taking the region of Search and getting its QueryBean
2. Next we are checking whether button is pressed.
3. we are getting the search criteria selected by user and assin it to dictionary
4. We are looping through Dictionary and create where clause and parameters and send it to AM to execute based on search clause given
5. If i dont pass any parameters , then by default all is loaded.
6. I have set bindcount to 2 because i have already 2 parameters

Model Code

1. We are getting the parameters and adding the parameters to the view object and execute it.

How to get bean value in Advanced Search OA Framework

In Advanced search the criteria is stored in order of Value_0,Value_1,...

I want to set a oaMessageChoice bean value in page load(processRequest)

My code will be.

OAAdvancedSearchBean advBean = (OAAdvancedSearchBean)webBean.findChildRecursive("advancedSearch");
OAMessageChoiceBean StatusSearch = (OAMessageChoiceBean)advBean.findChildRecursive("Value_1");
StatusSearch.setValue(pageContext,"Pending with Alliance");

where

advanced search is the ID of AdvancedSearch Region