Last active
July 11, 2022 13:36
-
-
Save bokks/5713e28cbb752248869039611dc219ef to your computer and use it in GitHub Desktop.
This patterns gives tips on using SafeURL with encryption in Stream Rules . Also when you should use Thread vs Requestor.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Note that this is for Stream rules */ | |
/* Below snippet is a JS function in a control performing a server call */ | |
/* Important Tip | |
Use encryption when you already have code using : | |
httpRequestAsync | |
pega.util.Connect.asyncRequest | |
openWorkByURL | |
openURLInWindow | |
*/ | |
<script> | |
function bulkProcess(ListName, flowAction, id,classname, skipActionCheck) | |
{ | |
if (classname == null || classname == "All Classes" ) | |
classname = ""; | |
var encodedID = encodeURIComponent(id); | |
var oSafeURL = new SafeURL(); | |
oSafeURL.put('pyActivity', "Assign-.BulkProcessAssignments" ); | |
oSafeURL.put('ListName', ListName); | |
oSafeURL.put('TaskStatus', flowAction ); | |
oSafeURL.put('ID', encodedID); | |
oSafeURL.put('moreBulkProcessing', "false"); | |
oSafeURL.put('ClassName', classname); | |
oSafeURL.put('skipActionCheck',skipActionCheck); | |
openWorkByURL(oSafeURL); | |
} | |
/* The solution is you can encrypt the url string pyActivity=XXX and pass the encrypted string to SafeURL */ | |
function bulkProcess(ListName, flowAction, id,classname, skipActionCheck) | |
{ | |
if (classname == null || classname == "All Classes" ) | |
classname = ""; | |
var encodedID = encodeURIComponent(id); | |
/* Note how we are using Requestor , as second argument . OpenWorkByURL action is a cross thread action */ | |
var oSafeURL = new SafeURL("<%=pega_rules_utilities.pzEncryptURLActionString(tools, "Requestor","pyActivity=Assign-.BulkProcessAssignments")%>"); | |
oSafeURL.put('ListName', ListName); | |
oSafeURL.put('TaskStatus', flowAction ); | |
oSafeURL.put('ID', encodedID); | |
oSafeURL.put('moreBulkProcessing', "false"); | |
oSafeURL.put('ClassName', classname); | |
oSafeURL.put('skipActionCheck',skipActionCheck); | |
openWorkByURL(oSafeURL); | |
} | |
/* You can also use SafeURL_createFromURL with encrypted URL as argument */ | |
var oSafeURL = SafeURL_createFromURL("<%=pega_rules_utilities.pzEncryptURLActionString(tools, "Requestor","pyActivity=Assign-.BulkProcessAssignments")%>"); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment