How to apply a Trigger on a Transcation Table

Hi Friends,
I have one requirement from my client.
let me explain u the scenario..
if a person is apply for a loan . when he clicks on the submit button it goes to the approvers.. it means it will go tho the transacation tables.
my requirement is if a person applies for the same loan two times before any action taken place for the previous applied loan .. then it should stop the user moving forward.saying your previous loan is pending for approval.
Technical:-
i wrote one package for it.. and called it in a trigger for validation
create or replace package body xx_transcation_pkg is
function get_trans(p_person_id in number)
return varchar2
is
cursor c1 is
SELECT htr.transaction_id
FROM per_analysis_criteria pac,
hr_api_transactions htr,
hr_api_transaction_steps hts,
hr_api_transaction_values htrv
WHERE htr.transaction_id = hts.transaction_id
AND hts.transaction_step_id = htrv.transaction_step_id
AND htrv.NAME LIKE 'P_ANALYSIS_CRITERIA_ID%'
AND htr.process_name = 'VEHICLE_LOAN'
AND htr.selected_person_id = TO_NUMBER (p_person_id)
AND pac.analysis_criteria_id = htrv.number_value
AND htr.status = 'Y'
AND hts.transaction_step_id =
(SELECT hts.transaction_step_id
FROM hr_api_transaction_values htv,
hr_api_transaction_steps hts
WHERE htv.transaction_step_id = hts.transaction_step_id
AND hts.transaction_id = htr.transaction_id
AND htv.varchar2_value IN ('INSERT', 'UPDATE'))
GROUP BY htr.transaction_id;
--variable declaration
l_value number;
begin
for i in c1
loop
l_value:=i.transaction_id;
if
l_value is not null
then
return('Flag1');
else
return('Flag2');
end if;
end loop;
end;
end xx_transcation_pkg;
and my trigger is
CREATE OR REPLACE TRIGGER TEST_RL
BEFORE DELETE OR INSERT OR UPDATE
ON PER_ANALYSIS_CRITERIA REFERENCING NEW AS N OLD AS O
FOR EACH ROW
declare
p_person_id number;
v_id_flex_num number;
l_flag varchar2(100);
begin
v_id_flex_num := (:n.ID_FLEX_NUM);
if
v_id_flex_num=50430
then
p_person_id:=(:n.segment30);
begin
select xx_transcation_pkg.GET_TRANS(p_person_id) into
l_flag from dual ;
end;
if
l_flag='Flag1' then
raise_application_error(-20002,'Your Previous Loan Application is pending for Approval');
end if;
end if;
end TEST_RL;
Now my problem is
This Trigger is not working in the scenarios
i) suppose person applies for a loan today and once again applies the same loan without changing anydata in the fileds then trigger is not validating.. transacation is taking place..
eg:- person:- xx
loan amount:-200
click on submit it goes to approver
second time person:- xx
loan amount:- 200
click on submit it goes to approver
Trigger is working in the scenarios
eg :- person:- xx
loan amount :- 200
click on submt it goes to approver
second time person:- xx
loan amount :- 210
click on submit ( error message :- Your Previous Loan Application is pending for approval).
Can anyone help me out, how to handle this
Thanks in advnace

Okay let me give some recommendations.
I would suggest you don't use a database trigger. Triggers can mask unhandled exceptions (making it difficult to debug), aren't aware of p_validate architecture in HRMS APIs, can be easily accidentally disabled, and function at a level much lower than the 'business process' layer that you're interested in.
The recommended (and supported) way to add custom validation in Oracle HRMS is to use API User Hooks. Your use-case is perfect for API User Hooks. The hr_sit_api package has an API for both create_sit and update_sit. Both of these APIs have 'before' and 'after' user hooks.
If I've understood your requirements (and I'm still not sure I do completely), the following approach could work:
a) Implement a 'before' hook on hr_sit_api.update_sit.
b) In this hook add a check to see if the current p_person_analysis_id is being updated in hr_api_transactions. You'll also need to check the timing of what happens when the final approver approves: if the hr_api_transactions row still exists at the time the API is called to commit the update your hook will raise the same error. I have a feeling the hr_api_transaction data is already removed at this point but just one for you to check.
c) If it is currently being updated, raise the error (use fnd_message.set_name and fnd_message.raise_error)
This will prevent the user from updating the SIT if an update is already pending.

Similar Messages

  • How to apply different CSS styles to different table cells?

    I have an h:dataTable table and I would like to apply different CSS styles to different table cells depending on their content. If I were doing JSP I would probably have a <c:if> test on the cells, and give them a style name depending on contents, and then define the styles in a separate style sheet. Is there a way in JSF to do the equivalent? Thanks.

    mitchgart wrote:
    BalusC wrote:
    How to achieve a cell-specific style is already answered in my 1st reply of this topic.That tells how to apply a style to the text (or other content) inside a cell but not how to apply a style to the <td> as a whole. It would work for something like text font or text color but not cell border.
    I'm thinking I can mark the content somehow and then have javascript traverse the DOM, find marked content, and traverse outward to the enclosing <td>. Is there a better way?BalusC already spoke about rowClasses and columnClass attributes, I assume those are insufficient.
    The Tomahawk dataTable component has the rowStyleClass and rowStyle attributes for assigning CSS to the HTML tr tag. One is allowed to reference the row data variable when assigning values to these. However, see https://issues.apache.org/jira/browse/TOMAHAWK-523 for workarounds to bugs in some implementations.
    The Tomahawk column component has the styleClass and style attributes for assigning CSS to the HTML td tag. These also may reference the row data variable.

  • IUUC_REPL_CONTENT - How to apply filters and replicate for Cluster tables BSEG/CDPOS

    Hello Friends,
    I have replicated the transparent tables by applying filters in IUUC_REPL_CONTENT but I know it's different for Cluster tables.
    Does anyone replicated the BSEG or CDPOS ?
    I need some inputs on this folks.
    Thanks in advance.
    Regards
    Raja

    May be this is helpful - http://scn.sap.com/community/replication-server/blog/2014/02/25/how-to-filter-on-the-initial-load-parallelize-replication

  • DisplayTag applies to all my regular html tables ?!?!

    Hi guys,
    Wonder if someone can help me on this one: I've just started to use displayTags and the results are as expected. The problem is that all my regular HTML tables receive the property of displayTag. This is not good because it distorts the look of the entire page (the footer and header are positioned in the center all of a sudden)
    I explicitly stated the below code in my JSP page which I wanted to table's properties to kick in.
    <link rel="stylesheet" href="css/screen.css" type="text/css"/>
    I wonder how to apply the settings only to ONE table without touching preexisting regular HTML tables.
    Thank you

    ok...i got it, I simply played with the css files :-)

  • How can i make trigger with basler camera GIGE 659x494 - 70 FPS and I/O terminal block

    Hi all,
    How can i make trigger with basler camera GIGE 659x494 - 70 FPS and I/O terminal block

    Frank,
    If you are wiring an isolated power output to the EVS you will need to apply a power supply to the terminal block.  This is mentioned in the "wiring isolated power output" section of the EVS getting started guide located here.  The guide references the EVS user manual which provides a pinout of the d-ub connector in table 2-11 of the manual located here.  For more information on the camera settings you need to set on the Basler camera please see the user manual of the camera you refrenced here.
    To provide power to the camera you can purchase a power cable for the camera.  Rather than a power cable, since you want to also do triggering, you will want a Trigger and I/O Cable instead which is part number 779985-01 as seen on this product page.  The I/O cable would allow you to wire the trigger lines to the terminal block as well as the power lines.
    David A
    National Instruments
    FlexRIO Product Support Engineer

  • Macbook pro system running slow - etrecheck shows issues - any idea how to apply fixes?

    Hi I normally consider myself pretty web savvy but I'm totally lost on what to do here. This computer has been running slow since I got it, but the harddrive went sideways recently. I've never worked with a recovered drive - which I apparently have as my terminal lists my workfolder-2 so....I'm guessing I'm pretty screwed. I learned about etrecheck through the forums here but don't understand how to apply it
    Would anyone help me understand what I need to do?
    Here's my etrecheck:
    Problem description:
    very slow osx system even with only one or two apps open - standard 2013 macbook pro
    EtreCheck version: 2.1.5 (108)
    Report generated January 1, 2015 9:52:46 PM EST
    Click the [Support] links for help with non-Apple products.
    Click the [Details] links for more information about that line.
    Click the [Adware] links for help removing adware.
    Hardware Information: ℹ️
      MacBook Pro (13-inch, Mid 2012) (Verified)
      MacBook Pro - model: MacBookPro9,2
      1 2.5 GHz Intel Core i5 CPU: 2-core
      4 GB RAM
      BANK 0/DIMM0
      2 GB DDR3 1600 MHz ok
      BANK 1/DIMM0
      2 GB DDR3 1600 MHz ok
      Bluetooth: Good - Handoff/Airdrop2 supported
      Wireless:  en1: 802.11 a/b/g/n
    Video Information: ℹ️
      Intel HD Graphics 4000 - VRAM: 512 MB
      Color LCD 1280 x 800
    System Software: ℹ️
      OS X 10.8.5 (12F45) - Uptime: 4 days 8:16:35
    Disk Information: ℹ️
      APPLE HDD HTS545050A7E362 disk0 : (500.11 GB)
      disk0s1 (disk0s1) <not mounted> : 210 MB
      Macintosh HD (disk0s2) / : 499.25 GB (310.25 GB free)
      Recovery HD (disk0s3) <not mounted>  [Recovery]: 650 MB
      HL-DT-ST DVDRW  GS31N disk1 : (369.9 MB)
      disk1s1 (disk1s1) <not mounted> : 54 MB
      disk1s2 (disk1s2) <not mounted> : 26 MB
      disk1s3 (disk1s3) <not mounted> : 34 MB
      disk1s4 (disk1s4) <not mounted> : 33 MB
      disk1s5 (disk1s5) <not mounted> : 65 MB
      disk1s6 (disk1s6) <not mounted> : 29 MB
      disk1s7 (disk1s7) <not mounted> : 26 MB
      disk1s8 (disk1s8) <not mounted> : 20 MB
      disk1s9 (disk1s9) <not mounted> : 36 MB
      disk1s10 (disk1s10) <not mounted> : 12 MB
      disk1s11 (disk1s11) <not mounted> : 35 MB
    USB Information: ℹ️
      Apple Inc. FaceTime HD Camera (Built-in)
      Apple Inc. Apple Internal Keyboard / Trackpad
      Apple Inc. BRCM20702 Hub
      Apple Inc. Bluetooth USB Host Controller
      Apple Computer, Inc. IR Receiver
    Thunderbolt Information: ℹ️
      Apple Inc. thunderbolt_bus
    Configuration files: ℹ️
      /etc/hosts - Count: 2
    Gatekeeper: ℹ️
      Mac App Store and identified developers
    Kernel Extensions: ℹ️
      /Applications/VMware Fusion.app
      [not loaded] com.vmware.kext.vmci (90.4.18) [Support]
      [not loaded] com.vmware.kext.vmioplug.10.1.24 (10.1.24) [Support]
      [not loaded] com.vmware.kext.vmnet (0104.03.86) [Support]
      [not loaded] com.vmware.kext.vmx86 (0104.03.86) [Support]
      [not loaded] com.vmware.kext.vsockets (90.4.23) [Support]
      /System/Library/Extensions
      [loaded] at.obdev.nke.LittleSnitch (4228 - SDK 10.8) [Support]
      [loaded] com.globaldelight.driver.BoomDevice (1.1 - SDK 10.1) [Support]
      [not loaded] com.waltop.iokit.driver.USBAtTablet (1.1.0) [Support]
    Problem System Launch Agents: ℹ️
      [failed] com.apple.accountsd.plist
      [failed] com.apple.CalendarAgent.plist
      [failed] com.apple.coreservices.appleid.authentication.plist
      [failed] com.apple.pbs.plist
      [failed] com.apple.printtool.agent.plist
      [failed] com.apple.tccd.plist
    Problem System Launch Daemons: ℹ️
      [failed] com.apple.wdhelper.plist
    Launch Agents: ℹ️
      [running] at.obdev.LittleSnitchUIAgent.plist [Support]
      [not loaded] com.adobe.AAM.Updater-1.0.plist [Support]
      [loaded] com.google.keystone.agent.plist [Support]
      [running] com.penpad.penpadtablet.plist [Support]
      [loaded] org.chromium.chromoting.plist [Support]
    Launch Daemons: ℹ️
      [running] at.obdev.littlesnitchd.plist [Support]
      [loaded] com.adobe.fpsaud.plist [Support]
      [invalid?] com.adobe.SwitchBoard.plist [Support]
      [loaded] com.github.GitHub.GHInstallCLI.plist [Support]
      [loaded] com.google.keystone.daemon.plist [Support]
      [loaded] com.microsoft.office.licensing.helper.plist [Support]
    User Launch Agents: ℹ️
      [loaded] com.adobe.AAM.Updater-1.0.plist [Support]
      [loaded] com.adobe.ARM.[...].plist [Support]
      [failed] homebrew.mxcl.postgresql.plist [Support]
    User Login Items: ℹ️
      Boom Application (/Applications/Boom.app)
      iTunesHelper Application (/Applications/iTunes.app/Contents/MacOS/iTunesHelper.app)
    Internet Plug-ins: ℹ️
      JavaAppletPlugin: Version: 14.9.0 - SDK 10.7 Check version
      o1dbrowserplugin: Version: 5.38.6.0 - SDK 10.8 [Support]
      AdobeExManDetect: Version: AdobeExManDetect 1.1.0.0 - SDK 10.7 [Support]
      Silverlight: Version: 5.1.20513.0 - SDK 10.6 [Support]
      FlashPlayer-10.6: Version: 15.0.0.246 - SDK 10.6 [Support]
      WidevineMediaOptimizer: Version: 6.0.0.12757 - SDK 10.7 [Support]
      QuickTime Plugin: Version: 7.7.1
      Flash Player: Version: 15.0.0.246 - SDK 10.6 Mismatch! Adobe recommends 16.0.0.235
      googletalkbrowserplugin: Version: 5.38.6.0 - SDK 10.8 [Support]
      AdobePDFViewer: Version: 10.1.1 [Support]
      Autodesk123D32: Version: Autodesk123D32 1.0.6 - SDK 10.7 [Support]
      DirectorShockwave: Version: 12.1.3r153 - SDK 10.6 [Support]
    Safari Extensions: ℹ️
      Searchme [Installed] Adware! [Remove]
    3rd Party Preference Panes: ℹ️
      remoting_host_prefpane  [Support]
      Flash Player  [Support]
    Time Machine: ℹ️
      Time Machine not configured!
    Top Processes by CPU: ℹ️
          3% coreaudiod
          2% Activity Monitor
          1% WindowServer
          1% activitymonitord
          1% Google Chrome
    Top Processes by Memory: ℹ️
      168 MB Google Chrome
      49 MB Google Chrome Helper
      34 MB mds
      30 MB WindowServer
      26 MB Finder
    Virtual Memory Information: ℹ️
      93 MB Free RAM
      1.39 GB Active RAM
      1.35 GB Inactive RAM
      1.45 GB Wired RAM
      48.43 GB Page-ins
      17.53 GB Page-outs

    Searchme [Installed] Adware! [Remove]
    Start by going to Safari/Preferences/Extensions and un-install the above.
    17.53 GB Page-outs
    Adding some RAM would help. Even though you haven't restarted for 4+ days, this is a little high. The 2 places I’ve seen recommended most to buy reliable RAM are below. I have purchased RAM several times from Other World Computing and have always been very satisfied with the product and service. They have on-line instructions on how to replace the RAM. OWC has also tested RAM above what Apple states is the maximum. I now have 6GB installed on a machine supposedly limited to 4 GB.
    Crucial
    Other World Computing
    Activity Monitor – Monitor Performance Problems  
    Performance Guide
    Why is my computer slow
    Why your Mac runs slower than it should
    Slow Mac After Mavericks
    Things you can do to resolve slowdowns  see post by Kappy

  • How to apply an Outlook 2013 Open license to a pre-installed Office Home and Business 2013 installation for Email Auto Archiving functionality

    We're deploying new Dell pc's.
    Unfortunately we have a large existing install base of Office Home and Business in the field due to customers buying Office bundled on Dell machines.  Buying Open License Outlook licenses is more cost effective than upgrading to Office Pro Plus for all
    these users and is our preferred path.  We aren’t sure how to apply these Open License Outlook licenses since the Home and Business installations work off a single license key for all the applications

    Hi,
    Isn't the Office bundled on Dell machines already activated?
    If it's the OEM version that has been installed on the machines and you want to use retail product keys to activate the Office, it's not possible. You will need to uninstall the OEM version and install the retail version.
    You can check the OEM licensing system here:
    http://www.microsoft.com/OEM/en/licensing/productlicensing/Pages/office-2013-licensing-packaging.aspx
    To find more help about OEM depolyment, I should recommend you to get contact with the OEM Reseller Support System
    http://www.microsoft.com/OEM/en/Pages/contactus.aspx
    If I misunderstood anything, please feel free to post back.
    Regards,
    Melon Chen
    TechNet Community Support

  • How to apply album cover picture to all songs on cd not just one at a time?

    i found agreat website with free cd covers for my songs that will show up in the corner of my ipod. but i can figure out how to apply the picture to all the songs in an alubm an dnot just one, i can only drag the picture into the box in itunes one by one.

    I highly recommend Album Cover Finder
    http://www.amphonicdesigns.com/albumcoverfinder/
    It's not free, but it's worth the small investment of 9 bucks.
    I just point it to my iTunes library and it batch uploads the artwork to every file automatically.

  • How to lock multiple user for a transcation code at same time is der any tc

    how to lock multiple user for a transcation code at same time is der any tc
    suppose i hav 15 user and i want to lock 10 user for mm02 who can i to it

    Basis can do a export and import transport, still if don't have connection between boxes.
    or
    check this
    http://www.sap-basis-abap.com/abap/copy-program-variants-from-one-to-another.htm

  • How to handle format trigger in bi publisher report

    Hi all,
    anyone have idea how to handle format trigger in bi publisher report....
    also if someone will illustrate the how exactly we use the triggers in bi publisher reports.
    regards
    Ratnesh

    Hi,
    there's no direct support for the format triggers out of Oracle Reports. Therefore they are mentioned in the log file and in the created layout after conversion the objects with format triggers are colored red to show, that there you had to do some additional work.
    Currently you had to built the logic of format triggers in BI Publisher new. Hve a look in the User Guide, there are some examples for if or choose statements.
    regards
    Rainer

  • How to Apply a Newly Created Access Policy on Existing Users in OIM????????

    How to Apply a Newly Created Access Policy on Existing Users in OIM?
    When the rule is getting failed the user is getting removed from the group but resource is not getting revoked. This is happening only for the old uses..for the users which i created now it working fine..i mean its resource is getting revoked.
    (Retrofit access policy" is checked on the Access Policyand Revoke if not longer applied is checked.)
    For the old users i see the POl_Key is null, for new users i see a value '10'. So i updated the pol_key for old users same as it got generated for new users '10'.
    i even updated the form version too but still revoke doesn't work.
    I cant go for the below approach..
    In order to apply a newly created Access Policy on existing users, one has to make sure that:
    1) "Retrofit access policy" is checked on the Access Policy.
    2) Then run the "Set User Provisioned Date" Schedule task to apply the Access Policy on the existing users in OIM.
    Note: After 9.1.0.1 BP03 the access policy execution has been moved to a new scheduled task "Evaluate User Policies" as mentioned inDocument 839368.1 :How to Use Access Policies to Provision with Groups.
    Is there any other approach i can try.. if you have any idea please reply me asap
    Thanks..

    Thanks for the reply kevin..
    We decided to try the Schedule task (Set User Provisioned Date).
    But i see one problem here after seeing this post in metalik --> Can Access Policies Manage The Life-cycle Of Users Created via Reconciliation? [ID 1136540.1]
    According to this post Access Policies framework does not manage users who are obtained either through trusted reconciliation or target reconciliation.
    Is there any custom way to achieve this??
    How does the access policy framework revoke resource work? (revoke if no longer applies)??
    Edited by: IDMuser19 on Jun 21, 2011 11:43 PM

  • How to apply the Patchset 7 to Forms 6i

    Hi all !!!
    I need install the PatchSet 7 in the iAS Server 1.0.2.2.2 (concrectly at the Forms Server Service).
    I had stopped all services of Oracle, and had applied the patch. But the services of Forms and Reports is missing after.
    Any idea.
    How to appplies the patch?
    Thanks and best regards.
    Carlos Hernandez
    Barcelona (Spain)

    848478 wrote:
    How to apply the latest patch set for all the Installed Modules in 11.5.10.2 along with the Roll up's if any.https://forums.oracle.com/forums/search.jspa?threadID=&q=Latest+AND+Patchsets&objID=c3&dateRange=all&userID=&numResults=15&rankBy=10001
    https://forums.oracle.com/forums/search.jspa?threadID=&q=Latest+AND+Patches&objID=c3&dateRange=all&userID=&numResults=15&rankBy=10001
    Thanks,
    Hussein

  • How to connect external trigger PCI-1433

    Hi all:
    I met the same problem as this old post: https://forums.ni.com/t5/Machine-Vision/How-to-connect-external-trigger-PCIe-1433/m-p/1677560/highli...
    however the post did not give solution.
    I am having an issue getting the external trigger( from PCI 6259) to work with a cameralink camera, a PCIe-1433 card . The PCI 6259 is connected to BNC 2111, the output trigger signal from CTR0 is connected to the SMB connector on the 1433 card and is providing pulse train at TTL voltages (0-5V).  Using the MAX SOFTWARE and under the Acquisition tab I have CC1 set to external 0, however the camera is not receiving this external trigger. The camera is Basler 4096-140km.
    I measured the ouiput signal from CTL0, the sigal seems good.
    I tried RTSI trigger before, failded. I thought SMB should be more straight forward, seems I was wrong.
    Looking forward to reply!
    Attachments:
    camera configuration.jpg ‏168 KB
    External Camera Trigger(SMB).vi ‏57 KB

    Bobjojo,
    You will actually need to affect the properties of both the camera and the frame grabber to take advantage of this triggering mode. I found a document that contains a good run down of the process to acquire in this mode (linked below). As far as the programming for the acquisition is concerned, the frames will be built at the driver level for the specified frame height. This means that the IMAQ driver will composite the line scans for you, and any simple acquisition (the document shows using the Vision Acquisition Express VI) will be able to pull the image into LabVIEW.
    www.ni.com/white-paper/13786/en/pdf
    Karl G.
    Applications Engineer
    ni.com/support

  • How to apply business rule over report level

    Hi All,
    I have a column name AAA over which i have to apply a business rule/filter like
    COUNT(“X Fact”." ID") WHEN “X Fact”.”Time to Issue Policy” <= 2 days at report level.How to apply that?any idea?
    Regards,
    Sonal

    Hi,
    Thanks for responce.
    Yes my AAA col is measure column coming frm Order Fact table (i.e AAA= "Order Fact"."Number of Order") & below is Business rule which I have to apply there
    COUNT(“Order Fact”."Order ID") WHEN “Order Fact”.”Time to Order” <= 3 days.How Can I apply this logic there at report level.Plz help?
    Regards,
    Sonal

  • How to apply a Character Style that's already been made in a template document?

    First of all I'd like to thank everyone that helps. I'm a complete beginner at scripting and appreciate all your help.
    I'm basically using GREP expressions to find patterns in a document and apply a Character Style which has already been made. This Character style was not made using script, but just in InDesign when making and setting up the template.
    var myDoc = app.activeDocument;
    //Clear the find/change grep preferences.
    app.findGrepPreferences = NothingEnum.nothing;
    app.changeGrepPreferences = NothingEnum.nothing;
    //Set the find options.
    app.findChangeGrepOptions.includeFootnotes = false;
    app.findChangeGrepOptions.includeHiddenLayers = false;
    app.findChangeGrepOptions.includeLockedLayersForFind = false;
    app.findChangeGrepOptions.includeLockedStoriesForFind = false;
    app.findChangeGrepOptions.includeMasterPages = false;
    //GREP Expression for finding all HEADERS
    app.findGrepPreferences.findWhat = ".+\n";
    //Applying formatting changes to put into All Caps, Bold and changing the font size to 12 pt.
    app.changeGrepPreferences.capitalization = Capitalization.allCaps;
    app.changeGrepPreferences.fontStyle = "Bold";
    app.changeGrepPreferences.pointSize = "12";
    myDoc.changeGrep();
    //Clear the find/change preferences after the search.
    app.findGrepPreferences = NothingEnum.nothing;
    app.changeGrepPreferences = NothingEnum.nothing;
    This is how I currently have it. I will manually define the changes to the text. The problem is, each template uses a different set of fonts and not all of them use Bold e.g. Sabon can use CE Bold.
    I would like to learn how to apply a Character Style and have tried looking around but nothing seems to work.
    Any help would be much appreciated.
    Thanks.

    select the text where u went  and run below  script after change group as per ur template.
    var myDoc = app.activeDocument;
    var mySel = app.selection[0];
    //Clear the find/change grep preferences.
    app.findGrepPreferences = NothingEnum.nothing;
    app.changeGrepPreferences = NothingEnum.nothing;
    //Set the find options.
    app.findChangeGrepOptions.includeFootnotes = false;
    app.findChangeGrepOptions.includeHiddenLayers = false;
    app.findChangeGrepOptions.includeLockedLayersForFind = false;
    app.findChangeGrepOptions.includeLockedStoriesForFind = false;
    app.findChangeGrepOptions.includeMasterPages = false;
    //GREP Expression for finding all HEADERS
    app.findGrepPreferences.findWhat = "role";
    //Applying formatting changes to put into All Caps, Bold and changing the font size to 12 pt.
    //app.changeGrepPreferences.capitalization = Capitalization.allCaps;
    //~ app.changeGrepPreferences.fontStyle = "Bold";
    //~ app.changeGrepPreferences.pointSize = "12";
    app.changeGrepPreferences.appliedCharacterStyle=myDoc.characterStyleGroups.item("Style Group 1").characterStyleGroups.item("Style Group 2").characterStyles.item("Header")// Header is name of character name
    mySel.changeGrep();
    //Clear the find/change preferences after the search.
    app.findGrepPreferences = NothingEnum.nothing;
    app.changeGrepPreferences = NothingEnum.nothing;
    If it's help then click yes
    Mi_D

Maybe you are looking for