The community will be in read-only from Tuesday 11:59pm (PST) to Wednesday 7:30am (PST)
The community will be in read-only from Tuesday 11:59pm (PST) to Wednesday 7:30am (PST)
Project and Portfolio Management Practitioners Forum
cancel
Showing results for 
Search instead for 
Did you mean: 

Saving apply on page load tokens

Highlighted
eata
Regular Collector

Saving apply on page load tokens

Hello all;

We have some custom tokens which runs on apply page load.

But the data they selected is not recorded to database.

Let me illustrate:

 

 

Here a rule runs and fills reference project link.

Another one:

 

 

But in data base, the corresponding  table columnns are null for corresponding field on screen.

 

 

I must open each request and press save button to update request details.

It is a high work load.

Is there any one who produced an end of day script ? or solve a similar problem before.

Or is there any way you can suggest. (other than opening each case and pressing save button)

Here is one of the rules:

select
'http://ppm.asyalocal.com.tr/itg/project/ViewProject.do?projectId='||pm.project_id,
pm.project_name||' - '||pm.display_status
from
kcrt_table_entries ent ,
pm_projects pm
where
1=1
and ent.visible_parameter6='[REQ.REQUEST_ID]'
and  pm.pfm_request_id = ent.request_id

 

 

 

 

14 REPLIES
AlexSavencu
Honored Contributor

Re: Saving apply on page load tokens

Hi,

The rules for the page load event have been specifically designed like this. The fields populated by the page load rules are saved when the user clicks the save button or when the request is performing a transaction.

Having a daily job will also not help since the values populated by the page load rules are only stored in the session.

I would suggest to switch to field change rules wherever possible.

Cheers
Alex

--remember to kudos people who helped solve your problem
eata
Regular Collector

Re: Saving apply on page load tokens

Hello Alex.

I could not find out what you mean.

You suggest me to change rule type ? As in the screen below?

TurboMan
Member

Re: Saving apply on page load tokens

Alex is telling you if you use "Apply on field change" instead of "Apply On Page Load"

Utkarsh_Mishra
Honored Contributor

Re: Saving apply on page load tokens

Hi Eata,

 

Insead of SQL query in your rule, you can use an Oracle function and...

 

In that Oracle function use:

 

PRAGMA AUTONOMOUS_TRANSACTION;

 

This will commit you data without saving the request/page.....

 

But it has some assoicated disadvantage... say if user does not want to save the change... but then also it will commit the change.

Cheers..
Utkarsh Mishra

-- Remember to give Kudos to answers! (click the KUDOS star)
AlexSavencu
Honored Contributor

Re: Saving apply on page load tokens

Hi, Utkarsh,

 

the correct approach is to call an Oracle function that wraps an Oracle procedure, since no INSERT/UPDATE/DELETE is allowed in a function that is part of a SQL query. This is rather complicated to maintain, therefore simply using Apply on Field Change rules is a much better idea.

 

cheers

alex


--remember to kudos people who helped solve your problem
eata
Regular Collector

Re: Saving apply on page load tokens

Thank you very much for your patient help.

If I change rule from "apply on page load" to "apply on field change" there has to be a change on the field to trigger that rule. Isn't it? There is no field available on the page.

(apply on field change runs at a change in any field or on the specific field the rule is applied?)

 

Regards  

AlexSavencu
Honored Contributor

Re: Saving apply on page load tokens

Hi,

Correct.

These rules are triggered when the fields configured to trigger the rule are updated.

I don't know if this is applicable for your implementation, but you can create a custom Oracle stored procedure to run once a day in order to update the requests.

Cheers
Alex

--remember to kudos people who helped solve your problem
Utkarsh_Mishra
Honored Contributor

Re: Saving apply on page load tokens

Hi Alex,

 

Just to update that in HP PPM Rules and Function-Execution step... there you can use  "Update/insert" inside a function with SQL .... it won't give any error.

 

Here I have used it at many places.. and I had never faced any issues.

 

I totally agree that Field change rule is the Best approach... but here user wan't to save the changes without saving the request (may be my undersating is incoorect)... so I thought of proposing the above solution..

 

Cheers..
Utkarsh Mishra

-- Remember to give Kudos to answers! (click the KUDOS star)
AlexSavencu
Honored Contributor

Re: Saving apply on page load tokens

Hi, Utkarsh,

 

indeed, it works in execution steps, but not in request type rules. Please double check the same.

 

cheers

alex


--remember to kudos people who helped solve your problem
eata
Regular Collector

Re: Saving apply on page load tokens

Yes Alex you are exactly right. But data base update process is not allowed by HP consultants. If the update process fill cause any data delete or data dublication I will be responsible.

 

My actual problem is there are two flows.

One is entered request flow, the other is project flow. Some of the requests are regarded as project and the project has a separete life cycle. The projet status is changing while project is living. And request has a request status field. The field selects data of onther flow.

 

I am considering to run a query and find updated requests' IDs. Then create a pyton script to emulate browser.

Open each case and press save button.

 

Or updaterequest web service to update request status.

I am working on it.

AlexSavencu
Honored Contributor

Re: Saving apply on page load tokens

Hello, eata,

 

using browser emulation can lead to many unexpected issues.

 

There is another option: you can create a new workflow with an automatic step to be executed once a day. This step would actually call a DB procedure to perform the updates you need.

 

cheers

alex


--remember to kudos people who helped solve your problem
eata
Regular Collector

Re: Saving apply on page load tokens

Hello;

I developed related function and procedure.

But I am getting error could you help me:

 

command:

select ppmasya_usr.krsc_utils.upd_rlt_req(37908)
from dual;

 

error:

cannot perform a DML operation inside a query

Cause: DML operation like insert, update, delete or select-for-update cannot be performed inside a query or under a PDML slave.

Action: Ensure that the offending DML operation is not performed or use an autonomous transaction to perform the DML operation within the query or PDML slave.

 

FUNCTION upd_rlt_req
( projectno in number                        )
    return varchar2
    IS
        --type rc is ref cursor;
    --l_link    varchar2(100);
    --l_status    varchar2(100);
    --i_projectno    number;
    --i_projectno:= to_number(projectno);  
       --l_cur    rc;
   begin
  
ppmasya_usr.krsc_utils.update_rlt_req(projectno);
      

       return 'Y';
end upd_rlt_req;

 

PROCEDURE update_rlt_req
( projectno in number                        )
   
    IS
        --type rc is ref cursor;
    --l_link    varchar2(100);
    --l_status    varchar2(100);
       --l_val    varchar2(4000);
  
       --l_cur    rc;
   begin
  
update ppmasya_usr.kcrt_request_details krd  
set
(krd.parameter9, krd.visible_parameter9)=
(select
'http://10.100.44.27:8085/itg/project/ViewProject.do?projectId='||pm.project_id,
pm.project_name||' - '||pm.display_status
from
ppmasya_usr.kcrt_table_entries ent ,
ppmasya_usr.pm_projects pm
where
ent.request_id=pm.pfm_request_id
and
ent.request_id=projectno)
where krd.request_id in (select ent2.visible_parameter6 from ppmasya_usr.kcrt_table_entries ent2 where ent2.request_id=projectno);

commit;
      

      
end update_rlt_req;

 

 

 

 

eata
Regular Collector

Re: Saving apply on page load tokens

How Can I use PRAGMA AUTONOMOUS_TRANSACTION;
In my function and procedure at the top of the page?

eata
Regular Collector

Re: Saving apply on page load tokens

I am answering my question. please give me kudos :)

 

FUNCTION upd_rlt_req
( projectno in number                        )
    return varchar2
    as
pragma autonomous_transaction;

   begin
  
ppmasya_usr.krsc_utils.update_rlt_req(projectno);
      

       return 'Y';
end upd_rlt_req;

//Add this to "OnDomLoad" event