Hello, community!

This is a selection window for my lookup. Lets take this example, I should not be able to select collaterals that have remaining allocation 0. My problem is that this field is being populated by a process, and the regular lookup filtration does not work. Is there any way to make that select button throw an error/ not let the user save their pick? As in, if remaining allocation equals 0 => select button will do nothing.

Like 0

Like

1 comments

Hello Maria,

Modifying this module window is quite a hard task to do. I believe is your case attribute filter will work just fine:

attributes: {
			"{Your lookup column Name}": {
                "dataValueType": Terrasoft.DataValueType.LOOKUP,
                "lookupListConfig": {
                    "filters": [
                        function() {
                            var filterGroup = Ext.create("Terrasoft.FilterGroup");
                            filterGroup.add("IsNotNull",
                                Terrasoft.createColumnFilterWithParameter(
                                    Terrasoft.ComparisonType.GREATER,
                                    "[{Your lookup column Name}:Id].RemainingAllocation", 0));
                            return filterGroup;
                        }
                    ]
                }
            }
		},

With these records where the remaining allocation is 0 will not be displayed.

Show all comments

Hello,

 

I am willing to change publish button caption. any ideas how can we do this? I tried to override the module but in vain.

 

Like 0

Like

1 comments

Hello,

If you want to change the caption of the publish button then you need to create a replacing schema of BaseMessagePublisherPage and in it change the value of the PublishButtonCaption localizable string

 

Show all comments

Hello,



I would like create multiple buttons that call a business process. Due to the number of buttons in my page, I would like to create a single button click method. This method would receive a parameter that would tell it which button was called. The parameter would then determine which field would be read.



My button method should look something like this:

 onButtonClick: function(clickedButton){
				var recordId = this.get("Id");
                var readField = "Error"; //This value should change later, will show error otherwise
 
                switch(clickedButton){
                    case "Button1":
                        readField = this.get("Field1");
                        break;
                    case "Button2":
                        readField = this.get("Field2");
                        break;
                    /*More Cases
                    .
                    .
                    .
                    */
                   default:
                    console.log(readField);
                    break;
                }
 
                var config = {
                    sysProcessName: "UsrBpToCall",
                	parameters: {
						CurrentRecordId: recordId,
						ReadField: readField,
 
					}
				};
                ProcessModuleUtilities.executeProcess(config);
}

I assume the parameter would appear in the diff section, but I do not know how to implement this functionality.



I appreciate your help!

 

Kind Regards,

Firas



 

Like 1

Like

3 comments
Best reply

Hello Firas,

If you add a tag to each button it will get passed as the fourth parameter to the click handler. 

For example:

{
	"operation": "insert",
	"parentName": "Detail",
	"propertyName": "tools",
	"name": "MyButton1",
	"values": {
		"itemType": Terrasoft.ViewItemType.BUTTON,
		"caption": "Send selected invoice",
		"click": {"bindTo": "onMyButtonClick"},
		"tag": "MyButton1"
	}
}

Then you can retrieve the tag in the click function handler like this: 

onMyButtonClick: function(p1, p2, p3, tag) {
    console.log(tag);
}

Ryan

Hello Firas,

If you add a tag to each button it will get passed as the fourth parameter to the click handler. 

For example:

{
	"operation": "insert",
	"parentName": "Detail",
	"propertyName": "tools",
	"name": "MyButton1",
	"values": {
		"itemType": Terrasoft.ViewItemType.BUTTON,
		"caption": "Send selected invoice",
		"click": {"bindTo": "onMyButtonClick"},
		"tag": "MyButton1"
	}
}

Then you can retrieve the tag in the click function handler like this: 

onMyButtonClick: function(p1, p2, p3, tag) {
    console.log(tag);
}

Ryan

Ryan Farley,



the solution works perfectly. Thank you.



I have a follow-up question if you do not mind. Does the tag being passed as the fourth argument mean that button click methods can take up to 4 arguments?  If that is the case how can one proceed if they were to pass more than one argument and populate p1 through p3? 



Thank you again, your Community responses and articles have been very helpful.



Firas

Hello,

 

Not sure about passing 4 arguments to the click event, I've been using the tag property only to pass the parameter needed. In your case you can bind the click-handler method to several buttons and specify different tags for it so the click-handler method could understand what to do according to the button tag.

Show all comments

Can I add custom function on this search button? Like alert or console

Like 0

Like

1 comments

Hello,

 

Theoretically, this is possible through additional development. 

 

This modal window is a separate schema called "LookupPage". The logic that is responsible for searching is located in the "LookupPageViewModelGenerator" schema



Unfortunately, we don't have the ready example of such realisation.



Best regards,

Bogdan

Show all comments

Hi Everyone,

I need to Hide button based on organizational role. I've used the following code but am not able to achieve the objective.

 

attributes:{

             "IsUserX": {

                    dataValueType: Terrasoft.DataValueType.BOOLEAN,

                    type: Terrasoft.ViewModelColumnType.VIRTUAL_COLUMN,

                    value: true

                },

        },

        onEntityInitialized: function() {

                    // Calling the parent implementation of the onEntityInitialized method.

                    this.callParent(arguments);

                    this.fnIsUserX();



            },

            getSectionActions:function(){

                var actionMenuItems = this.callParent(arguments);

                actionMenuItems.addItem(this.getButtonMenuItem({

                    Type:"Terrasoft.MenuSeparator",

                    Caption:""

                }));

                //actionMenuItems.addItem(this.getButtonMenuSeparator());

                actionMenuItems.addItem(this.getButtonMenuItem({

                                        "Tag":"XYZ",

                                        "Caption":"XYZ",

                                        "Click":{"bindTo":"ABC"},

                                        "Visible": {"bindTo": "IsUserX"},

                                        "Enabled": {"bindTo": "isCustomActionEnabled"},

                                        }));

                return actionMenuItems;

            },

            isCustomActionEnabled: function() {

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

                console.log(selectedRows);

                return selectedRows ? (selectedRows.length > 0 && selectedRows.length <= 50) : false;

            },

            fnIsUserX:function(){

                var currentuser = Terrasoft.SysValue.CURRENT_USER.value;

                var esqAdmin = this.Ext.create("Terrasoft.EntitySchemaQuery", {

                    rootSchemaName: "SysUserInRole"

                });

                esqAdmin.addColumn("SysRole");

                esqAdmin.addColumn("SysUser");

                var grpFilters = this.Ext.create("Terrasoft.FilterGroup");

                var filterUser = this.Terrasoft.createColumnFilterWithParameter(this.Terrasoft.ComparisonType.EQUAL, "SysUser", currentuser);

                var filterRole = this.Terrasoft.createColumnFilterWithParameter(this.Terrasoft.ComparisonType.EQUAL, "SysRole.Name", "XYZ");

                grpFilters.addItem(filterUser);

                grpFilters.logicalOperation = this.Terrasoft.LogicalOperatorType.AND;

                grpFilters.addItem(filterRole);

                esqAdmin.filters.add(grpFilters);

                esqAdmin.getEntityCollection(function(result) {

                    if (!result.success) {

                        this.set("IsUserX",false);

                        return;

                    }

                    else {

                        var length = result.collection.collection.length;

                        if (length>0){

                            this.set("IsUserX", true);

                        }

                    }

                }, this);

            },

Like 0

Like

1 comments

Hi,

 

There is no onEntityInitialized method in the section page (it's available in the edit page only). If you need the button to be visible based on the user role you need to set the value for the "Visible" attribute in the button config (inside the actionMenuItems.addItem this.getButtonMenuItem function). You can use the example of the "Change log" button from the BaseDataView module (start seeking an example using this part of code - actionMenuItems.addItem(this.getObjectChangeLogSettingsMenuItem());) where operation permission is checked to display the button (and operation permissions are assigned to roles and this is what is needed in your task).

 

Best regards,

Oscar

Show all comments

I am going to add custom button which alerts some text on contact page. Is it possible?

Like 0

Like

2 comments

Hello Muhammadjon,

 

in order to achieve this you need to create a Replacing view model at the Custom package.

For the partent object you will need to select ContactSectionV2, or the section where you want to create this button.

Then you need to create a new localizable string (you will see the possibility to create a new one on the left) where you will put the desired text. for the button. While creating the localizable string you will need to enter the value, and the code. The code is something that you will use later.

 

After that you insert this code on the page:

 define("ContactSectionV2",

        function(BaseFiltersGenerateModule, Enums, ConfigurationConstants, BusinessRuleModule) {

            return {

                entitySchemaName: "Contact",

                messages: {},

                attributes: {},

                rules: {}/**SCHEMA_MODULES*/,

                /**

                 * Current schema mixins

                 */

                mixins: {},

                methods: {

                    OnTestButtonClick : function() {

                        Terrasoft.showInformation('Test') 

                    }

                },

                diff: /**SCHEMA_DIFF*/[

                    {

                    "operation": "insert",

                    "parentName": "ActionButtonsContainer",

                    "propertyName": "items",

                    "name": "TestButton",

                    "values": {

                        "itemType": Terrasoft.ViewItemType.BUTTON,

                        "style": Terrasoft.controls.ButtonEnums.style.GREEN,

                        "caption": {"bindTo": "Resources.Strings.TestButtonCaption"},

                        "markerValue": {"bindTo": "QualificationProcessButtonCaption"},

                        "classes": {"wrapperClass": ["t-btn-wrapper t-btn-text t-btn-style-blue actions-button-margin-right"]},

                        "iconAlign": Terrasoft.controls.ButtonEnums.iconAlign.RIGHT,

                        "click": {"bindTo": "OnTestButtonClick"},

                        "layout": {

                            "column": 6,

                            "row": 0,

                            "colSpan": 2

                        },

                        "visible": true

                    }

                }    ]/**SCHEMA_DIFF*/

            };

        });

 

The method  Terrasoft.showInformation('Test')  is the one responsible for displaying the message on screen. Here instead of Test you can write any message. 

The part where it says "caption": {"bindTo": "Resources.Strings.TestButtonCaption"}" , this is where you put the code from the localizable string previously created. So if the code of the string was called TestButtonCaption, then you need to put Resources.Strings.TestButtonCaption. If you name the code like "RandomButton" then it will be Resources.Strings.RandomButton.

 

Best regards,

Dariy 

Thanks so much! This is so helpful

Dariy Pavlyk,

Show all comments

How can i create custom button which alerts some text?

Like 0

Like

1 comments

Hello Muhammadjon,

 

in order to achieve this you need to create a Replacing view model at the Custom package.

For the partent object you will need to select ContactSectionV2, or the section where you want to create this button.

Then you need to create a new localizable string (you will see the possibility to create a new one on the left) where you will put the desired text. for the button. While creating the localizable string you will need to enter the value, and the code. The code is something that you will use later.

 

After that you insert this code on the page:

 define("ContactSectionV2",

        function(BaseFiltersGenerateModule, Enums, ConfigurationConstants, BusinessRuleModule) {

            return {

                entitySchemaName: "Contact",

                messages: {},

                attributes: {},

                rules: {}/**SCHEMA_MODULES*/,

                /**

                 * Current schema mixins

                 */

                mixins: {},

                methods: {

                    OnTestButtonClick : function() {

                        Terrasoft.showInformation('Test') 

                    }

                },

                diff: /**SCHEMA_DIFF*/[

                    {

                    "operation": "insert",

                    "parentName": "ActionButtonsContainer",

                    "propertyName": "items",

                    "name": "TestButton",

                    "values": {

                        "itemType": Terrasoft.ViewItemType.BUTTON,

                        "style": Terrasoft.controls.ButtonEnums.style.GREEN,

                        "caption": {"bindTo": "Resources.Strings.TestButtonCaption"},

                        "markerValue": {"bindTo": "QualificationProcessButtonCaption"},

                        "classes": {"wrapperClass": ["t-btn-wrapper t-btn-text t-btn-style-blue actions-button-margin-right"]},

                        "iconAlign": Terrasoft.controls.ButtonEnums.iconAlign.RIGHT,

                        "click": {"bindTo": "OnTestButtonClick"},

                        "layout": {

                            "column": 6,

                            "row": 0,

                            "colSpan": 2

                        },

                        "visible": true

                    }

                }    ]/**SCHEMA_DIFF*/

            };

        });

 

The method  Terrasoft.showInformation('Test')  is the one responsible for displaying the message on screen. Here instead of Test you can write any message. 

The part where it says "caption": {"bindTo": "Resources.Strings.TestButtonCaption"}" , this is where you put the code from the localizable string previously created. So if the code of the string was called TestButtonCaption, then you need to put Resources.Strings.TestButtonCaption. If you name the code like "RandomButton" then it will be Resources.Strings.RandomButton.

 

Best regards,

Dariy 

Show all comments

i need to disable a button after it is clicked once without refreshing a page.

Like 0

Like

2 comments

Add a boolean attribute to the page:

attributes: {
    "IsButtonEnabled": {
		dataValueType: Terrasoft.DataValueType.BOOLEAN,
		type: Terrasoft.ViewModelColumnType.VIRTUAL_COLUMN,
		value: true
	}
}

Then bind the enabled property of the button to the attribute:

{
	"operation": "insert",
	"parentName": "Header",
	"propertyName": "items",
	"name": "MyButton",
	"values": {
		"itemType": Terrasoft.ViewItemType.BUTTON,
		"caption": "My button",
		"click": {"bindTo": "onMyButtonClick"},
		"enabled": {"bindTo": "IsButtonEnabled"}
	}
}

Now when it is clicked, set the attribute to false:

onMyButtonClick: function() {
    this.set("IsButtonEnabled", false);
}

Ryan

Ryan Farley,

Hi Ryan, thank u for ur asnwer, is it for Classic or Freedom UI?

 

Show all comments

Hello Community!

I want to save a record on button click. How is this done from the front-end. What is the line of code that I am missing. Best Regards!

Like 0

Like

6 comments
Best reply

Petrika,

 

It doesn't save the record since the click event is handled not by the onCardAction method, but by your custom one:

click": {
						"bindTo": "onGenerateReferencePriceClick"
					},

According to your need you can use another approach of saving a record: you can call the save function directly (save method parent implementation can be found in the BaseEntityPage module):

this.save();

just add it at the beginning of the code for your button click handling.  And also you can execute methods synchronously using Terrasoft.chain method (an example of the usage can be found in this community post).

 

Best regards,

Oscar

Hi Petrika,

 

Please study the logic of the SaveRecordButton element in the BaseDataView module and the logic of the onCardAction method and the "save" tag of the button and apply the same logic to your button.

 

Best regards,

Oscar

Oscar Dylan,

Dear Oscar!

I have added the save tag , in the button diff ( image below )

I am uncertain of the lines of code I have to put in the body of the Method, that the button calls(image below)

Your help is much appreciated Oscar! Thank you

Petrika,

 

Simply add:

"tag": "save",
"markerValue": "SaveButton",
...
"click": {
						"bindTo": "onCardAction"
					}

To your button "values" and refresh the page. This will do the trick.

 

Best regards,

Oscar

Oscar,

Still Its not working.

I will give a full explanation of the problem.

I have created a button Generate Reference Price (marked with Red), which calls a web-service that populates the Collateral Price indicator detail(marked with yellow).

In the moment That I click the Generate Reference Price button i want that the information entered in the page is saved (just like clicking the Save button marked with brown). You can get a better understanding from the image below.

This is the code from the button

"operation": "insert",
				"name": "FzGeneratePrecalButton",
				"values": {
					"itemType": 5,
					"style": "blue",
					"id": "74a20850-7021-4e0a-a2e6-98bdc419f323",
					"tag": "save",
					"markerValue": "SaveButton",
					"caption": "Generate Reference Price",
                     ...
					"click": {
						"bindTo": "onGenerateReferencePriceClick"
					},
					"visible": {
						"bindTo": "FZButtonVisible"
					},
					"enabled": true
				},

And this is part of the code, of the Method that the button calls

onGenerateReferencePriceClick: function()
			{
				const tag = arguments[0] || arguments[3];
				const cardModuleSandboxId = this.getCardModuleSandboxId();
				this.sandbox.publish("onGenerateReferencePriceClick", tag, [cardModuleSandboxId]);

This is the result from the debugger

I cant find a reaon why this is not working.

Petrika,

 

It doesn't save the record since the click event is handled not by the onCardAction method, but by your custom one:

click": {
						"bindTo": "onGenerateReferencePriceClick"
					},

According to your need you can use another approach of saving a record: you can call the save function directly (save method parent implementation can be found in the BaseEntityPage module):

this.save();

just add it at the beginning of the code for your button click handling.  And also you can execute methods synchronously using Terrasoft.chain method (an example of the usage can be found in this community post).

 

Best regards,

Oscar

Thanks very much Oscar!

Show all comments

Hello Community,

Is it possible to hide a button that I created myself through business rules (

Show element on the page)? I want the button to appear when some fields of my page are filled in. How is this done ?

Like 0

Like

3 comments

Hello Petrika,

 

Thank you for your question!

 

Unfortunately, it's not possible to hide a button with the help of a business rule. You can only hide a field.

 

Kind regards,

Anastasiia

Hello Anastasia!

I thought that Attribute, could help me in this scenario

 

Hello Petrika,

 

There was a similar question on the Community in the past. Please see this thread. In your case the ButtonVisible attribute should change the state from true to false and visa versa in case this.get("Needed column")=="" or typeof(this.get("Needed column")) == 'undefined'. So simply perform a couple of tests and you will get the result needed.

 

Best regards,

Oscar

Show all comments