Hi all,
I found one inconvenients related to business process run on other tab than default tab on page. System changing this tab automatically after process ends.
My process has one step, which open Pre-configured page and after Save/Close back to the Project page. This process is invokend on Project/Structure detail tab. Everything works perfect but system initialize Project page with default General Information tab instead of Structure tab on which process was exectuted.
How to switch tab automatically after page is initialized after business process has ended ?
Regards,
Marcin Kott
Like
Hi Marcin,
Business process can communicate with the client side via Websockets. You can send a Websocket message to the page with the name of the tab that you want to open.
Here are the steps to follow:
1. Add usings in your business process https://prnt.sc/q6gknw:
Terrasoft.Configuration
Terrasoft.Messaging.Common
Newtonsoft.Json
2. Create a method under Methods tab:
public static void SendTabName(UserConnection userConnection, Guid recordId, string tabName) { string senderName = "TabSender"; string message = JsonConvert.SerializeObject(new { RecordId = recordId, TabName = tabName }); MsgChannelUtilities.PostMessage(userConnection, senderName, message); }
3. Add process parameters RecordId and PageTabName.
4. Add a script task that invokes a method with message:
SendTabName(Get<UserConnection>("UserConnection"), Get<Guid>("RecordId"), Get<string>("PageTabName")); return true;
5. Subscribe for the message on the page:
define("MyPage", [], function() { return { entitySchemaName: "MyObject", methods: { init: function() { this.callParent(arguments); this.Terrasoft.ServerChannel.on(Terrasoft.EventName.ON_MESSAGE, this.onTabMessageReceived, this); }, destroy: function() { this.Terrasoft.ServerChannel.un(Terrasoft.EventName.ON_MESSAGE, this.onTabMessageReceived, this); this.callParent(arguments); }, onTabMessageReceived: function(sender, message) { if (message && message.Header && message.Header.Sender === "TabSender") { var result = this.Ext.decode(message.Body); if (this.get("Id") === result.RecordId) { this.glbSetActiveTab(result.TabName); } } }, glbSetActiveTab: function(tabName) { this.set("ActiveTabName", tabName); } } }; });
Regards,
Dmytro
Dmytro Smishchenko,
Thank You for complete clarification. Its works.
Not exactly fit to my case but was useful to take forward my implementation and fix problem.
In my solution, process runs "Pre-configured page" task, so "Script task" runs after this steps sends message but before load "Project edit page" back then i can't handle this message.
My final solution is setting sessionStorage variable on "Pre-configured page" init method and read and destroy this variable on "Project Page 2 edit" initTab method like this ..
methods: { initTabs: function() { //this.callParent(arguments); if(sessionStorage.getItem("SetStructureTab")) { this.set("ActiveTabName", "StructureTab"); this.set("StructureTab", true); sessionStorage.removeItem("SetStructureTab"); } else{ this.callParent(arguments); }
Regards,
Marcin Kott