Hi community,

 

I read the article (https://community.creatio.com/questions/add-action-detail) in Creatio community and added a button in the action menu of our order product detail.

But the visibility seems not working. May you help me to adjust the code below? What I

need is to show the button when some detail records are selected, and hide the button otherwise.

 

                     addToolsButtonMenuItems: function(toolsButtonMenu) {

                             this.callParent(arguments);

                             toolsButtonMenu.addItem(this.getButtonMenuSeparator());

                             toolsButtonMenu.addItem(this.getButtonMenuItem({

                               Caption: this.get("Resources.Strings.UsrBtnBatchUpdate"),

                               Click: {"bindTo": "OnButonClick"},

                               Visible: {"bindTo": "IsSelectRecord"}

                             }));

                     },

 

Thanks a lot!

Like 0

Like

2 comments
Best reply

Hi Andrew,

 

Please use the following approach:

methods: {
				addToolsButtonMenuItems: function(toolsButtonMenu) {
					this.callParent(arguments);
					toolsButtonMenu.addItem(this.getButtonMenuSeparator());
					toolsButtonMenu.addItem(this.getButtonMenuItem({
						Caption: {"bindTo": "Resources.Strings.CustomButton"},
						Click: {"bindTo": "onButonClick"},
						Visible: {"bindTo": "getCustomButtonVisible"},
					}));
				},
				getCustomButtonVisible: function() {
					return this.isSingleSelected();
				},
				onButonClick: function() {
					console.log("Clicked!");
				}
			},

there is no IsSelectRecord base attribute that will make the button visible or invisible, thus there are basic methods to make "Edit" or "Copy" buttons enabled\disabled so I've used the logic behind them as an example to make the custom button visible.

Hi Andrew,

 

Please use the following approach:

methods: {
				addToolsButtonMenuItems: function(toolsButtonMenu) {
					this.callParent(arguments);
					toolsButtonMenu.addItem(this.getButtonMenuSeparator());
					toolsButtonMenu.addItem(this.getButtonMenuItem({
						Caption: {"bindTo": "Resources.Strings.CustomButton"},
						Click: {"bindTo": "onButonClick"},
						Visible: {"bindTo": "getCustomButtonVisible"},
					}));
				},
				getCustomButtonVisible: function() {
					return this.isSingleSelected();
				},
				onButonClick: function() {
					console.log("Clicked!");
				}
			},

there is no IsSelectRecord base attribute that will make the button visible or invisible, thus there are basic methods to make "Edit" or "Copy" buttons enabled\disabled so I've used the logic behind them as an example to make the custom button visible.

Oleg Drobina,

Thank you for your guid!. It works for a single detail record selected, like the behavior of "Edit" or "Copy".

What I want is the like the behavior of "Delete", and I found the solution in the academy.

In summary, I just adjusted the code below to approach the behavior like "Delete" action.

 

getCustomButtonVisible: function() {

    var selectedRows = this.get("SelectedRows");

    return selectedRows ? (selectedRows.length > 0) : false;

},

 

Thank you!

Show all comments

The Cast function in select class is not working, second parameter 'DBDataValueType' gets error as 'Error   CS1503   Argument 2: cannot convert from 'System.Guid' to 'Terrasoft.Core.DBDataValueType'   Terrasoft.Configuration.Dev'.

 

var SelQuery = new Select(UserConnection)
.Column(Func.Cast("UsrName", DBDataValueType.TextDataValueTypeUId)).As("UsrName")
.From("UsrTableName") as Select;
 
var SelRecord = SelQuery.ExecuteScalar<string>();

 

Like 0

Like

2 comments

Hi there, 

 

It seems that the error may be hidden in this line: 

.Column(Func.Cast("UsrName", DBDataValueType.TextDataValueTypeUId))

 

Please try to use the code below as an example: 

var textDataValueType = new TextDataValueType(new DataValueTypeManager()) {
   Name = "Text"
};
var SelQuery = new Select(UserConnection)
   .Column(Func.Cast("Name", textDataValueType)).As("Name")
   .From("Contact") as Select;
var SelRecord = SelQuery.ExecuteScalar&lt;string&gt;();

 

Regards,

Anastasiia

Anastasiia Markina,

 

Thanks for code, Now its working.

Show all comments