Run a business process from an action on page

Hi everyone, 

I'm running on bpm'online last version 7.12.0

I've added a few actions to my sections and pages. Let's take "Order" for instance.

I could bind a business process to those added on section. For example, for a BP called "customProcess", here's the code in OrderSectionV2

 

	oneSelected: function() {
				var selectedRows = this.get("SelectedRows");
				return selectedRows ? (selectedRows.length == 1) : false;
			},
 
customProcessAction: function() {
				//Call Business Process
				var selectedOrder = this.get("SelectedRows").toString();
				var args = {
					sysProcessName: "customProcess",
					parameters: {
						OrderId: selectedOrder
					}
				};
				// Running business process.
				ProcessModuleUtilities.executeProcess(args);
			},
 
getSectionActions: function() {
				var actionMenuItems = this.callParent(arguments);
				actionMenuItems.addItem(this.getButtonMenuItem({
					Type: "Terrasoft.MenuSeparator",
					Caption: ""
				}));
				actionMenuItems.addItem(this.getButtonMenuItem({ 
					"Caption": {bindTo: "Resources.Strings.customProcessCaption"},
					"Click": {bindTo: "customProcessAction"},
					"Enabled": {bindTo: "oneSelected"}
				}));
				return actionMenuItems;
			}

By applying the same logic on OrderPageV2, it's not working. The action appears but it doesn't do anything when clicking on it.

I hope you'll be able to help me.

Thank you, best regards. 

 

Like 0

Like

2 comments

Please take a course by the link below and debug the code.

https://developers.google.com/web/tools/chrome-devtools/javascript/

Then put breakpoints into the selected places and find the value that you missed.

http://prntscr.com/jdqezc

Additionally, please investigate the code below

var selectedOrder = this.get("SelectedRows").toString();

Where from you expect to get the SelectedRows value on the page? If  you were in a section, the SelectedRows would contain the rows that were selected in the section. But if you are on a page, what the SelectedRows variable should contain?

Probably you need to pass an Id of the page record instead of the SelectedRows. 

Additionally, please investigate the place where you expect to see the menu action. If you need to see it on a section or on a page when a section is open on a left side, then you need to place the script in a section module (for example OpportunitySectionV2). If you need to see the menu action on a page, then you need to place the script in a page module. If you need to see it everywhere, then you probably need to place the script both in a section module and in a page module. But the logic should be different. 

 

 

 

Thank you for your quick answer.

Eugene Podkovka writes:

Where from you expect to get the SelectedRows value on the page? If  you were in a section, the SelectedRows would contain the rows that were selected in the section. But if you are on a page, what the SelectedRows variable should contain?

The code is for a section indeed and was just an example.

 

Eugene Podkovka writes:

Additionally, please investigate the place where you expect to see the menu action. If you need to see it on a section or on a page when a section is open on a left side, then you need to place the script in a section module (for example OpportunitySectionV2). If you need to see the menu action on a page, then you need to place the script in a page module. If you need to see it everywhere, then you probably need to place the script both in a section module and in a page module. But the logic should be different. 

Yes I figured that was the issue here. I do need to see it everywhere ! 

I'll try to make it work and ask for your help again if I have issues. Thank you very much.

Show all comments