jump to navigation

Outputing ALL images from PS July 12, 2007

Posted by Duncan in PeopleSoft, PeopleTools, PIA, SQL.
trackback

I was asked an unusual question yesterday and I thought I’d share it with you all.

The client wanted to view/extract all of the images held within PeopleSoft. My first reaction was that it couldn’t be done. As there are over 1000 images it’s not a task to be easily done manually. Also, only about 1/4 of the images are stored in the Web Server cache, so it’s not a task of just getting them from there.

So … how was it done?

All images page in PIA

The answer was to create a custom page with an HTML area on it, pointing to a record with a long field on. Then, in Page Activate PeopleCode, loop through all of the image names in the database appending and prepending with HTML and MetaHTML. Concatenate them all together and assign the resulting string to the Long field behind the HTML Area. Et Voila!

This is the Page Activate PeopleCode:

Local SQL &SQLGetImages;
Local string &ImageHTML, &ImageName;
&SQLGetImages = GetSQL(SQL.DMD_IMAGES);
While &SQLGetImages.Fetch(&ImageName)
&ImageHTML = &ImageHTML | "<img src='%Image(" | &ImageName | ")'/> " | &ImageName | "<BR />";
End-While;
DMD_HTML_AREA.HTMLAREA = &ImageHTML;
&SQLGetImages.Close();

and this is the SQL in the SQL Object:

SELECT CONTNAME
FROM PSCONTDEFN C
WHERE C.ALTCONTNUM = (SELECT MAX(C1.ALTCONTNUM)
FROM PSCONTDEFN C1
WHERE C1.CONTNAME = C.CONTNAME
AND C1.CONTFMT <> ' ')
AND C.CONTFMT = (
SELECT MAX(C1.CONTFMT)
FROM PSCONTDEFN C1
WHERE C1.CONTNAME = C.CONTNAME
AND C1.ALTCONTNUM = C.ALTCONTNUM
AND C1.CONTFMT <> ' ')

As an added bonus, all of the images will be available in the Web Server cache if you need the actual files.

I guess it’s not the sort of thing you get asked for every day, but you never know when you might need it …

Advertisements

Comments

1. Derek - July 12, 2007

Wouldn’t get asked everyday, but I can definitely see where this would come in handy. Thanks for the tip!

2. Sachin - July 18, 2007

Great tip!

3. Alagiri Ruban - August 6, 2007

This really a good tip

4. Ajay - November 26, 2007

excellent…

5. Cool - April 1, 2008

Very usefull tip!!!

6. Giri - September 24, 2008

Good one!

7. Ryan - September 18, 2009

Glad I found your page, I was trying to see what images PS provides. Thanks so much

8. Richard - October 16, 2009

Thanks. Our team has found this a very useful development tool for searching for an appropriate image, and I have just made this a permanent component in our development environment.

9. Neil Yetman - August 3, 2011

Hi Duncan, I thought I would show you how I have updated the code in your post to turn it into an IScript. The benefit is it is much quicker to create. There is no need to create a component and page. I’ve even taken the SQL and put it directly into the PeopleCode so you can lose the SQL Definition. For me I created a WEBLIB_NY record, with one field (ISCRIPT) and copied the function below into the FieldFormula PeopleCode. Then the URL to get to it is http://some.web.server/psp/DB_NAME/EMPLOYEE/HRMS/s/WEBLIB_NY.ISCRIPT1.FieldFormula.IScript_Images.

Note: Depending on the roles your User ID is assigned, you may need to add this IScript to a permission list in order to access it.

Function IScript_Images
Local SQL &SQLGetImages;
Local string &ImageHTML, &ImageName;

&SQLGetImages = CreateSQL(“SELECT CONTNAME FROM PSCONTDEFN C WHERE C.ALTCONTNUM = (SELECT MAX(C1.ALTCONTNUM) FROM PSCONTDEFN C1 WHERE C1.CONTNAME = C.CONTNAME AND C1.CONTFMT ‘ ‘) AND C.CONTFMT = ( SELECT MAX(C1.CONTFMT) FROM PSCONTDEFN C1 WHERE C1.CONTNAME = C.CONTNAME AND C1.ALTCONTNUM = C.ALTCONTNUM AND C1.CONTFMT ‘ ‘)”);
While &SQLGetImages.Fetch(&ImageName)
%Response.WriteLine(” ” | &ImageName | “”);
End-While;
&SQLGetImages.Close();

End-Function;

Tipster - August 7, 2011

Interesting, and thanks for sharing it.

I’ve actually taken this in the opposite direction and turned it into more of a page 🙂

I’ve now added some fields to filter the results to reduce the amount of data transfer required. I’ve grouped them by small/medium/large and navigation collection (32×32).

10. Prashant - October 17, 2011

Hi Duncan,

Really nice to see this!!!

Request if you could share some details around the page modifications that you have done based on size.

Thank You!

Cheers
Prashant


Sorry comments are closed for this entry

%d bloggers like this: