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
Question

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

Hello Community!

I am developing a functionality such as, a data grid within a detail, is populated when I Click a button. In the same time when I click the button I want to reload the grid data. Which is the proper syntax for the callback function in Creatio, because i havent seen many examples in the Community.

 
			onGenerateButtonClick: function(callback,scope)
			{
				var currentRecordId = this.get("MasterRecordId");
				var args = {
                    sysProcessName: "FZProcess_dc5a9de",
                    parameters: {
                        RecordId: currentRecordId,
						Amount: FZAmount,
						Interes: FZInteres,
						StartPaymentDate: FZStartPaymentDate,
						Tenor: FZTenor		
                    } 		
                }                
				this.reloadGridData();
                ProcessModuleUtilities.executeProcess(args);  
 
			}

I want to use this.reloadGridData(); inside a callback, after the   ProcessModuleUtilities.executeProcess(args) is finished , which is the proper way to do this ? 

Like 0

Like

6 comments
Best reply

Petrika,

In your case the button appears to be a part of the page schema, not a part of the detail schema. For you to refresh the detail you'd need to use:

this.updateDetail({ detail: "NameOfDetail" });

You can find the "NameOfDetail" value to use by looking at the details section of the page code for your detail (it's not the name of the detail schema, but the name or Id it gave it when it added it to the page). The reloadGridData function only works from within the detail schema code itself. 

Hello Petrika,

Calling this.reloadGridData() is the proper function to use to refresh the detail grid from within the detail schema itself. However, you do need to call after the process completes. 

I have an article here that shows how to use a callback when executing a process: https://customerfx.com/article/programmatically-starting-a-process-from…

If you put the call to reloadGridData inside the callback then it will refresh  when the process has completed.

Ryan

Ryan Farley,

Hello Ryan,

Firstly thanks for the quick reply, your posts are very useful, each time i have a developing problem in creatio.

In this case i saw the post before. I have try it. When I use the callback like the article the page only reloads and never stops, thats why i thought of another callback syntax.

Ryan Farley,

To be more specific

I have created this button Generate on the Main Page(parent). When this button is clicked , it calls a bussines Process, which on the other hand executes a Stored Procedure(populates dhe datagrid of the details).

onGeneratePrecalButtonClick: function()
			{
var currentRecordId = this.get("Id");
		var args = {                                                                  
		sysProcessName: "FZProcess_dc5a9de",
			parameters: {
				RecordId: currentRecordId,
				Amount: this.$FZAmount,
				Interes: this.$FZInteres,
				StartPaymentDate: this.$FZStartPaymentDate,
				Tenor: this.$FZTenor		
					}
				};
              ProcessModuleUtilities.executeProcess(args);  
}

When the Business Process finishes, i want to reload the grid data of the Details, so that I dont have to press the green Button below

How can this be done ?

 

Petrika,

 

Hello,

 

There are two possible ways:

 

1) Call this method after the executeProcess method call:

this.updateDetail({
 
                        detail: "DetailNameHere"
 
                    });

2) At the end of your business process execution you need to send some message using MsgChannelUtilities class and PostMessageToAll method, create a replacing ClientMessageBridge, add your message there, add the message to the page where the detail is located, subscribe to the message and specify a handler for the received message (a simple example is here). Once the message is received the handler should call the same updateDetail method as above.

 

Best regards.

Oscar

Petrika,

In your case the button appears to be a part of the page schema, not a part of the detail schema. For you to refresh the detail you'd need to use:

this.updateDetail({ detail: "NameOfDetail" });

You can find the "NameOfDetail" value to use by looking at the details section of the page code for your detail (it's not the name of the detail schema, but the name or Id it gave it when it added it to the page). The reloadGridData function only works from within the detail schema code itself. 

Thanks very much Oscar and Ryan ! Your help was great.

Show all comments

Hi community,

 

I have the following situation :

 

 

From the "ENCOWAY SESSION" button, I want to override the onClick() method from it to automatically start a business process from there. How can I do this ?

 

 

Furthermore, my business process should take the object id (e.g. opportunity id) corresponding to the id of the record where the button is and set it as a request parameter of a webservice.

 

Then, I want to open the response paramter, which is an URL, in a new window. The Script Task is in C#, so I want to have a similar method as window.open("URL") in Javascript. The "URL" should be the response parameter of the API.

 

Do you have any idea on how to achieve this ?

 

Here is a business process model summary of what I want :

 

 

Many thanks,

Jonathan

Like 0

Like

2 comments
Best reply

Hi Jonathan,

I have an article on that topic with the code you'll need to start the process and pass the current record Id into a process parameter here: https://customerfx.com/article/programmatically-starting-a-process-from…

However, as far as opening a new window, you can't do that from a server-side process. Instead, you can send a value, such as a URL string, from the server-side process to the client-side code, then the client-side code could open the window. I have an article on that topic here https://customerfx.com/article/sending-a-message-from-server-side-c-to-…

Ryan

Hi Jonathan,

I have an article on that topic with the code you'll need to start the process and pass the current record Id into a process parameter here: https://customerfx.com/article/programmatically-starting-a-process-from…

However, as far as opening a new window, you can't do that from a server-side process. Instead, you can send a value, such as a URL string, from the server-side process to the client-side code, then the client-side code could open the window. I have an article on that topic here https://customerfx.com/article/sending-a-message-from-server-side-c-to-…

Ryan

Dear Ryan Farley,

 

Your answer was really perfect. I managed to implement the whole process. Your articles are very pertinent. 

 

Many many thanks,

Jonathan

Show all comments

Hi 

Can anyone tell me what is the functionality of the Portal message button (as highlighted in the image) present in the Cases section on portal, and where can I find its configuration in the system?

 

Thanks

Like 0

Like

3 comments

Hello Nisarg,



Could you please elaborate more on your business task?



Best regards,

Bogdan

Hi Bogdan,

As the Cases section is not present in Studio Creatio, I would want to implement the Portal message button functionality in a custom section.

Thanks

Dear Nisarg,



Unfortunately, there is no way to implement your business task.



Best regards,

Bogdan

Show all comments