I have a problem when trying to modify a lookup value in a Business Process. I have a Source field in Opportunity and when I first select the lookup it displays all of the values. After I click on anything else this happens:
The problem is that there are values in the lookup. I don't know what is happening.
I has solved this problem by adding parameter "this" into the "result.collection.each()".
It will be shown as "result.collection.each(function(), this)"
esq.getEntityCollection(function(result){
debugger;if(!result.success){// For example, error processing/logging.this.showInformationDialog("Can't set the location.");return;}
result.collection.each(function(item){
var primaryWarehouse ={value: item.get("Id"), displayValue: item.get("SceName")};this.set("SceWarehouse", primaryWarehouse);return;}, this)}, this);
I have tried to use the "Set field value" action, but it's too simple.
I want to set the value of "Warehouse" with a primary warehouse.
Note: The "Warehouse" section has the "Primary" (boolean) field.
So, for example; I have 2 warehouses, "A" and "B". And, I set the warehouse "B" primary field as TRUE. Then, when the user creates an order, the "Warehouse" field of the order will be filled by "B" automatically.
Based on the shared information I can assume that your business task can be fully covered with a help of business rules functionality.
If you'd like to expand the customization you can consider designing the custom business process that will read the needed columns from a page and apply changes with a Modify data element or even with script-task element where you can specify the custom logic with code.
Alternatively, you can implement your business task with a help of additional development, but we do not have a specific ready to use example of such implementation.
I managed to create a function in the page source code as below:
/* Overload the base Terrasoft.BasePageV2.onEntityInitialized method that is called after Creatio initializes the schema of the record page object. */
onEntityInitialized: function(){/* Call the parent implementation of the method. */this.callParent(arguments);/* Call the handler method that sets the [Location] column value. */this.setWarehouse();},
/* The handler method that sets the [Warehouse] column value. */
setWarehouse: function(){/* The [Warehouse] column value. */
var location =this.get("SceWarehouse");/* Checks whether the mode of the new record is set. */
var newmode =this.isNewMode();// * If the value is not set and the mode of the new record is set. */if(!location && newmode){/* Get the contact's location by using ESQ */const userContactId = Terrasoft.SysValue.CURRENT_USER_CONTACT.value;const esq =this.Ext.create(Terrasoft.EntitySchemaQuery, {
rootSchemaName:"SceWarehouse"});
esq.addColumn("Id");
esq.addColumn("SceName");
esq.addColumn("Primary");const esqFirstFilter = esq.createColumnFilterWithParameter(Terrasoft.ComparisonType.EQUAL,
"Primary", true);
esq.filters.add("esqFirstFilter", esqFirstFilter);
esq.getEntityCollection(function(result){
debugger;if(!result.success){// For example, error processing/logging.this.showInformationDialog("Can't set the location.");return;}
result.collection.each(function(item){
var primaryWarehouse = item;this.showInformationDialog(primaryWarehouse.get("SceName"));this.set("SceWarehouse", primaryWarehouse);})}, this);}}
The "showInformationDialog" function is able to show the correct record.
But, the "SceWarehouse" is still not populated.
Note: "SceWarehouse" field is a lookup based on the "SceWarehouse" section.
I has solved this problem by adding parameter "this" into the "result.collection.each()".
It will be shown as "result.collection.each(function(), this)"
esq.getEntityCollection(function(result){
debugger;if(!result.success){// For example, error processing/logging.this.showInformationDialog("Can't set the location.");return;}
result.collection.each(function(item){
var primaryWarehouse ={value: item.get("Id"), displayValue: item.get("SceName")};this.set("SceWarehouse", primaryWarehouse);return;}, this)}, this);
The onLookupDataLoaded: function(config) is not triggered for a custom lookup field in the object. However, the same is triggering for the OOTB lookup columns.
When the control is passed to the lookup, the onLookupDataLoaded event has to trigger but it isn't triggering for custom/newly created lookup in objects.
Are any additional changes required for new lookup columns added to the object?
With the new designer it is not possible to change the default value when the value is not anymore in the list of values of the lookup.
Create a lookup field, then add a value in the list of value and setup a default value in the field. Delete the lookup value in the list then when saving the record you get an integrity error : The INSERT statement conflicted with the FOREIGN KEY constraint ...
In earlier version you were able to change the default value in the designer but now it is not possible anymore when changing the value you got the load turning and you cannot change the default value.
It would be a great idea to apply a change and not to have to go in the db for changing the Foreign key.
Please be advised that the "The INSERT statement conflicted with the FOREIGN KEY constraint ..." error message appears due to a deleted lookup value that was previously used in the system.
Please note that it is highly not recommended to delete the lookup value to reduce the risk of such errors.
As a workaround, we may suggest you renaming the lookup rather than deleting it.
If the issue with the error persists we would recommend using the SQL script below to find out to which entity the FK is attached and where it is located.
After executing the script, you would need to find the connection between the section where the record is added with the FK that prevents it from being added.
Most likely the section has a field with a removed DEFAULT VALUE from the system or, that same field was removed which may cause this error.
Please see the SQL script:
SELECT
OBJECT_NAME(constraint_object_id) AS FKName,
OBJECT_NAME(parent_object_id) AS TableName,
COL_NAME(parent_object_id, parent_column_id) AS ColumnName,
OBJECT_NAME(referenced_object_id) AS RefTableName,
COL_NAME(referenced_object_id, referenced_column_id) AS RefColumnName
FROM
sys.foreign_key_columns
where OBJECT_NAME(constraint_object_id) = 'FK0ptyMLPUPcuuJ4DXFRngaggXnqcL'
Yes but before the release 7.17 you were able to correct this in the designer. With 7.17 and upwards, it is not possible to change the value in the interface. My request is to restablish the feature in the designer.
Please be advised that we have requested a demo instance of 7.16.2 version of Creatio for testing purposes.
Could you please login and provide us with the descriptive information you are referring to in your last message about changing the value in the designer in prior Creatio versions please?
I have noticed this behavior as well in 7.17 (which is different than previous versions). In 7.17 you cannot edit the default value so it no longer references the deleted item (it will just spin and not allow you to remove the now invalid default item)
The issue I experienced (this was in 7.17.1, I've not yet retested this in 7.17.2) wasn't with setting the default value. The issue was when a default value for a lookup column had been set, then later that lookup item was deleted (so the default value referenced an Id from the lookup that no longer exists). In this case, I was unable to edit the default value to change or remove the default - I assume because it was trying to load the Name part of the default value which no longer existed.
The only way I could get around this and edit the default again was to insert a row into the lookup using the same Id as the deleted item (the Id for the default value of the lookup column)
Please be advised that upon our testing we have confirmed the issue with an infinite loading after changing the Default Value in the Lookup in 7.17.0 version.
We may also confirm that this issue has been fixed in 7.17.2 - the system allows you to change the Default Value of the lookup after this exact value was deleted within the lookup list.
We appreciate your cooperation!
Please do not hesitate to contact the Support Team in case you have any additional questions!
In order to implement the required functionality please use the “dependencies” property of an attribute and in a method-handler set the value of the field to the “not filled in” value. Please see the example of the code below (UsrTest, Dear and Phone are the attributes of a particular object):
attributes: {
"UsrTest": {
"dependencies": [
{
"columns": ["Dear", "Phone"],
"methodName": "setUsrTest"
}
]
}
}
setUsrTest: function(){
if (this.get("Phone") === "111" && this.get("Dear") === "test"){
this.set("UsrTest", "not filled in");
}
}
Please find additional information in the article by the link below:
The goal is to force the user to clear the field value, in order to force the user to enter a new value, just like a field that has nor been filled in yet.
Default values can be set via configuration for all replaced objects. For example if I want to set default Account for Orders I create replaced object for Order and and specify it in default value field: http://prntscr.com/qqg9kp. it can be selected from existing value, system setting or variable: http://prntscr.com/qqga4r. Please note that if selected default value is removed from the system it can lead to different issues so do not select values that can or will be deleted.
Yes, it is possible to do either via hard additional development or by changing "Displayed value" in object advanced settings for the object that is represented by the lookup http://prntscr.com/q50jbe. Please note that it is not preferred option since this value will be changed everywhere in the system where lookups based on "Contact" object are used.
Please also note that account field cannot be selected there since account is another lookup, but the system allows using only "String" data type fields when specifying "Displayed value", but you can add your custom hidden field and create a process that will fill this field in with the value of an account that is chosen for the contact specified.
I want to open a look up which by default has already selected records, please see image below. Lets say, I have look up "Main Activity". I want record "Main Activity A" by default was checked upon opening the look up window.
In order to add such functionality you will need to proceed with custom development to the basic functionality.
Overall, this would be a major development, and we highly do not recommend to interfere with basic functionality, since it can caused unexpected system behavior.
If you decide to go for development within the system, you will need to do the following:
- Add the LookupUtilitiesV2 to the dependencies of the schema, where lookup is located;
- Override the basic schema BaseLookupPageV2;
- BaseLookupPageV2 contains various methods, which are responsible for opening of the lookup and processing user actions. It also contains an attribute 'SelectedRows', which you might need in your development.
- Override the basic method opening the lookup, so to retrieve the collection of objects, before they are rendered on the page. Modify or add the needed object to selected rows.
- Add the clause, that your functionality will only execute for particular schema/lookup/section/page, since BaseLookupPageV2 is a parent schema for other lookups in the system.