您的位置:首页 > 运维架构

Create Google Maps directions in PeopleSoft using Related Content

2012-07-18 22:55 656 查看

Create Google Maps directions in PeopleSoft using Related Content




In my
previous post on setting up predelivered collaborative related services, I was asked to also elaborate on how to create your own custom related content based on field content from the component. In this post I will explain how to incorporate Google Maps
directions as related content based on the home address of an employee and the work location. For this example I will be using PeopleSoft HCM9.1 on PeopleTools 8.51.

First let’s examine the Google Maps direction service. You can invoke directions straight from an url using start location and end location parameters. Base url looks like this:
http://maps.google.com/maps?saddr=[startlocation]&daddr=[endlocation]
You can see that url has two variables consisting of the start and end location. For example if you would construct the following url:
http://maps.google.com/maps?saddr=Oracle, San Francisco&daddr=Duboce Avenue, San Francisco

You will end up with following:




We will use this base url to set up a related content service in PeopleSoft and expend this url with the work and home location of an employee on the Home and Mailing Address page.

Setup Related Content Service

First we need to create the service. Go to PeopleTools > Portal > Related Content Service > Define Related Content Service and add a new entry




In the screen above you will see an extra parameter output. This has to have a fixed value of
embed. This is a requirement from Google, if you want to use Google Maps in junction with iFrames.
Now we need to have access to the home and work location. I will add this service to the Home and Mailing Address page. Here we have access to the home address and upon changing your home address you will see a new direction being
generated.

Add Work location to Home Address component

The page below is the vanilla page HR_HOME_MAILING




This page contains the Home address. To be able to invoke Google Maps directions, we will have to fetch and add the work location to this page. I will store the work location in a derived record and add it to the page level 0.
First let’s have a look at the current work location of the employee.


Now that we
know the home and work location the final url that the Related Content Service will construct will be http://maps.google.com/maps?saddr=643 Robinson St, Buffalo&daddr=500 George Washington Pkway, New York
This will be presented like:



First start by creating a derived record to store the from and to location like below



Now add field FROM_LOCATION to level 0 and add Component PeopleCode PostBuild Event, to store the work location from the current job assignment.
It is important to set the style of the field to
PTRANSPARENT
. This style will make the field invisible for the eye but accessable for the Related Content Service.



Code will be something like this:
Local Record &Job, &Location;
/* Get current assignment */
&Job = CreateRecord(Record.CURRENT_JOB);
&Job.EMPLID.Value = HR_SS_PERS_SRCH.EMPLID.Value;
&Job.EMPL_RCD.Value = 0;
&Job.EFFSEQ.Value = 0;
&Job.SelectByKeyEffDt(%Date);

/* Get location details */
&Location = CreateRecord(Record.LOCATION_TBL);
&Location.SETID.Value = &Job.SETID_LOCATION.Value;
&Location.LOCATION.Value = &Job.LOCATION.Value;
&Location.SelectByKeyEffDt(%Date);

/* Set TO_LOCATION to worklocation address and city */
GOOGLEDIREC_DER.TO_LOCATION.Value = &Location.ADDRESS1.Value
| ", " | &Location.CITY.Value;

Get Home Address

Although we have the home address on this page, I would like the concatenate the address and city. I will add the FROM_LOCATION on level 0 and fill this with the address and city. Although you can have Related Content Services reference level 1 and higher,
you can not assign it to a certain row and this page can have multiple addresses (HOME, MAIL).

Add field FROM_LOCATION on level 0 and add the following lines to the PageActive code. We will not be adding this code to the Postbuild, since this only executes once on the component. We want the Related Content Service to refresh every time you change
your home address.

Local Rowset &Address;

&Address = GetLevel0()(1).GetRowset(Scroll.PERSON_ADDRESS);

For &i = 1 To &Address.ActiveRowCount
   If &Address(&i).PERSON_ADDRESS.ADDRESS_TYPE.Value = "HOME" Then
      GOOGLEDIREC_DER.FROM_LOCATION.Value = 
         &Address(&i).PERSON_ADDRESS.ADDRESS1.Value
         | ", " | &Address(&i).PERSON_ADDRESS.CITY.Value;
   End-If;
End-For;

Assign Related Content Service to page

Go to the Manage Related Content Configuration Page.




Click on Assign Related Content to Application Pages and you will be presented with the PeopleSoft Portal menu.




From here choose the ESS Home and Mailing Address component.



On this page set Services at Page level, because we only want to see the Related Content on the main page and every time you change your address the Related Content needs to be refreshed with the home address field filled in the PageActivate.
Choose Page HR_HOME_MAILING and service GOOGLEMAPSDIRECTIONWORKHOME. Click on Configure to assign the fields on the page to the service parameters.



For service parameter Home Location set Mapping Type to Page Field and click in Select. In the popup screen, choose From location from the derived record. Do the same for service parameter Work Location and set it to field To location.
Set service parameter Embed output to mapping type Fixed and enter the value embed. The screen will look like this.



See it in action

All configuration is now done.
Navigate to the Home and Mailing Address component and you will see that you now have a Related Content dropdown on the page.



When you select the Related Content HomeWorkDirection the screen splits and you will see Google Maps in the second frame.



Now let’s say we want to move closer to work and we change the home address



Click on Save and choose the Related Content and you will see the new directions to work.



In this post I have still created some customization, because the data in my component was not complete to call this service. The entire idea of Related Content is that you do not have to create any customization to make it work.
Always try to keep the number of customization to a minimum.
Viewed 3103 times by 1246 visitors

Share this:
Email
Print

inShare0

Facebook



Related posts:

Setting up predelivered Related Content services
PeopleSoft 9.1 Mobile Inventory: Create customization
environment
Create apealing Dashboards with PeopleTools 8.52
Create interactive dashboards with InterWindow Communication
(IWC)
PeopleSoft Applications Portal 9.1 Feature Pack 1

Category:
General /
Technical

Tags:
Related Content


Posted
by:
Hakan Biroglu (56 post(s)).

«
Use barcode in BI publiser as from PeopleSoft
UPK PeopleTools Reporting & Test FrameWork »

You can follow any responses to this entry through the
RSS 2.0
feed. You can skip to the end and

leave a response. Pinging is currently not allowed.

3 Responses (last comment shown first)

July 6, 2012
Balaji



I try this one peopletool 9.1…but related content menu option not there….plz help

[Reply to this comment]



Hakan Biroglu Reply:

July 6th, 2012 at 7:23 am

Please check my previous blog with the prerequisites for related content http://bloggingaboutoracleapplications.org/setting-up-predelivered-related-content-services/
[Reply to this comment]

April 19, 2012
Ikeer Savage



This is Great!!! thank you for sharing..

[Reply to this comment]
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: