Categories
CRM Hints and Tips Peoplecode Peoplesoft

Display Template Debugging in PeopleSoft CRM

A quick tip – if you want lots of debugging feedback in CRM Display Template rendering, just create a userid CSPEER (Chris Speer) and use that. Chris Speer wrote a lot (all?) of the Application Package code for Display Templates and handily left debugging (messagebox) code in place that only happens when the current logged on user is CSPEER.

Useful to know.

Note: You will need to hack the filename the debug output goes to – it still refers to a UNC path of a machine at PeopleSoft.

Of course, if you don’t want to edit the code at all you could:

  • Create a NetBIOS alias called “sclappp532” on the application server through a Windows registry entry.In HKLM\SYSTEM\CurrentControlSet\services\LanmanServer\Parameters, just add a string value called OptionalNames with a value “sclapps532”. Personally, I would also create a matching DNS CNAME entry for completeness.
  • As the PeopleCode filename refers to a share name CR900DVL_LOGS you will also need to create that.
Categories
Hints and Tips Peoplecode

HashTables in PeopleCode

I came across this implementation of a hashtable in PeopleCode that uses the java API:

Implementing a HashTable in PeopleCode

But it is worth noting that there is another PeopleCode only implementation already delivered in PeopleTools:

EOEW_ETLAPI:COMMON:HashTable.

Categories
Hints and Tips Java Peoplecode

Ceil/Ceiling function in PeopleCode

I just used the java Math library ceil function from PeopleCode to solve the “round to nearest 0.5” problem e.g.

1
2
3
4
5
6
7
8
9
10
11
Local JavaObject &mathclass;
Local number &number_to_round, &result;
 
/* Instantiate java Math class */
&mathclass = GetJavaClass("java.lang.Math");
 
For &number_to_round = 0.1 To 2.0 Step 0.1
/* Use ceil function from java to solve problem */
&result = &mathclass.ceil(&number_to_round * 2) / 2;
MessageBox(0, "", 0, 0, "Number to Round: " | &number_to_round | " Result: " | &result);
End-For;
Categories
App Engine Hints and Tips Peoplecode Peoplesoft PeopleTools Performance Tuning

Jackson Structured Programming (JSP) – Read Ahead and PeopleCode

Jackson Structured Programming – now that brings back memories of my COBOL training at British Telecom in the late 1980’s.

What prompted this short post was a dreadful piece of hand-crafted PeopleCode to load a CSV file using a file layout. The usual “Operand of . is null” occurred unless the input file contained a “blank line” at the end.

The underlying reason for this was a failure to apply one of the fundamental techniques in JSP – the single read-ahead rule:

Single Read-ahead rule: Place the initial read immediately after opening the file, prior to any code that uses the data; place subsequent reads in the code that processes the data, immediately after the data has been processed.

In fact, this approach is exactly what you get when you drag a file layout into a PeopleCode step in Application Engine – sample code that uses the JSP single read-ahead rule.

Categories
Peoplecode Peoplesoft PeopleTools

PeopleCode Techniques 1

Here is some sample code RowInit PeopleCode:

Declare Function BuildHTMLString PeopleCode MY_FUNCLIB.MY_FIELD FieldFormula;

BuildHTMLString(GetField(WORK_RECORD.MY_TEXTFIELD), …. some other parameters);

The underlying Function is defined as you might expect:

 

BuildHTMLString

On the surface there is not a lot wrong with this code but it contains a technique that can hurt performance – passing around and using object references when you really don’t need to. This technique comes from the OO programming world and is absolutely valid but all this function is doing is building a string value. Changing the code so the Function RETURNS a string and using simple assignment in the RowInit logic is another option:

BuildHTMLStringReturnString

But is this really faster? And by how much? In my benchmarking of 10000 rows, the first version took some 14 seconds elapsed time to populate. The string assignment version took under 2 seconds. Now this was on a laptop of limited resources, but I think this illustrates a valid point – think about the cost of passing objects around and consider the impact on performance in medium to high volume situations. Anything that releases the app server to do other work quicker is good in my view.

Of course building the string in the underlying SQL is an even better option from a performance perspective – but only if all of the logic in the function can be coded in SQL. Sometimes that just isn’t feasible and PeopleCode is the best way to go.

Categories
Peoplecode Peoplesoft PeopleTools SQL

RowInit PeopleCode vs Database Logic

Sometimes you need to do processing logic in RowInit PeopleCode that looks as though it is pretty harmless. But is it? Is RowInit always the correct place to do that logic?

Personally, I would nearly always recommend using RowInit PeopleCode as it is the “Peoplesoft Way” and PeopleSoft developers and functional consultants are more familiar with it. It is also generally easier to maintain and is database agnostic. But there are certain design patterns where I would consider moving logic to the database. Here is one such example:¬†

Categories
Peoplecode PeopleTools

Sortable Image Column in PeopleTools Grid

A quick tip if you want to allow users to sort on an Image column in a PeopleTools grid. Typically this is used in RAG (Red Amber Green) type traffic light images for KPI/target values. The tip is simple but effective:

Don’t use an Image column type – use an HTMLAREA and embed a hidden value into a HTML comment in the column followed by a link to the image you want to display.

Given a HTML area linked to RECORD.MY_FIELD on the grid, use RowInit PeopleCode to construct the HTML like this:

RECORD.MY_FIELD.Value = '<!--' | {the_value_to_sort_on} | '-->' | "<img src='%Image(MY_IMAGE)'>";

where the “value to sort on” could be a literal or a RECORD.FIELD.Value reference or indeed any calculated value. Just make sure the values you assign reflect the collating sequence you want for the images.

Oh … you might want to centre the image in the column using a DIV

<div style=”text-align: center;”>

… the img tag above

</div>

Enjoy.

Categories
CRM Peoplecode Peoplesoft PeopleTools

PeopleSoft CRM 9.1 Case Corruption from My Cases Pagelet

There is a nasty bug in PeopleSoft CRM 9.1 that can lead to case data being overwritten by data from another case.

Just open two different cases from the My Cases pagelet. Each opens in a new window but they have identical URLs apart from the CASE_ID. The effect of this is that changes made to one case result in the component globals such as CASE_ID being overwritten on the second tab. If that tab is then saved, then incorrect data is written back to the database. Insidious little bug.

Categories
App Engine Peoplecode Peoplesoft

Where you do CreateRowset does matter …..

In Peoplecode, it is common to see this construct:

1
Local Rowset &rs = CreateRowset(Record.RECNAME);

Often, this construct is used within a loop. But this is not a “free” statement – it goes to the database:

1
SELECT {column_list} FROM {tab_name} WHERE 1=2

Which, on SQL server would get wrapped in a SET FMTONLY ON / SET FMTONLY OFF statement pair in order to get the column META-DATA (describe output).

But if you use the above construct inside a loop, then there will be “n” executions of the above SQL – so “n” database round trips too. This is not free and will impact your performance.

Better to define the rowset at the component level and re-use inside the loop.

PS: The same applies to CreateRecord(Record.RECNAME). Think about where you place these statements in your code – especially in App Engine code where you are likely to be looping through rows..