Hey Community,

 

I have two details on my custom "Order" entity. Depends on order status i need to show/hide add button and the possibility to edit this details.

Is there any best practices for this scenario?



Thanks for help,

Oleksiis

Like 1

Like

6 comments
Best reply

Hello, 

Here is an example of how to hide the Add button in detail based on the condition:

define("UsrSchemaaae5d57eDetail", ["ConfigurationGrid", "ConfigurationGridGenerator",
	"ConfigurationGridUtilitiesV2"], function() {
	return {
		entitySchemaName: "UsrForHideTest",
		attributes: {
                -------------
			"IsAddEnabled": {
				dataValueType: Terrasoft.DataValueType.BOOLEAN,
				value: true
			}
		},
                -------------
		methods: {
                --------------
			init: function() {
				this.callParent(arguments);
				this.isAddEnabled();
			},
			isAddEnabled: function() {
				var esq = Ext.create("Terrasoft.EntitySchemaQuery", {
                        rootSchemaName: "Contact"
                    });
                    esq.addColumn("Type");
                     esq.getEntity(this.values.MasterRecordId, function(result) {
                        if (result.success && result.entity.values.Type.displayValue == 'Customer') {
                            this.set("IsAddEnabled", false);
                        }
                    }, this);
			}
		},
		diff: /**SCHEMA_DIFF*/[
			{
				"operation": "merge",
				"name": "AddRecordButton",
				"values": {
					"visible": {"bindTo": "IsAddEnabled"}
				}
			},

Here we are hiding the button if the Type of the Contact = 'Customer'.

Regarding the editing of the detail, if I`m not mistaken, you cannot change it dynamically. 

Upd

I found the code snippet to hide Add button and added it to page - 

 

			isDetailEnabled: function(detailName) {
      		var productionStage = this.get("RdtStatus").displayValue;   
			if (detailName === "RdtSchemad16d4a3eDetail") {
			if(productionStage === "Planned"){
                    return true;       //Disable the "+" button
                }
                else{
                    return false;        //Enable the "+" button
                }
	}
			if (detailName === "RdtSchema670160a3Detail") {
			if(productionStage === "Planned"){
                    return true;       //Disable the "+" button
                }
                else{
                    return false;        //Enable the "+" button
                }
	}
			return this.callParent(arguments);
}

But now i have issue with clicking on data on editable grid



Hello,

not sure about best practices but for me isDetailEnabled also caused issues like that. I implemented this logic with replacing method in Detail code like this:

getAddRecordButtonEnabled: function() {
				var instance = this;
				var isEditable = instance.get("IsProductDetailEditable");
				return isEditable && this._isAddRecordButtonEnabled();
			},

adding attribute IsProductDetailEditable and settiging its value in onGridDataLoaded method override with an esq check of the parent page Status or any other condition you would need. This would cover add button, for the changes of existing rows you could add buisness rules for each field to block them for certain conditions, in my case implemented an esq check on save logic, with replacing method saveRowChanges from ConfigurationGridUtilities, check result would notify the user unability to save changes for that condition or proceed as normal.

Hello, 

Here is an example of how to hide the Add button in detail based on the condition:

define("UsrSchemaaae5d57eDetail", ["ConfigurationGrid", "ConfigurationGridGenerator",
	"ConfigurationGridUtilitiesV2"], function() {
	return {
		entitySchemaName: "UsrForHideTest",
		attributes: {
                -------------
			"IsAddEnabled": {
				dataValueType: Terrasoft.DataValueType.BOOLEAN,
				value: true
			}
		},
                -------------
		methods: {
                --------------
			init: function() {
				this.callParent(arguments);
				this.isAddEnabled();
			},
			isAddEnabled: function() {
				var esq = Ext.create("Terrasoft.EntitySchemaQuery", {
                        rootSchemaName: "Contact"
                    });
                    esq.addColumn("Type");
                     esq.getEntity(this.values.MasterRecordId, function(result) {
                        if (result.success && result.entity.values.Type.displayValue == 'Customer') {
                            this.set("IsAddEnabled", false);
                        }
                    }, this);
			}
		},
		diff: /**SCHEMA_DIFF*/[
			{
				"operation": "merge",
				"name": "AddRecordButton",
				"values": {
					"visible": {"bindTo": "IsAddEnabled"}
				}
			},

Here we are hiding the button if the Type of the Contact = 'Customer'.

Regarding the editing of the detail, if I`m not mistaken, you cannot change it dynamically. 

Dmytro Vovchenko writes:

Hello, 

Here is an example of how to hide the Add button in detail based on the condition:


 
define("UsrSchemaaae5d57eDetail", ["ConfigurationGrid", "ConfigurationGridGenerator",
	"ConfigurationGridUtilitiesV2"], function() {
	return {
		entitySchemaName: "UsrForHideTest",
		attributes: {
                -------------
			"IsAddEnabled": {
				dataValueType: Terrasoft.DataValueType.BOOLEAN,
				value: true
			}
		},
                -------------
		methods: {
                --------------
			init: function() {
				this.callParent(arguments);
				this.isAddEnabled();
			},
			isAddEnabled: function() {
				var esq = Ext.create("Terrasoft.EntitySchemaQuery", {
                        rootSchemaName: "Contact"
                    });
                    esq.addColumn("Type");
                     esq.getEntity(this.values.MasterRecordId, function(result) {
                        if (result.success && result.entity.values.Type.displayValue == 'Customer') {
                            this.set("IsAddEnabled", false);
                        }
                    }, this);
			}
		},
		diff: /**SCHEMA_DIFF*/[
			{
				"operation": "merge",
				"name": "AddRecordButton",
				"values": {
					"visible": {"bindTo": "IsAddEnabled"}
				}
			},

Here we are hiding the button if the Type of the Contact = 'Customer'.

Regarding the editing of the detail, if I`m not mistaken, you cannot change it dynamically. 

 

Thanks so much, will take a look on this.

Dmytro Vovchenko,

I tried your code-snippet for this implementation and seems the code not running with editable details. And code triggered only when opening the edit page of detail. 

So on the main page where details exists the Add button still visible :(

Show all comments

Hello Community!

 

I have an on-prem installation of creatio studio compatibility edition version 8.0.9.

I installed the Customer 360 app and created my custom app in the application hub.

The newly created package is specified in the "CurrentPackageId" system setting

 

Now when I click on the gear icon on eg the contact list from the Customer 360 app, creatio creates a new package with a name in the format App_...in my case, it was "QsApp_oyuwyip".

This package has a special manifest file called app-descriptor-extension.json in the file system, which seems to be used to associate the package with the Customer 360 app and to extend it (the new package can be seen in the "advanced settings" part of the Customer 360 app).

 

I can move the ClientModule to my package and if I change it, then create will update it correctly (and not create a new module in the QsApp_oyuwyip package), but if I change something else (like the account page from the Customer 360 app) it will be stored in the QsApp_oyuwyip package again and I'd have to move it again.

 

This "feature" makes it more difficult to deploy the changes to our customer's system. We are using git and Clio in our CI/CD pipeline, which was built with one package to transfer in mind...

Is there a way to force the system to use my custom app/package to store all changes?

 

Thanks,

Robert

Like 7

Like

5 comments
Best reply

Hello,

 

In order to have the changes saved in the application to the desired package, you need to set it in the "Package in installed application" lookup. After doing this, the changes made to this application will be automatically saved in the package you have selected.

 

This behavior is described in the article on our academy for more detailed.



Thank you for your question.

Hello,

 

In order to have the changes saved in the application to the desired package, you need to set it in the "Package in installed application" lookup. After doing this, the changes made to this application will be automatically saved in the package you have selected.

 

This behavior is described in the article on our academy for more detailed.



Thank you for your question.

Would definitely be a good video, feels like a recurring theme :)

I've been told the issue with random packages being selected for a customization to be saved in (and new packages being created) will be improved greatly over the next few versions. 

However, for now, you can control the package it will be saved in by changing the URL when you open a page for edits and appending the query string parameter &packageUId=[Your package UId]. This will force the editor to save the new version of the page in that package. If you want an easy way to get the package UId, simple click the [Add page] button in your application and copy this from the URL then use to add to the URL the first time you edit an existing Freedom UI page to force it to go into your package. Once the page is added to your package after the first save, you'll no longer need to add this to the URL and it will continue to save it to your package. 

For example, the *first* time you edit a page such as Contacts_FormPage, add this to the URL to force it to save into your package. From then on, editing that page will continue to save it to that package.

Ryan

Ryan Farley,



Great tip 🙂

 

Great to hear there is plan to improve handling of the "auto" packages. Also from the marketplace directly in the application hub (only in dev/test instances) also create new empty packages each time since Creatio 8.1 is also quite confusing 😅. Hope they fix that before pushing the feature into production instances.



In the meantime, it would be great for Creatio to provide official proper guidance and tips to manage this.

Hi guys,

Do you have any recent news regarding this matter? I have a new Project and this occurred to me again.

Regards,
Solem

Show all comments