Hello!

 

I've been searching for documentation on how to access data in a column, from the database, but to no avail. To give you some sort of background, my Product object has a detail called Collateral. Users can add more collaterals - each having an allocation percentage. What I need is to create a function that gets from the database the allocation percentage of each Collateral added to the Product. How can I implement this with javascript?

Example: Product1 has 3 Collaterals added: Coll1, Coll2, Coll3.

How can I get, for Product1 the allocation percentage of each Collateral?

Also, where could I check more documentation on the available methods? For example, asyncValidate for javascript?

Like 1

Like

4 comments

Hi Maria,

 

You need to use ESQ to get the data from some record in the detail related to the section. In this case you need to get the Id of the current main record (where the detail is located) by using for example:

var currentRecordId = this.get("Id");

and then in the ESQ filter you need to specify this Id in the filtration ("CollateralsInProduct" should be replaced with your detail object code, "CollateralValue" should be replaced with the code of the column in the "CollateralsInProduct" object where the actual values are stored, "ProductId" should be replaced with the code of the column that connects you detail to the main product record):

var esq = Ext.create("Terrasoft.EntitySchemaQuery", {
    rootSchemaName: "CollateralsInProduct"
});
esq.addColumn("CollateralValue");
var esqFilter = esq.createColumnFilterWithParameter(Terrasoft.ComparisonType.EQUAL, "ProductId", currentRecordId);
esq.getEntityCollection(function (result) {
    if (result.success) {
        result.collection.each(function (item) {
            /* Process the collection elements. */
        });
    }
}, this);

As for more documentation on basic methods like asyncValidate - unfortunately we have none suitable one where all the methods are described. I will ask our Academy team to create this article where all the available methods and properties are described so anyone could easily search data they need, thank you for this suggestion.

Hi Maria,

I have an article outlining a simple place to start with EntitySchemaQuery (to query the database from client-side code) here: https://customerfx.com/article/an-introduction-to-performing-client-sid…

Also an article on using asyncValidate here: https://customerfx.com/article/asynchonous-validation-on-pages-in-creat…

Hope this helps get you started. 

Ryan

Oleg Drobina,

Thank you, your answer enlightened me very much. Though I have some trouble accessing the id of the product. 

Based on what you explained, 

In this case you need to get the Id of the current main record (where the detail is located) by using for example:

 var currentRecordId = this.get("Id");

I understood that through this line of code I am accessing the id of the product to which my collaterals are added. But by logging this id to the console, I noticed that each time it comes different. Is this the id of each collateral that I am adding? How can I get to the id of the product? That's what I am supposed to do, right?

Thank you so much for the attention.

For me, I usely add a debugger to the code. Then examine "this" In the console to see what values are already available.

Show all comments

Hi Community!

 

I have the following requirement:

We need to link a custom entity called reclamations to the activity. This has to be done m:n. So I have created a new link entity called ReclamationInActivity and added it as a detail to the ActivityPageV2.js.

 

When adding such a ReclamationInActivity record from the activity a new page opens and the user can open the reclamation lookup window there to select or create a reclamation.

When they choose to create a new reclamation, the account and contact have to be prefilled on the "new reclamation" page.

 

I cannot use business rules, because there is no link from the reclamation to ReclamationInActivity.

Also, using a business process is not an option, because the user would have to save the record first and we need to prefill the values.

Is there a way to achieve this by javascript somehow?

 

Thanks,

Robert

Like 0

Like

1 comments

Hi,

If I understand you correctly you want to add a value to columns "Contact" and "Account" from your activity. If so, you can use a simple esq request to get these values and set them in the init or onEntityInitialized methods.

Show all comments

I created a harmony of data which comes from external web services. For example, I retrieved dataA for ColumnA, dataB for ColumnB, dataC for ColumnC etc. I want to INSERT this data to section object table which section page based on.



How can i bind these things?

Like 0

Like

1 comments

Hello,

 

You can create a business process in which you will fill in the required fields received from the web service.

 

Details on the academy website:

https://academy.creatio.com/docs/user/bpm_tools/process_elements_refere…

Show all comments

Dear Community,

 

I have the same detail on a page but in 2 different pages.

Is it possible to remove the (+) button from the detail on one page but not the other?

I've read this one and this one on how to hide it, but they hide the (+) button on every page.

 

This tab requires the detail to have a (+): Detail1

On a different page, this detail can not have the (+): Detail2

 

Thank you.

 

 

Kind regards,

Yosef

Like 0

Like

4 comments

Hello Yosef,

I have an article on that topic here: https://customerfx.com/article/conditionally-making-a-detail-read-only-…

Basically, the article determines if the "Add" button is available based on the column that the detail is connected to the page with. For example, if you had a detail that could be on the Account page (connected by the detail column UsrAccount) and also on the Contact page (connected by the detail column UsrContact), you could make the Add button available only on the Account page by using the following: 

getAddRecordButtonVisible: function() {
    // if the detail is connected to the page using the column UsrAccount 
    // make the Add button visible
    return (this.get("DetailColumnName") === "UsrAccount");
}

Ryan

It is also possible to create 2 details based on the same object - one with "+", another - read-only

Ryan Farley,

but there is a problem when having inline editable list, even after hiding the menu commands "Add, Edit, Copy, Delete" of the detail using "getEditRecordMenuItem: Terrasoft.emptyFn", the buttons still there when clicking a record so we can do all the operation 

button shown

is there a way to hide them as well based on a condition, and make the fields non-editable 

one solution for making them disappear is to comment or remove the lines of ActiveRowActions : 
comments

but this solution doesn't prevent the record's fields to be editable, and also not dynamic based on a condition

Show all comments

Hello Community!

I have modified the Activity object in order to display a custom Object (Order) and added an Activity column too. 

Now, when clicking on the RightSideMenu I have the same object (Activity = Attività, and Ordini = Orders) repeated twice. Does anybody know which module is in charge of displaying the options within this menu? Or do you have any idea of what the "cleanest" solution might be?

Thank you and have a great day! :) 

Like 0

Like

5 comments
Best reply

Federica,

 

Basically, there is a table in the database called EntityConnection. You can delete all the records from this table that refer to the objects which you do not need (for example, contact, requests etc).

You can do the following:

delete from EntityConnection where SysEntitySchemaUid in (select Uid from SysSchema where Name = '')

where '' is the name of the object, for example, Contact.

But the thing is if you delete the records from the EntityConnection table - the next fields on the activity page will be deleted automatically as well:



Best regards,

Bogdan

Hello Federica,



Could you please send the screenshot once again?



Best regards,

Bogdan

Hello Bogdan,



Here's the image, sorry for the mishap

Federica,

 

Basically, there is a table in the database called EntityConnection. You can delete all the records from this table that refer to the objects which you do not need (for example, contact, requests etc).

You can do the following:

delete from EntityConnection where SysEntitySchemaUid in (select Uid from SysSchema where Name = '')

where '' is the name of the object, for example, Contact.

But the thing is if you delete the records from the EntityConnection table - the next fields on the activity page will be deleted automatically as well:



Best regards,

Bogdan

Thank you Bogdan! That's exactly what I did (according to your suggestion) ! :) Do you happen to know how to change the icon too? 

 

I made a few tests and to access the icons I need to implement EmailItemSchema client module

Now: 

Show all comments

Hi Community,

 

We are trying to integrate the Zadarma Widget with Creatio. Our main objective is to load this widget every time we press the "Phone" button (marked with red square in the following image).

In order to achieve this, we need to call the necessary dependencies, so it's possible to execute the "zadarmaWidgetFn" function, as you can see on the next image.

require.config({
	paths: {
		loader_phone_lib: '//my.zadarma.com/webphoneWebRTCWidget/v8/js/loader-phone-lib.js?sub_v=62',
		loader_phone_fn: "//my.zadarma.com/webphoneWebRTCWidget/v8/js/loader-phone-fn.js?sub_v=62"
	},
});
 
define("CtiPanel", ["ServiceHelper", "loader_phone_lib", "loader_phone_fn"], function(ServiceHelper) {
	return {
		messages: {},
		mixins: {},
		attributes: {},
		methods: {
			callPhoneNumber: function (){
				var number = this.get("PhoneNumber");
				window.console.log(number);
 
				var sipValue = "SIP";
 
				var payload = {
					sip: sipValue
				};
 
				ServiceHelper.callService("ImdZadarmaWebHookService", "ZadarmaWebRTCKey", function(response) {
					var result = JSON.parse(response.ZadarmaWebRTCKeyResult);
					window.console.log(result.key);
					zadarmaWidgetFn(result.key, 'SIP', 'square', 'en', true, "{left:'10px',top:'5px'}");
				}, payload, this);
			}
		},
		diff: []
	};
});

However, we are getting the following error while loading these dependencies, because one of the files "loader_phone_lib" (https://my.zadarma.com/webphoneWebRTCWidget/v8/js/loader-phone-lib.js?s…) has other dependencies that are called through tags.

We would like to know, how can we load these dependencies, that are inside the "loader_phone_lib" file, without getting this error?

 

Thanks in Advance.

 

Best Regards,

Pedro Pinheiro

Like 3

Like

4 comments

Hi Pedro,

 

According to https://requirejs.org/docs/errors.html#mismatch there should be the anonymous define() method inside the script HTML tag in one of the dependencies that are loaded. So to fix the error you need to check all the steps described in the requirejs.org document.

 

Best regards,

Oscar

Hi Oscar,

 

Thank you for the response.

 

Yes, some of the scripts have the anonymous define() method inside, so by following the documentation you provided, I removed the dependencies from the "loader_phone_lib" script and added them using the code bellow:

....
require.config({
	paths: {
		zadarmaSocket: "//my.zadarma.com/webphoneWebRTCWidget/v8/js/socket.io",
		zadarmaDetectWebRTC: "//my.zadarma.com/webphoneWebRTCWidget/v8/js/detectWebRTC.min",
		zadarmaJssip: "//my.zadarma.com/webphoneWebRTCWidget/v8/js/jssip.min",
		zadarmaMd5: "//my.zadarma.com/webphoneWebRTCWidget/v8/js/md5.min",
		zadarmaWidgetAPI: "//my.zadarma.com/webphoneWebRTCWidget/v8/js/widget-api.min.js?sub_v=62",
		zadarmaWidget: "//my.zadarma.com/webphoneWebRTCWidget/v8/js/widget.min.js?sub_v=62",
		loader_phone_fn: "//my.zadarma.com/webphoneWebRTCWidget/v8/js/loader-phone-fn.js?sub_v=62"
	}
});
 
define("CtiPanel", ["ServiceHelper", "zadarmaSocket", "zadarmaDetectWebRTC", "zadarmaJssip", "zadarmaMd5", "zadarmaWidgetAPI", "zadarmaWidget", "loader_phone_fn"], function(ServiceHelper) {
	return {
		messages: {},
		mixins: {},
		attributes: {},
		methods: {
			callPhoneNumber: function (){
				var number = this.get("PhoneNumber");
				window.console.log(number);
 
				var sipValue = "SIP";
 
				var payload = {
					sip: sipValue
				};
 
				ServiceHelper.callService("ImdZadarmaWebHookService", "ZadarmaWebRTCKey", function(response) {
					var result = JSON.parse(response.ZadarmaWebRTCKeyResult);
					window.console.log(result.key);
					zadarmaWidgetFn(result.key, 'SIP', 'square', 'en', true, "{left:'10px',top:'5px'}");
				}, payload, this);
			}
		},
		diff: []
	};
});

This piece of code manage to "fix" the previous error. However, I'm getting a new error, which is related to the Socket.Io (zadarmaSocket), as you can see on the next image:

I think this error is caused by the fact that one of the dependencies cannot reach specific functions/vars from other dependencies. I've tried to use the "shim" attribute, in order to create a sequence for loading the dependencies and it didn't work.

 

Thanks in Advance.

 

Best Regards,

Pedro Pinheiro

 

Pedro Pinheiro,

 

Hello,

 

The new code returns another error message on my side, but it happens since there is no ImdZadarmaWebHookService service and ZadarmaWebRTCKey method in my app. Can you please also share the code of this part?

 

Thank you!

 

Best regards,

Oscar

Hello Oscar Dylan,

 

The ZadarmaWebRTCKey method is responsible for requesting the WebRTC key from a specific "Client Key", "Client Secret" and SIP Number. I use this key to start the communication between the widget and Zadarma.

 

ImdZadarmaWebHookService.cs

 /* The custom namespace. */
namespace Terrasoft.Configuration.ImdZadarmaWebHookServiceNamespace
{
    using System;
    using System.ServiceModel;
    using System.ServiceModel.Web;
    using System.ServiceModel.Activation;
    using Terrasoft.Core;
    using Terrasoft.Web.Common;
    using Terrasoft.Core.Entities; 
	using System.Web;
	using System.Collections.Generic;
	using Terrasoft.Configuration.ImdZadarmaAPI;
	using System.Net.Http;
 
    [ServiceContract]
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]
    public class ImdZadarmaWebHookService: BaseService
    {
        [OperationContract]
       	[WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)]
		public string ZadarmaWebRTCKey(string sip){
 
            //ZadarmaApi is a class that contains all the methods to work with Zadarma API
			var zadarma = new ZadarmaApi("KEY", "SECRET");
 
 
			SortedDictionary<string, string> parameters = new SortedDictionary<string, string>();			
			parameters.Add("sip", sip);
 
            var response = zadarma.Call("/v1/webrtc/get_key/", parameters, HttpMethod.Get);
            string str = (string) response.Content.ReadAsStringAsync().Result;
            return str;
		}
    }   
}

The code for ZadarmaApi class can be found here:

https://github.com/zadarma/user-api-cs-v1/blob/master/ZadarmaAPI/ZadarmaApi.cs

 

Best Regards,

Pedro Pinheiro

Show all comments

We are looking for a for a way to impose a character limitation on a string value that is different than the standard settings. 

 

For example, the user enters a job number as a string and we want to restrict entry to only 10 characters. Is there a way to do this? Obviously not OOTB but with some customization?

Like 0

Like

1 comments

There is a possibility to setup a field validation and this approach is described in this Academy article.

 

Best regards,

Oscar

Show all comments

Hello community,

 

I need to filter a detail grid in order to show only a specific type of object.

To be more precise: the detail CI Users displays Contacts and Accounts...

Has anybody done anything similar and could you provide me with a code sample?

 

Thank you in advance, have a nice day

Like 0

Like

3 comments
Best reply

If you'd like to filter out the record, rather than just hide them, you can filter the detail using a filter method. I have outlined how to do that here: https://customerfx.com/article/filtering-a-detail-list-in-creatio-forme…

Ryan

Solved like this: 

methods: {
			prepareResponseCollectionItem: function(item) {
				var account = item.$Account && item.$Account.value; 
				debugger;
				if(account){
					item.customStyle = {
						"display":"none"
					}
				}
			}
		},

 

If you'd like to filter out the record, rather than just hide them, you can filter the detail using a filter method. I have outlined how to do that here: https://customerfx.com/article/filtering-a-detail-list-in-creatio-forme…

Ryan

Thank you Ryan!

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 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