How to Refresh a Page from a Process in Creatio (formerly bpm’online)

In this article I will tell you how to refresh a page from a process in Creatio. It’s pretty common for a process to run on a signal from a record being saved. That process might update fields that you want the user to see right away. To do that you’ll need to refresh the page once the process is complete. From our process we will send a message and then listen for that message on the page. Whenever we get that message it will refresh the page and the user will see any changes right away.

For this example when a contact is saved I need to go get some values from the contact’s account and then put those values in fields on the contact. For this to work I need to refresh the page once the process is done. Without this, the user won’t see the new values until they reopen the contact.

I’ll add a script task as the last task in my process. I’ll add code to this script task that will send a message back to my page.

The code I’ll add to that script task is this

Terrasoft.Configuration.MsgChannelUtilities.PostMessageToAll("FXRefreshContactPage", "");
return true;

When this code calls PostMessageToAll it gives a name of our message. In this case it’s FXRefreshContactPage. You want the name of your message to be unique. This part sends the message, now we have to go edit the page to receive it. Once you start editing the page you’ll want to put in some code that allows the page to receive the message. This is the code that I put in the page.

init: function() {
	this.callParent(arguments);
	// register our onProcessMessageReceived function to get messages from the server
	Terrasoft.ServerChannel.on(Terrasoft.EventName.ON_MESSAGE, this.onProcessMessageReceived, this);
},
onProcessMessageReceived: function(scope, message) {
	var sender = message && message.Header.Sender;
	if (sender === "FXRefreshContactPage") {
		this.reloadEntity();
	}
},
destroy: function() {
	// un-register the function when the page is destroyed so it stops receiving messages
	Terrasoft.ServerChannel.un(Terrasoft.EventName.ON_MESSAGE, this.onProcessMessageReceived, this);
	this.callParent(arguments);
}

First we register to get messages from the server in the init, later, in the page destroy, we’ll unregister the function. When a message is received it will call our function named onProcessMessageReceived (we could name this whatever we want). This code will receive all messages so we have to check that it’s the message that we sent from our process. Once we get our message we call reload entity which reloads all the data on the page. Now the user will be able to see right away any changes that you’ve made to the record in the process.

1 Comment

  1. Thank you so much for this write up. This helps me greatly in improving user experience.

    Reply

Leave a Reply to Reid Burger Cancel reply

Your email address will not be published. Required fields are marked *

Subscribe To Our Newsletter

Join our mailing list to receive the latest Infor CRM (Saleslogix) and Creatio (bpm'online) news and product updates!

You have Successfully Subscribed!