Greetings. 

I have a need to give users the ability to decide, which fields should be required for a particular page. I had some sort of the solution in my head. It makes an request and returns with a list of fields that need to be required for this particular page. The problem I am facing is making fields required via JS code (not in Diff section but in the code section, like "onEntityInitialized"). Looking forward to seeing the possible ways to solve this problem.

Like 0

Like

1 comments

Hello,

In order to make a field required based on the condition you need to bind it to an attribute, here is an example of how to do it:

1) Create a new boolean attribute

attributes: {
			"IsValueRequired": {
				"dataValueType": Terrasoft.DataValueType.BOOLEAN,
				"value": false
			}
		},

2) Bind this attribute to an "IsRequired" parameter in the field diff:

"values": {
					"isRequired": {"bindTo": "IsValueRequired"},
					"layout": {

3) Set the value to this attribute in the onEntityInitialized method:

methods: {
			onEntityInitialized: function() {
				this.callParent(arguments);
				this.setIsValueRequired();
			},
			setIsValueRequired: function() {
				if (YOUR CONDITION) {
					this.set("IsValueRequired", true);
				}
				else this.set("IsValueRequired", false);
			}
		},

 

Show all comments

Hello community!

I need to set fields required based in values of a lookup at client side.

I was trying to test how isRequired works in attributes , but I found that the only way to work with it, is declaring the explicit value to True or False.

Tried to use a virtual column, and a method function, but it behaves weird.  

Here are my examples:

and this how it looks on screen:

 

It's showing the "Enter a Value" warning but they are supposed not to be required (* is missing).

 

Is there any way to workaround with this?

 

Thank you for your help.

Like 0

Like

3 comments
Best reply

Cesar Jaramillo,

Let's see what method of making fields required* dynamically actually works good – it is using rules/businessRules.

You can create a rule for your field, the condition can be any value of the page and its related lookups.

Like here:

But if you have to do this for several fields, it will take much time to set them for each field. 

And if there are many conditions or they are too complex, "businessRules" abilities can be not enough.

But we can set an attribute (boolean) to be a condition for each of these rules, like here:



The attribute value can be changed dynamically using "methods".

 

So here's what i'd advise you to do:



In my example the fields "Email" and "Preferred language" become required, if the contact Type is "Customer" and the "Owner" field is not empty.

1. Add an attribute of type BOOLEAN

attributes: {
	"FullInfoRequired": {
		"dataValueType": Terrasoft.DataValueType.BOOLEAN,
		"dependencies": [
			{
				"columns": ["Owner", "Type"],
				"methodName": "setFullInfoRequired"
			}
		]
	}
},

Each time any of the columns ("Owner" or "Type") is changed, the method "setFullInfoRequired" is called.

2. Add the method

setFullInfoRequired: function() {
	var type = this.get("Type");
	// ContactType.Client is a GUID for "Customer" type
	if (type.value === confConsts.ContactType.Client && this.get("Owner")) {
		this.set("FullInfoRequired", true);
	}
	else this.set("FullInfoRequired", false);
}

To set the attribute on page loading, immediately after the page loaded its data, you should also call this function in "onEntityInitialized":

onEntityInitialized: function() {
	this.callParent(arguments);
	this.setFullInfoRequired();
}

3. Add the rules using Page designer, as in my 2nd screenshot, for each field that should become required.

 

If the conditions are simple, just use businessRules as in the 1st screenshot.

 

Hello Cesar,

 

The isRequired attribute that uses the value that method returns works correctly in my local app (using bindTo: {"method name here"}). It seems that there is either some other custom logic related to these columns in the ContactPageV2 or maybe custom CSS that hides these * symbol. You need to look through all the logic related to these columns where you need to have the * symbol.

 

Best regards,

Oscar

Oscar Dylan,

Hi Oscar,  In my case, when the method returns True it works fine, but when it returns False, the * is gone, but the warning remains and it doesn't allow to save.  In what version did you try it?

Thanks!

Cesar Jaramillo,

Let's see what method of making fields required* dynamically actually works good – it is using rules/businessRules.

You can create a rule for your field, the condition can be any value of the page and its related lookups.

Like here:

But if you have to do this for several fields, it will take much time to set them for each field. 

And if there are many conditions or they are too complex, "businessRules" abilities can be not enough.

But we can set an attribute (boolean) to be a condition for each of these rules, like here:



The attribute value can be changed dynamically using "methods".

 

So here's what i'd advise you to do:



In my example the fields "Email" and "Preferred language" become required, if the contact Type is "Customer" and the "Owner" field is not empty.

1. Add an attribute of type BOOLEAN

attributes: {
	"FullInfoRequired": {
		"dataValueType": Terrasoft.DataValueType.BOOLEAN,
		"dependencies": [
			{
				"columns": ["Owner", "Type"],
				"methodName": "setFullInfoRequired"
			}
		]
	}
},

Each time any of the columns ("Owner" or "Type") is changed, the method "setFullInfoRequired" is called.

2. Add the method

setFullInfoRequired: function() {
	var type = this.get("Type");
	// ContactType.Client is a GUID for "Customer" type
	if (type.value === confConsts.ContactType.Client && this.get("Owner")) {
		this.set("FullInfoRequired", true);
	}
	else this.set("FullInfoRequired", false);
}

To set the attribute on page loading, immediately after the page loaded its data, you should also call this function in "onEntityInitialized":

onEntityInitialized: function() {
	this.callParent(arguments);
	this.setFullInfoRequired();
}

3. Add the rules using Page designer, as in my 2nd screenshot, for each field that should become required.

 

If the conditions are simple, just use businessRules as in the 1st screenshot.

 

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 developing an external application to Creatio with integration via oData.

We need to know how to obtain with odata the required fields of a schema, for example contact and the data type of each field.

 

Thank you!

Regards

Like 0

Like

3 comments
Best reply

Hello Uriel,

Once authenticated normally, you can do a POST to the following (it's DataService, but when you authenticate for OData it will also work for DataService, even if you're using OData for the other requests):

/0/DataService/json/SyncReply/RuntimeEntitySchemaRequest

Include the following payload in the request:

{"uId":"25d7c1ab-1de0-4501-b402-02e0e5a72d6e"}

Where the uId included is the UId for the entity (you can get this from SysSchema or VwSysSchemaInWorkspace where ExtendParent = false). You'll get back a json payload with details for all columns, including the "isRequired" value for the column.

Ryan

Hello Uriel,

Once authenticated normally, you can do a POST to the following (it's DataService, but when you authenticate for OData it will also work for DataService, even if you're using OData for the other requests):

/0/DataService/json/SyncReply/RuntimeEntitySchemaRequest

Include the following payload in the request:

{"uId":"25d7c1ab-1de0-4501-b402-02e0e5a72d6e"}

Where the uId included is the UId for the entity (you can get this from SysSchema or VwSysSchemaInWorkspace where ExtendParent = false). You'll get back a json payload with details for all columns, including the "isRequired" value for the column.

Ryan

Ryan Farley,

Thank you! Have a nice weekend.

Ryan Farley,

Hello,

I need to update, using odata, a record in Creatio, but there are one or more fields that are required to be completed, on the Creatio side (Form_Page) that are not completed and I get error when updating those records using odata.


Is there any way to skip the required field rules (fields not related to the integration) and get the object update using odata?

Show all comments

Dear community,

 

How to find all the required activities created in the current stage of DCM, which have not been completed yet ?

For example, I need to determine that there is at least one required activity at the current stage of DCM.

 

 

Thank you in advance.

Best regards,

Mariia

Like 0

Like

3 comments

Hello Mariia,

 

You need to use the "Activity" detail (on the "History" tab) of the record where the DCM is set. Or you can simply take a look at the Actions Dashboard and see if there is an "*" mark on the activity subject and that means that the activity is required.

 

Best regards,

Oscar

Hello Oscar Dylan,

Thank you for your answer, but the task is a bit more complicated.

My business task is to prevent the process (that can be started with the button on the page) from changing the stage if there is at least one required action at this stage.

It is something like if the user change the stage manually (in the base logic of DCM):

 

Thank you in advance.

Best regards,

Mariia

Mariia Prostiak,

 

In order to get the information about the uncompleted activities please use the “GetRequiredUncompletedElements” method from the “Terrasoft.Core.DcmProcess” namespace. Please find more information about this method in the documentation by the link below:

 

https://academy.creatio.com/api/netcoreapi/7.15.0/index.html#Terrasoft.Core~Terrasoft.Core.DcmProcess.DcmEntityUtilities~GetRequiredUncompletedElements.html

 

Best regards,

Norton

Show all comments

Hello Community,

 

I have a project where we have a decent amount of tabs per edit page. Many fields are labeled similarly due to the nature of the project. However, not all of them are required on a given page. I think it would make it easier for the users if there was a way to let them know in which tab they are missing a required value. I attach a picture describing what I mean. 

Thanks a lot for any recommendations!

Ignacio

 

 

File attachments
Like 1

Like

0 comments
Show all comments