HowTo: Creating IScripts



Step 1: WEBLIB_ record

You must put your PeopleCode on a record that begins with “WEBLIB_”. You can either create one or add onto an existing record that meets that naming convention.

Step 2: Create the PeopleCode Function

The function name should start with “IScript_”.

%Response

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:

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

%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");

Step 3: Security

You must grant security to your IScript before you can view it. This is done on the Permission List just like the security for a regular page.

Nagivation to the Permission Online:

PeopleTools > Security > Permissions & Roles > Permission Lists

Go to the WebLibraries page/tab.

On that page, you will need to enter the record name of the script. Then, click on the Edit link to choose the specific IScript that you wish to grant access.

Step 4: 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

See PeopleBooks for more information.

Step 5: Register Your IScript

If an end-user should access the IScript, you need to put a content reference in the menu for easy access. You can do so, by registering your script through the registration wizard. If you just intend to access the script via code, you don’t need to do this step.

When you open a record that begins with “WEBLIB_”, you will notice a new button on the toolbar for the registration wizard. Just click that button and follow the steps.

See PeopleBooks for more information.

Resources

These resources may not be as relevant:


Share

8 Comments

  1. Excellent addition! Thanks for providing this. Helped me out a lot in learning IScripts.

    Thanks
    Jeromy

  2. praveen says:

    Thank you for the post. I want o t know in details how an Iscripts works
    1.if I want ot add additional functionality of the page like auto comple to search fields on the page where to invoke these iscripts.
    2.if I want to interact with third paty webservices as per use keyin(same time ) we can not use any peoplecode events there on the page i hope iscripts can help to resolve these but i want to know how it works.
    3. a synchronus reuest msg should send and recieve when part of string tyed in the edit box.

  3. praveen says:

    I am able to use IScript as content reference but it will not fulfil the requiremnet…

  4. digitaleagle says:

    praveen,

    Here are a few thoughts in response to your questions:

    1. Its sounds like you need more than IScripts. You can use Javascript on your page to perform actions in the browser when a user types into a field. The javascript can tell the browser to load a URL in the background that would contain the data for your autocomplete. So, what I would do is have your javascript load the URL for your IScript. Then, the IScript would process and load the results either into XML or JSON format. The Javascript on the page would parse the data and present it to the user without ever refreshing the current page.

    You might consider using a library like jQuery for the javascript on the page. jQuery has quick and easy methods for loading a URL, and the UI library may have some functions that will make your autocomplete easier.

    2. For the web service, you might not need an IScript at all. You might be able have the javascript from the user’s browser interact directly with the webservice. Or, you could use javascript to load an IScript URL, which would in turn trigger your IScript PeopleCode and allow you to do what you need to do from PeopleCode.

    3. Again, Javascript is the tool you need for this type of event. If you have Deffered Processing turned off, the FieldEdit and FieldChange events trigger after the user changes a field. But, in reality, what is happening is PeopleSoft has some javascript that forces the page to reload when the user leaves a field that he changed. This is not what you want, and so, I understand what you are saying in that PeopleCode doesn’t work.

    Take a look at this jQuery reference:
    http://remysharp.com/visual-jquery/
    If you look at the Events > Event Helpers, they have a keypress(fn) function that will allow you to attach a function to the field’s keypress event.

    One big thing you have to keep in mind is that you have to make sure to test your javascript in all of the browsers that your users will be using. When writing PeopleCode, you just have to test the code running on the server, but javascript runs in the browser. Each browser works slightly differently. That is one of the reasons I like jQuery: they have already taken into account some of the browser differences.

    Here are some other posts that might help:
    JSON: http://psst0101.wordpress.com/2009/03/25/json/
    jQuery; http://psst0101.wordpress.com/2009/01/12/jquery-and-peoplesoft/

  5. praveen says:

    Thank you for the responce…

    Can you help me me with some code or can you explain me the existing Iscript_timeoutwarning how it will be invoked?

    Like I have checked the source page of peoplesoft home,It has the Iscript_timeoutwarning script but how it will get execute after ome period of time.where the exact event get trigger it and get executethis code….

    I am not a Javascript programmer but with effort i ried to understand some.. but need some help from you thanks…

    • digitaleagle says:

      Praveen,

      Sorry. I lost track of this comment, and I am just now getting back to it.

      I did a little research in PeopleTools 8.52, and here’s what I found. In the PT_SAVEWARNINGSCRIPT javascript file, there is a function called displayTimeoutWarningMsg2(). That gets triggered by a setTimeout() call. Near the bottom, you’ll see a window.open() that opens the timeout warning dialog. The URL passed to that window is passed in a variable called timeoutWarningPageURL. That variable has the URL to the iScript IScript_TIMEOUTWARNING.

      I know it’s late, but I hope that helps.

  6. praveen says:

    Can you hel me how to call Iscript from Java Script.

    • digitaleagle says:

      Praveen,

      Calling an iScript from javascript requires loading a page or URL. You can do this in 1 of 2 ways:
      1. Open a new window or navigate the current page to the iScript’s URL.
      2. Make an AJAX call with HTTPRequest or a library such as jQuery’s ajax() functions.

      I hope that helps.

Leave a comment