Wednesday, August 7, 2013

What is an Iscript?

  • IScripts are Internet Script classes.
  • It is a specialized PeopleCode function that generates dynamic web content.
  • It is stored in a record definition.
  • The record definition name must start with WEBLIB_. The function can be in any field event of the record definition. By convention, we generally use the field ISCRIPT1 and the event FieldFormula.
  • The function name, however, must start with IScript_ and cannot take any parameters or return a value.
  • They interact with web clients (browsers) using a request-response paradigm based on the behavior of the Hypertext Transfer Protocol.
  • One must have PeopleSoft Pure Internet Architecture set up correctly before you can run an iScript.





Flowchart for IScript


How to call an IScript?

  • It can be called a number of ways. How you call it depends on the purpose of the IScript.
  • If your IScript is a pagelet, then you will create a CREF for your IScript in the portal registry under.
Navigation - Portal Objects > Pagelets.
  • If your IScript is called from JavaScript (Ajax, etc), then you call your IScript using a URL like
http://server:port/psc/site_name/portal_name/node_name/s/WEBLIB_name.FIELDNAME.FieldFormula.IScript_name.
To make it easier, you can generate an IScript URL using the PeopleCode built-in function GenerateScriptContentURL.



IScript Security

IScripts are secured on your system similar to Component Interfaces. After you create a WEBLIB record, and your functions, you must add them just as you would add a page to an application.


To add security to an iScript :

  • Navigate to the Maintain Security page and open the Permission List to which you want to give access.
  • Select Web Libraries.
  • You may need to scroll through the tabs at the top of the page to access the Web Libraries tab.
  • (Optional) Add new WebLibrary for Permission List.Select the access you want to give each function in the WEBLIB record.

Note:
IScripts aren't part of the regular Component Processor flow.

%Request: You can use the %Request object to read parameters that were sent to the script. For example, if the URL had “?EMPLID=00001? at the end of it, you could use the following PeopleCode to read it:

&emplid = %Request.GetParameter("EMPLID");

This system variable is applicable only in an internet script.

%Response: This returns a reference to the response object. This reference can be used like an object, that is, you can use this as part of a dot notation string. You can use the %Response to create the output HTML, XML, or other format. The Write function is the main function that you will use:
For example:

%Response.Write("<b>Hello, World</b>");

This system variable is applicable only in an internet script.

When to use Iscripts?

Here are two scenarios where iScripts would be an appropriate choice:

Scenario 1: The page being developed cannot be built using PeopleSoft Application Designer.
An example of this is a page that requires more than one HTML form.
PeopleSoft Pure Internet Architecture places the entire page inside of a single form tag, so no other HTML form tags can be added.
In this case the requirements of the page can't be met by pages created in PeopleSoft Application Designer, so use iScripts instead.


Scenario 2: The page being developed never accesses the database.
Using a page and Component Processor for this type of page incurs unnecessary processing overhead.
An example of this is a page that talks to another website and redisplays HTML from the remote site.

Determine the URL

The URL for a component looks something like this:
… /c/MenuName.ComponentName.Market

The URL for an IScript looks something like this:
… /s/RecordName.FieldName.Event.FunctionName

Scope of an IScript

  • They can be used only as part of a PeopleSoft Pure Internet Architecture application either as part of a page created in PeopleSoft Application Designer or an IScript.
  • An IScript is always contained in a WEBLIB record. You wouldn't use any of these objects in an Application Engine program, a Component Interface, and so on.
  • However, an IScript could call and start a Component Interface, a Business Interlink, and so on.