Thursday, June 09, 2005

 

Linking to pages directly in CRM 8.9

Ok, so I will start with an easy topic for my first article.

There was a user requirement to notify a user with an e-mail which includes a direct link to a page in a component in CRM 8.9. The problem is, PeopleSoft doesn't come with built-in query string parameters for all delivered components. And no matter what page in a component you navigate to, you only see the component name in the URL.
So, to get a user to click a link in an e-mail to go directly to a page, you have to write some code in SearchInit PeopleCode. You can use the primary record on your page for this. You can add this on either the record Peoplecode or the Component Record Peoplecode, although I prefer to use the Component Record PeopleCode because it makes more sense, since it relates to the search page of a component.
The IScript %Request class is what we can use to grab the query string parameters. There are a couple of methods PeopleSoft provides, but I've only been able to get one of them to work.
The GetParameter method theoretically returns the value of a query string parameter you pass to it, but I have not been able to get it to work. It always returns blank.
The one that actually works is the QueryString parameter. It returns the querystring that is attached to the URL plus a whole lot of PeopleSoft-generated "junk" on the end. So to get your querystring parameters, you have to then parse the string returned to isolate your parametes.
Once you get the value of your parameter parsed, you can set the key fields of your component equal to the query string parameters, and then tell PeopleSoft to skip the search page if it has all the keys it needs to go directly to a page.

For this example, my record has a primary key of PROCESS_INSTANCE, and that is the querystring parameter I'm going to use. The URL I'm using is:

http://server:port/psp/database/EMPLOYEE/CRM/c/MENU.COMPONENT.MKT?PROCESS_INSTANCE=10

Example Code:

MyComponent.MyRecord.SearchInit

Local string &querystr;

&querystr = %Request.QueryString;

If Find("PROCESS_INSTANCE", &querystr, 1) > 0 Then
&endposn = Find("&", &querystr, 1);

¶m = Substring(&querystr, 1, &endposn - 1);

&value = Find("=", &param, 1);

&process = Substring(&param, &value + 1, Len(&param) - &value);

If &process <> "" Then
CG_LAUNCH_TBL.PROCESS_INSTANCE = &process;
SetSearchDialogBehavior(0);
End-If;
End-If;

Line by line explanation:

&querystr = %Request.QueryString;

This line returns the querystring. An example of what this looks like is:

PROCESS_INSTANCE=10&FolderPath=PORTAL_ROOT_OBJECT.FOLDER_NAME.COMPONENT_NAME
&IsFolder=false&IgnoreParamTempl=FolderPath,IsFolder
&PortalActualURL=http%3a%2f%2fServerName%3a81%2fpsc%2fDbname%2fEMPLOYEE%2fCRM%2fc%2fMENU.COMPONENT.GBL
...

Notice that the custom querystring parameter appears at the beginning of the QueryString property returned.

If Find("PROCESS_INSTANCE", &querystr, 1) > 0 Then

Searches for the query string parameter. We only want to parse it if our custom parameter is in the URL. Otherwise we just want the search page to come up as normal.

&endposn = Find("&", &querystr, 1); // find the beginning of the parameter after ours
¶m = Substring(&querystr, 1, &endposn - 1); // get our parameter
&value = Find("=", &param, 1); // find the position of the = sign in our parameter
&process = Substring(&param, &value + 1, Len(&param) - &value);
// get the value of the parameter starting from the position after the equals sign for a length of the whole parameter minus the length of the paramter up to the equals sign


Parses the value of the querystring parameter. This code will only work for 1 parameter since it assumes the custom parameter is the first one. If you have more than 1, you'll need to modify this.

If &process <> "" Then
CG_LAUNCH_TBL.PROCESS_INSTANCE = &process;
SetSearchDialogBehavior(0);
End-If;

If there is a value found, then it sets the Key field of the search record to that value, and calls
SetSearchDialogBehaviour with a value of zero to tell PeopleSoft to bypass the search page.

And that's it. That's all the coding required.

When you test this, if you aren't logged into PeopleSoft, it will prompt you to log in first, and then it will navigate to your page.

Hope you find this useful, comments are welcome.

Friday, June 03, 2005

 

First posting - Welcome

Welcome to PeopleSoft Development Tips, a place where I will be posting articles on PeopleSoft development that I have done as part of my job. I work for IBM Business Consulting Services in Canada. Any opinions in this blog are my own personal opinions and do not represent the opinions or practices of IBM. Any articles I might post will not have any client-specific information, they will be generic to any PeopleSoft installation.
If there are any topics you would like me to write about, please email me and let me know. I plan on doing articles on PeopleSoft workflow, CRM workflow, how to launch a Windows application from a PeopleSoft web page, insights on how to customize PeopleSoft CRM 8.9, and more. I basically will write articles on topics I am working at on my current project, whatever that happens to be at the time.
My first article is going to be on how to set up a simple PeopleSoft workflow. Stay tuned.

This page is powered by Blogger. Isn't yours?