The views expressed on this blog are my own and do not necessarily reflect the views of Oracle.

Sunday, 20 January 2013

iScript in PeopleSoft


For those who have heard about iScript and wondering what it is, I could give a basic understanding on the iScripts. iScript is a method by which Peoplesoft  offers control to the developer in overriding the people tools frame work. In simple words using iScript, developer will be able to get complete control on the browser. You can create pages which looks like other websites (eg: facebook, amazon etc) still within the Peoplesoft system.

iScript have two main classes, Request and Response. Those who have experience with web development could easily relate these words. For others I could explain it in simple words.

Request class will get the parameters passed from the browser. For eg: in google if you search for “Peoplesoft”, then the browser will send a request to the server with parameter q and parameter value “PeopleSoft”. So in our iScript we can get the parameter value “PeopleSoft” using the request class and send out appropriate result (response).

As you have thought, Response class is the class responsible to give result to a query. In the above example once we receive the search word “Peoplesoft” and performed the search, we need to display the search result in the browser. For this we will formulate the result html and prints it on the user browser using the Write() or WriteLine() method of the response class.

Writing iScript Programs

1.       You should write iscript programs in record field event of any record starting with WEBLIB_ .
2.       The iScript program will be written like a normal function except that the function name starts with IScript_
For example I want to display a hello world page to the users. The basic steps are as follows.

First I choose a record, say WEBLIB_HELLOWORLD and on the record field (say HTML) Field Formula and write a function IScript_HelloWorld.

Now I create a HTML object with the html code to be printed.

HTML object name is HELLOWORLD.

<!DOCTYPE html>
<html>
<body>
<h1>Hello World</h1>
</body>
</html>

Now my code looks as below.

Function IScript_HelloWorld()
Local string &sHTML;
rem Get the text to be printed from the HTML object;
&sHTML = GetHTMLText(HTML.HELLOWORLD);
rem Print the html to the client browser;
%Response.Write(&sHTML);
End-Function;

3.       Now I need to give permission to the iScript. It is like normal activity, go to permission list open web libraries section and give necessary permission to the iScript (you need to choose iScript by drilling down from the underlying record).

4.       Now you can access your iScript page by going to the below navigation http://server:port/psc/site_name/portal_name/node_name/s/WEBLIB_name.FIELDNAME.FieldFormula.IScript_name

If you are already logged in, you will be taken to the hello world page. Otherwise peoplesoft sign in page will appear and from there you will be directly taken to the iscript page on successful login.

Now if you come to real applications, instead of printing hello world, if you want to print a value from data base. In the place of string “Hello world” in the HTML definition replace it with %bind(:1).
Now in the code where you get the html text, use the below.

rem I print “iscript example”  as the text;
&sHTML = GetHTMLText(HTML.HELLOWORLD,”iscript example);

The hard coded string can be replaced with a variable with has fetched the value from the database. Thus making your program more interactive. To add on more functionality you could use post functionality in the HTML and obtain the parameters using the Request class and printing sensitive data.

rem Getting parameter passed by the browser.
&sParm = %Request.GetParameter(“search”);

Now you can do processing based on the obtained string and print the output method.


iScripts are interesting method in peoplesoft to un-cuff the restrictions put by peoplesoft application designer. You can create content rich pages, implement ajax/json services, create mobile pages, redefine portels that has visibility in larger crowds, create mobile applications etc using the peoplesoft iscript.

While using iscript, you should take care of the below 3 points
1.       Browser compatibility of the HTML rendered
2.       Translation of the text printed on the browser
3.       Multi-lingual, multi-market and multi-currency situations should be taken care.

You can start with the hello world example and unwind yourself. I’m sure it will be fun experience.




13 comments:

  1. Doing a great job, Keep posting !!!

    ReplyDelete
  2. Great post, needed a simple "hello world" example to start teaching myself iScripts and this was the perfect place to start

    ReplyDelete
    Replies
    1. @mmeyer Thank you for the feedback.

      Delete
    2. how to integrate peoplesoft with google maps using iscript?

      Delete
    3. @kanishk If you want to display google map in the entire page, then you can use the Response.Write method to write the entire code (which will be readily available from the google developer tools) which will open up google maps in the full page.

      If you are looking at displaying google maps along with some other data in the the existing PeopleSoft page, instead of iScript you should be preferring HTML object in the application designer page designing tools. Create an iframe and add the code provided by google inside that.

      Delete
    4. Good job on explaining it for newbies in a way that Peoplebooks can't.

      Delete
    5. @Deve Thank you for the feedback.

      Delete
  3. Please describe how client send parameters to server , so that request class can be executed and give response

    ReplyDelete
    Replies
    1. Hi Satyajit,

      You can get the parameters passed from any external system using the getparameter method of the request class. Do you processing in peoplecode and send any response (if any) using the write method of the response class.

      Thanks,
      Tony

      Delete
  4. Describe how client data are captured in request class.

    ReplyDelete
  5. Describe how client data are captured in request class.

    ReplyDelete
  6. Do you which web library gets triggered when Peoplesoft home page is refreshed?

    ReplyDelete
    Replies
    1. Hi Sayeed,

      Checkout the WEBLIB_PORTAL library for classic functions. With the Fluid version the homepage is a People Tools component.

      Thanks,
      Tony

      Delete

Followers