Posts

Save, Delete or Commit has failed because lock "XXX" is not held

Image

This is what I do when there is a problem with the Lock. Tipically, the error message is as follows:

Save, Delete or Commit has failed because lock "XXX" is not held

Remove all Datapages programmatically

Use the following function:

@(Pega-RULES:DeclarePages).pzDeleteAllInstancesOfDeclarativePage(tools,D_MyDataPage)

That's all!

Refresh a section on client using JavaScript

Just execute the following JavaScript function:

pega.api.ui.actions.refreshSection({section: "MySection"})

Of course, we can set a parameter to run a data transform or call an activity. Keep reading!

Using the PDFBox library to embed an Image to a PDF document

I tried to embed an image into a PDF using the apache POI and iText libraries but none of them worked to me. So I tried with the pdfbox library and it worked!

Java function to create a PDF document with an embedded image

Image

In this post I will show a Java function that pastes an image into a brand new PDF. The input and output of this function will be Base64 encoded.

Why did I need it? The client requested that the images attached to the case be converted to PDF in order to be sent to a service that only accepts PDF documents.

How to call an activity from the client using the "asyncRequest" JavaScript function

Image

Here is an example where we invoke the pyUtilityStub activity using the POST method by sending GET and POST parameters at the same time:

var oSafeURL = new SafeURL("@baseclass.pyUtilityStub");
oSafeURL.put("pzPrimaryPageName", "pyWorkPage");
oSafeURL.put("parameterGet1", "valueGet1");
oSafeURL.put("parameterGet2", "valueGet2");

var postData = new SafeURL();
postData.put("parameterPost1", "valuePost1");
postData.put("parameterPost2", "valuePost2");

pega.u.d.asyncRequest("POST", oSafeURL, null, postData);

How to discard a rule from another operator

Image

Yesterday, I ruined my Dev Studio access because I private-edited an OOTB rule (pzpega_ui_invoke.js). So I needed to discard it urgently or I would lose my operator and all my work. Unfortunately I no longer had access to the Dev Studio using my operator so I needed to do it from another operator. Here's how I accomplished it.