Question

Refresh page fields after process runs from update signal

I have a section with a detail on it. When I save the detail a business process runs which is triggered from the record inserted/modified signals. This process modifies data on the parent section. Everything is working correctly, however, I don't see the changes on the parent record unless I refresh the screen.

Is there some way to force the parent record to refresh once the detail record is saved so the user sees the updated fields automatically?

(I have tried unchecking the "run process in background" option on the process, made no difference)

I am also open to other ways to accomplish this if using a process to update the parent from the detail isn't the best route.

Thanks.

Like 1

Like

6 comments

you can send message at the end of process. Approximate script:

 

string sender = "RefreshDataAfterMyProcess";
string messageText = "Success"
MsgChannelUtilities.PostMessageToAll(sender, messageText);

And then subsribe to this message at the page and refresh data when page receives this message. 

Vladimir Sokolov,

Thank you Vladimir. This sounds like exactly what I needed, however I never do seem to get the message when subscribing to it on the page.

I did solve it another way, by overriding the onSaved on the detail page and send the message from there (and moved the process to the object events so it executes synchronously instead of triggering on a signal). I am able to solve my issue this way. 

Not sure why I was unable to get the message sent via PostMessageToAll, I would like to get that figured out. I tried subscribing as both BROADCAST & PTP and also with and without tags.

Thanks again.

Dear Ryan,

Please try using the send message approach offered by Vladimir and here is an example of subscription to such message on the contact section schema where "MyMessage" is a name of sent message from business process:

define("ContactSectionV2", ["ContactSectionV2Resources"],
	function(resources) {
		return {
			entitySchemaName: "Contact",
			diff: [],
			methods: {
				init: function() {
					this.callParent(arguments);
					this.subscriptionFunction();
				},
				subscriptionFunction: function() {
					Terrasoft.ServerChannel.on(Terrasoft.EventName.ON_MESSAGE,
					this.onMyProcessMessage, this);
				},
 
				onMyProcessMessage: function(scope, message) {
					if (!message || message.Header.Sender !== "MyProcess") {
						return;
					}
					var message2 = message.Body;
					if (!this.Ext.isEmpty(message2)) {
						this.Terrasoft.showInformation(message2);
					}
				}
			}
		};
	});

Hope you will find it helpful!

Regards,

Anastasia

Anastasia Botezat,

Thanks for this. That was just what I needed.

Ryan

Hi all, In my Script Task i put MsgChannelUtilities as Vladimir said, on compile i got an error :  The name MsgChannelUtilities does not exist in the current context

Dear Maxime,

In order to fix the issue you need to indicate needed namespace, which contains MsgChannelUtilities class. Please add "Terrasoft.Configuration" to the usings of the business process.

Regards,

Anastasia

Show all comments