You are viewing this site as a guest. You can still ask questions and help others! Join our Dev2Dev IT Community to receive your own blog, share your knowledge, and much more.

Restrictive Page.Activate event and Insert, Update or Delete data.

10 replies [Last post]
pwauly's picture
User offline. Last seen 9 years 2 weeks ago. Offline
Joined: 05/09/2011
Posts: 5

Hi All
we have encountered an issue with the Page.Activate event and saving data. We have resolved the issue and I'd like to post our solution. I have searched for the issue on this site and can not see anyone asking for help however appologises nonetheless for repetition if this situation has been covered.

Page PeopleCode events only permits a DML SQL commands (Insert,Delete...) to called particular circumstances. These events are well documented - look for PeopleBooks Component Process workflow Post Change, Save Change etc.

Well we wanted to created a new row of data in a log table when a user lands on a page.
The only event triggered in this case would be Page.activate.

But Peoplesoft Architecture was preventing us from issuing a SQLExec command
ie SQLEXEC ("Insert into %Table(A_Record) (Column1) values ('A')" ) ;
or
via The record Insert command
&MyRec = CreateRecord(Record.A_TABLE)
&MyRec.Column1.value = "A";
&MyRec.Insert();

So the solution here was to write a Application Engine eg "UD_Insert_Data_AE".
Create a new step and SQL action.
Write your SQL to insert the value - eg
Insert into %Table(A_Record) (Column1) values ('A')
Leave the Commit Action to the default.

Save your Application Engine,
Then- go to PeopleSoft and create a Process for your new appEngine and assign the values:
Component = PRCSMULTI
Process Groups = ALLPAGES

Then Finally kick the Application Engine from the Page.Activate peoplecode:

CallAppEngine("UD_Insert_Data_AE");

Hope this helps.
Pwauly

pwauly's picture
User offline. Last seen 9 years 2 weeks ago. Offline
Joined: 05/09/2011
Posts: 5
Re: Restrictive Page.Activate event and Insert, Update or ...

Hi Again -
Feel to ask questions about the above post.

Thanks
Pwauly

Lepa's picture
User offline. Last seen 1 year 37 weeks ago. Offline
Joined: 06/23/2008
Posts: 591
Re: Restrictive Page.Activate event and Insert, Update or ...

pwauly, did you try using save() or savenow() functions in the page activate code and then have your insert statement on some save peoplecode event? I would imagine that to be better than calling an application engine.

Thanks for sharing your solution though, I truly appreciate it.

Give back to the community and help it grow!
* Help with unanswered forum questions and issues
* Register or login to share your knowledge at your own blog

pwauly's picture
User offline. Last seen 9 years 2 weeks ago. Offline
Joined: 05/09/2011
Posts: 5
Re: Restrictive Page.Activate event and Insert, Update or ...

Hi Lepa
thanks for the feedback. No we had not initially tried using the functions Do Save or DoSaveNow() on the Page.Activate event and have the SQL business-end on a PostSave event.

I have tried this method and found it not to succeed due to the PS restrictions placed on the use of these functions.
IE We witnesed this error:
"Built-in function DoSave cannot be called from Other PeopleCode (180,182) UD_TEST_PAGE.Activate PCPC:31 Statement:1

The specificed built0in function has restrictions on what types of PeoplCode programs it may be used in. It has been used in a program that violates these restrictions.

Review and rework the PeopleCode toremove the violation. " OK

This message is also displayed when DoSaveNow(); is used.

So thanks for the suggestion and yes I agree that the use of an application engine for this case could be deemed overkill but so far it been entirely neccessary - and so far the only successful method.

Thanks
Pwauly

Hari_aindian's picture
User offline. Last seen 6 years 19 weeks ago. Offline
Joined: 08/02/2010
Posts: 84
Re: Restrictive Page.Activate event and Insert, Update or ...

I think we can do this through publishing message from Page Activate .

rahulkhandelw's picture
User offline. Last seen 9 years 8 weeks ago. Offline
Joined: 10/16/2009
Posts: 34
Re: Restrictive Page.Activate event and Insert, Update or ...

I agree with Hari, publishing a message would be better. It's worth giving a try.. :)

pwauly's picture
User offline. Last seen 9 years 2 weeks ago. Offline
Joined: 05/09/2011
Posts: 5
Re: Restrictive Page.Activate event and Insert, Update or ...

Thanks for the PS message suggestion - i'll give it a whirl. Cheers

RR_2011's picture
RR_2011 (not verified)
Re: Restrictive Page.Activate event and Insert, Update or ...

pwauly,
Did try publishing message? did it work?

pwauly's picture
User offline. Last seen 9 years 2 weeks ago. Offline
Joined: 05/09/2011
Posts: 5
Re: Restrictive Page.Activate event and Insert, Update or ...

Hi RR_2011
no I didn't try the messaging technique that was proposed by an earlier post. I take it you're trying to implement something like this? Are you encountering any issues?

Thanks
Pw

RR_2011's picture
RR_2011 (not verified)
Re: Restrictive Page.Activate event and Insert, Update or ...

Hi pwauly,

It works. Publishing Async message from Page activate works. have no issues.

if you get a chance try it out and let me know if you have any questions and I will be glad to asnwer them.

Good post.
RR_2011

Guest's picture
Guest
Re: Restrictive Page.Activate event and Insert, Update or ...

you can try using iscript for this. It will work. you can go through the iscript concepts.

1. Create a HTML
2. create a function in your weblib record. The function should start with Iscript_. I believe
3. Call using generatescriptcontenturl() in page activate.