Custom Javascript Functions in ProcessFlow

 9 Replies
 1 Subscribed to this topic
 52 Subscribed to this forum
Sort:
Author
Messages
Kyle Jorgensen
Veteran Member Send Private Message
Posts: 122
Veteran Member
What's the best way of using a file with custom javascript functions in ProcessFlow?
I know I can add to the provided "pflow.js", but I'd rather not alter delivered code.

Is there some javascript expressions I can use inside an "Assign" node so that it will read my custom functions file?
I found a few solutions using Google, but they rely on the browser's DOM...which doesn't appear available in ProcessFlow.
Woozy
Veteran Member Send Private Message
Posts: 709
Veteran Member
This is a timely question.  Last week at Inforum I chatted with some of the folks who designed the IPA/Pflow tools about this exact question.  I have always avoided modifying the pflow.js because I was afraid our functions would be wiped out by an upgrade (we are under Managed Services).

I found out that it is possible to create your own "user" Javascript library named "pflow_user.js" in the same folder as the delivered "pflow.js" file.  The designer will treat your custom file exactly like (and in parallel with) the functions in the pflow.js file.  In fact, your custom functions will also appear in the assign node "Functions" drop down list, as long as you formatted the file exactly like the pflow.js.

As a side benefit, if you create a function within your library that is named the same as one of the "delivered" functions, it will override or extend those functions.

I know this works on both the Pflow Classic 9.0.1 version and the IPA (Landmark) 9.2.x version, and perhaps earlier versions.

I hope this is helpful to you.  I know it made me very happy...

Good Luck!



Kelly Meade
J. R. Simplot Company
Boise, ID
Kyle Jorgensen
Veteran Member Send Private Message
Posts: 122
Veteran Member
Oh my gosh, that's exactly what I was hoping to find out. I can't wait to try it tomorrow.
John Henley
Send Private Message
Posts: 3351
Very interesting! Thanks for letting us know.
Thanks for using the LawsonGuru.com forums!
John
Kyle Jorgensen
Veteran Member Send Private Message
Posts: 122
Veteran Member
This works! I placed a copy of our custom pflow_user.js in my C:\Program Files\Lawson Software\ProcessFlow901\ directory and now I have access to them in the "Assign" nodes within the designer. Next test will be to place the pflow_user.js file on the Lawson server and restart the pfserver. I don't see why it won't work there. I'll keep the forum posted.
Woozy
Veteran Member Send Private Message
Posts: 709
Veteran Member
In my case (using IPA) a restart of pflow services was not required after adding the pflow_user.js file.  I think the fact that it is there makes it available immediately.
Kelly Meade
J. R. Simplot Company
Boise, ID
Kyle Jorgensen
Veteran Member Send Private Message
Posts: 122
Veteran Member
Yep, sure enough. This just keeps getting easier!! Coolest undocumented feature of ProcessFlow I've found yet.
Shane Jones
Veteran Member Send Private Message
Posts: 460
Veteran Member
great topic.... I modified the pflow.js file in the past but it was a pain everytime we patched the system. This sounds like it is a bit more forgiving than in the past. Thanks for sharing....
Shane Jones
Tools: HR, Payroll, Benefits, PFI, Smart Office, BSI, Portal and Self-Service
Systems: Lawson, Open Hire, Kronos, Crystal Reporting, SumTotal Learning
** Teach others to fish...
Terry P
Veteran Member Send Private Message
Posts: 234
Veteran Member
Ok - so is there a similar way to do this for Design Studio Javascript Functions? I have several functions that I use over and over (like converting to proper case) etc etc. I came across another one that works great, but I couldn't get it to work within Design Studio script.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

String.prototype.toTitleCase = function () {
var smallWords = /^(a|an|and|as|at|but|by|en|for|if|in|of|on|or|the|to|vs?\.?|via)$/i;

return this.replace(/([^\W_]+[^\s-]*) */g, function (match, p1, index, title) {
if (index > 0 && index + p1.length !== title.length &&
p1.search(smallWords) > -1 && title.charAt(index - 2) !== ":" &&
title.charAt(index - 1).search(/[^\s-]/) < 0) {
return match.toLowerCase();
}

if (p1.substr(1).search(/[A-Z]|\../) > -1) {
return match;
}

return match.charAt(0).toUpperCase() + match.substr(1);
});
};
George Graham
Veteran Member Send Private Message
Posts: 201
Veteran Member
Terry - know this is a little late in replying but in Design Studio there is an include function in the file menu. This allows you to "include" any file that contains javascript functions and routines as part of your DS form. You can keep different files for different purposes and include only what you need on a form by form basis.