Skip to content

Instantly share code, notes, and snippets.

@bokks
Last active January 6, 2021 20:35
Show Gist options
  • Save bokks/0d25a37d51c7ddeadb664c5f94b304d1 to your computer and use it in GitHub Desktop.
Save bokks/0d25a37d51c7ddeadb664c5f94b304d1 to your computer and use it in GitHub Desktop.
This pattern shows how to easily perform Activity registration using pzRegisterActivity
/* This shows how to convert a regular SafeURL to a Dispatcher URL */
/* The normal URL would be like pyActivity=Work-.AttachmentStatus&AttachmentHandle=XXX */
/* When you pass the SafeURL to pega.u.d.convertToRunActivityAction(oSafeURL) , the URL becomes a dispatcher */
/* pyActivity=pzRunActionWrapper&pzActivity=Work-.AttachmentStatus&AttachmentHandle=XXX&pzActivityParams=AttachmentHandle */
/* pzRegisterActivity or long form of registration works only with such Dispatcher URLs */
<script>
function CheckAttachmentStatus(LinkHandle,strAttachmentHandle)
{
var oSafeURL= new SafeURL("Work-.AttachmentStatus",getReqURI());
linkHandle = LinkHandle;
attachHandle = strAttachmentHandle;
oSafeURL.put("AttachmentHandle",strAttachmentHandle);
var callback ={ success:deleteAttachment,
argument: [LinkHandle, strAttachmentHandle]
};
pega.util.Connect.asyncRequest('GET', oSafeURL.toURL(),callback);
}
</script>
/* Solution by Registration */
/* Important Note -- You donot need to call the convertToRunActivityAction API - if you are using the
standard api pega.u.d.asyncRequest or pega.api.ui.actions.runActivity apis. The conversion to Dispatcher URL is handled */
<script>
function CheckAttachmentStatus(LinkHandle,strAttachmentHandle)
{
var oSafeURL= new SafeURL("Work-.AttachmentStatus",getReqURI());
linkHandle = LinkHandle;
attachHandle = strAttachmentHandle;
oSafeURL.put("AttachmentHandle",strAttachmentHandle);
var callback ={ success:deleteAttachment,
argument: [LinkHandle, strAttachmentHandle]
};
pega.u.d.convertToRunActivityAction(oSafeURL); // This is the API for SafeURL transformation
pega.util.Connect.asyncRequest('GET', oSafeURL.toURL(),callback);
}
<% pega_rules_utilities.pzRegisterActivity(tools,"Work-.AttachmentStatus"); %>
/* Simple API to Register Activity */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment