Question

Help with Sandbox, you need the button to be Enabled = false if it's a woman. How to make it so that the code is written correctly and the attribute in ContactPageV2 works



 

define("ContactSectionV2", [], function() {
	return {
		entitySchemaName: "Contact",
		messages: {
			"MessageOnPageClick": {
				mode: Terrasoft.MessageMode.PTP,
				direction: Terrasoft.MessageDirectionType.PUBLISH
			},
			"MessageIsButtonEnabledSubscribe": {
				mode: Terrasoft.MessageMode.BROADCAST,
				direction: Terrasoft.MessageDirectionType.PUBLISH
			},
		attributes: {
			"ButtonEnabled11": {
				"dataValueType": Terrasoft.DataValueType.BOOLEAN,
				"type": Terrasoft.ViewModelColumnType.VIRTUAL_COLUMN,
				dependencies: [
					{
						columns: ["ButtonEnabled"],
						methodName: "getButtonEnabled"
					}
				]
			}
		},
		},
		methods: {
			onEntityInitialized: function() {
				this.callParent(arguments);
				this.getButtonEnabled();
			},
			onSectionClick: function() {
				this.sandbox.publish("MessageOnPageClick", null, ["SectionModuleV2_ContactSectionV2"]);
			},
			getButtonEnabled: function() {
				this.set("ButtonEnabled11", this.sandbox.publish("MessageIsButtonEnabledSubscribe", null, ["SectionModuleV2_ContactSectionV2"]));
			},
		},
		diff: /**SCHEMA_DIFF*/[
			{
				"operation": "insert",
				"parentName": "CombinedModeActionButtonsCardLeftContainer",
				"propertyName": "items",
				"name": "NewButton",
				"values": {
					"itemType": Terrasoft.ViewItemType.BUTTON,
                    "caption": {bindTo: "Resources.Strings.NewButtonCaption"},
                    "classes": {"textClass": "actions-button-margin-right"},
					"click": {bindTo: "onSectionClick"},
					"style": Terrasoft.controls.ButtonEnums.style.RED,
					"enabled": {bindTo: "ButtonEnabled11"}
				}
			}
		]/**SCHEMA_DIFF*/
	};
});
 
define("ContactPageV2", [], function() {
	return {
		entitySchemaName: "Contact",
		attributes: {
			"ButtonEnabled": {
				"dataValueType": Terrasoft.DataValueType.BOOLEAN,
				"type": Terrasoft.ViewModelColumnType.VIRTUAL_COLUMN,
				dependencies: [
					{
						columns: ["Gender"],
						methodName: "setButtonEnabled"
					}
				]
			}
		},
		messages: {
			"MessageOnPageClick": {
				mode: Terrasoft.MessageMode.PTP,
				direction: Terrasoft.MessageDirectionType.SUBSCRIBE
			},
			"MessageIsButtonEnabledSubscribe": {
				mode: Terrasoft.MessageMode.BROADCAST,
				direction: Terrasoft.MessageDirectionType.SUBSCRIBE
			},
		},
		methods: {
			onEntityInitialized: function() {
				this.callParent(arguments);
				this.setButtonEnabled();
				this.sandbox.subscribe("MessageOnPageClick", function() {
					return this.onPageClick();
				}, this, ["SectionModuleV2_ContactSectionV2"]);
			},
			onPageClick: function() {
				this.showInformationDialog(";;;;;;");
			},
			setButtonEnabled: function() {
				var value;
				if (this.get("Gender") != null && this.get("Gender").value == "eeac42ee-65b6-df11-831a-001d60e938c6")  {
					value = true;
					this.set("ButtonEnabled", value);
					this.sandbox.subscribe("MessageIsButtonEnabledSubscribe", value, ["Answer"]);
				}
				else {
                    value = false;
					this.set("ButtonEnabled", value);
					this.sandbox.subscribe("MessageIsButtonEnabledSubscribe", value, ["Answer"]);
				}
			},		
		},
		diff: [{
			"operation": "insert",
			"parentName": "LeftContainer",
			"propertyName": "items",
			"name": "NewButton",
			"values": {
				"itemType": Terrasoft.ViewItemType.BUTTON,
				"caption": { bindTo: "Resources.Strings.CaptionButton" },
				"classes": { "textClass": "actions-button-margin-right" },
				"style": Terrasoft.controls.ButtonEnums.style.BLUE,
				"enabled": {bindTo: "ButtonEnabled"},
				"click": {bindTo: "ButtonEnabled"}
			}
		}] /**SCHEMA_DIFF*/
	};
});

 

Like 0

Like

1 comments

Hi Erlan,

 

Please clarify what exactly in the approach discussed here yesterday doesn't work. Why do you still need sandbox messages in this scenario?

Show all comments

Hi,

 

I would like to add custom buttons to a lookup that opens when clicking on an Action Item in the account section. Autogenerated Page will not meet our requirement as the client just wants a pop-up and do not want to open a whole separate page. I couldn't find a way to add the buttons specific to 1 lookup, hence I created a custom ModalBox as below:

This has 1 field which is a filtered Contact lookup.

On clicking the lens icon, the lookup opens, but the issue is that it lies on top of the existing ModalBox as below:

How can I open it in a separate window and pass the selection to the custom ModalBox?

Any help is appreciated. Thanks!

Like 0

Like

1 comments

Hello,

Thanks for reaching out!

 

I'd suggest checking out a similar post on our Community where you'll find detailed steps on how to set up the functionality you're looking for. It's quite informative and might have just what you need.

 

I hope you'll find the answers to your questions there.

 

Best regards, Pavlo!

Show all comments

Hello Creatio Community,

I'm working on a section featuring two fields: a numeric "Project Number" field and a lookup "Parent Project Number" field. I need to set up a safeguard that prevents users from choosing the same value in both fields. Seeking advice on how to implement this effectively within Creatio's environment.

Appreciate your insights

Like 0

Like

1 comments

Hello,

one of the ways to implement this would be using validation, though you would only see that fields are same during save process. to implement this you'd be replacing code for client schema page where you need this check - specifically code for method asyncValidate - its a method describing validity of page before saving. Examples of using it can be found on community, for example here https://community.creatio.com/questions/use-asyncvalidate-minipage

in method you'd descibe interaction you need - if check thats comparing values of 2 fields (need to take actual value of lookup field to compare it to numeric) and if they match throw 

validationResult.success = false;
and message descibing unsuccessfull validation in validationResult.message
then the save wouldnt happen and user would get a message that you specify
Show all comments

Condition:

The button should be available if the current contact is male (corresponding value for the corresponding field on the contact page). The availability of the button takes into account the change of the field.

Implement button state tracking by binding the "enabled" property of the button to an attribute ("attributes" property) of a Boolean type.

The button should work in combined (combined) mode. This mode is enabled when you open any entry in the section in the current browser tab. In fact, the entry opens on the client schema of the section (in the address bar of the browser, you can see that the client schema is now the Section of the section). To open an entry in client-side page schema mode (the address bar will have a Section Page), either open the section entry in a new browser tab, or open the section entry in the current browser tab and refresh the page.

To implement the data exchange to track the state of the button, you need to use Sandbox.

 

I have a problem, I don't know how to track attribute state in ContactSectionV2 from ContactPageV2 using SandBox? I am unable to control access in ContactSectionV2.

 

define("ContactPageV2", [], function() {
	return {
		entitySchemaName: "Contact",
		attributes: {
			"ButtonEnabled": {
				"dataValueType": Terrasoft.DataValueType.BOOLEAN,
				"type": Terrasoft.ViewModelColumnType.VIRTUAL_COLUMN,
			}
		},
		messages: {
			"MessageOnPageClick": {
				mode: Terrasoft.MessageMode.PTP,
				direction: Terrasoft.MessageDirectionType.SUBSCRIBE
			},
			"MessageIsButtonEnabled": {
				mode: Terrasoft.MessageMode.PTP,
				direction: Terrasoft.MessageDirectionType.SUBSCRIBE
			}
		},
		methods: {
			onEntityInitialized: function() {
				this.callParent(arguments);
				this.setButtonEnabled();
				this.sandbox.subscribe("MessageOnPageClick", function() {
					return this.onPageClick();
				}, this, ["SectionModuleV2_ContactSectionV2"]);
				this.sandbox.subscribe("MessageIsButtonEnabled", function() {
					alert(osfeofksepofkpo);
					return this.setButtonEnabled();
				}, this, ["SectionModuleV2_ContactSectionV2"]);
			},
			onSaved: function() {
				this.callParent(arguments);
				this.setButtonEnabled();
			},
			onPageClick: function() {
				this.showInformationDialog(";;;;;;");
			},
			setButtonEnabled: function() {
				var buttonEnabledValue = this.get("ButtonEnabled");
				if (this.get("Gender") != null && this.get("Gender").value == "eeac42ee-65b6-df11-831a-001d60e938c6") {
					this.set("ButtonEnabled", true);
					this.sandbox.subscribe("MessageIsButtonEnabled", function() {
						alert(true);
						return this.set("ButtonEnabled", true);
					}, this, ["SectionModuleV2_ContactSectionV2"]);
				}
				else {
                    this.set("ButtonEnabled", false);
					this.sandbox.subscribe("MessageIsButtonEnabled", function() {
						alert(false);
						return this.set("ButtonEnabled", false);
					}, this, ["SectionModuleV2_ContactSectionV2"]);
				}
			}
 
		},
		diff: [{
			"operation": "insert",
			"parentName": "LeftContainer",
			"propertyName": "items",
			"name": "NewButton",
			"values": {
				"itemType": Terrasoft.ViewItemType.BUTTON,
				"caption": { bindTo: "Resources.Strings.CaptionButton" },
				"classes": { "textClass": "actions-button-margin-right" },
				"style": Terrasoft.controls.ButtonEnums.style.BLUE,
				"enabled": {bindTo: "ButtonEnabled"},
				"click": {bindTo: "onPageClick"}
			}
		}] /**SCHEMA_DIFF*/
	};
});
 
define("ContactSectionV2", [], function() {
	return {
		entitySchemaName: "Contact",
		messages: {
			"MessageOnPageClick": {
				mode: Terrasoft.MessageMode.PTP,
				direction: Terrasoft.MessageDirectionType.PUBLISH
			},
						"MessageIsButtonEnabled": {
				mode: Terrasoft.MessageMode.PTP,
				direction: Terrasoft.MessageDirectionType.PUBLISH
			}
		},
		methods: {
			onCardRendered: function() {
				this.callParent(arguments);
				this.onSectionButtonEnabled();
			},
			onSectionClick: function() {
				this.sandbox.publish("MessageOnPageClick", null, [this.sandbox.id]);
			},
			onSectionButtonEnabled: function(message) {
				this.sandbox.publish("MessageIsButtonEnabled", null, [this.sandbox.id]);
			}
		},
		diff: /**SCHEMA_DIFF*/[
			{
				"operation": "insert",
				"parentName": "CombinedModeActionButtonsCardLeftContainer",
				"propertyName": "items",
				"name": "NewButton",
				"values": {
					"itemType": Terrasoft.ViewItemType.BUTTON,
                    "caption": {bindTo: "Resources.Strings.NewButtonCaption"},
                    "classes": {"textClass": "actions-button-margin-right"},
					"click": {bindTo: "onSectionClick"},
					"style": Terrasoft.controls.ButtonEnums.style.RED,
					"enabled": {bundTo: "ButtonEnabled"}
				}
			}
		]/**SCHEMA_DIFF*/
	};
});

 

Like 0

Like

4 comments
Best reply

Erlan Ibraev,

 

It will do the needed action, I've tested this code before providing it. The code is added to be used in the combined mode which means that when you open the contact page from the section then the logic from the ContactSectionV2 will be triggered (your initial question).

Should be blocked for women this button

To achieve the result:

 

1) Display the "Gender" column in the section list

2) Replace the code in the ContactSectionV2 with the code attached:

define("ContactSectionV2", [], function() {
	return {
		entitySchemaName: "Contact",
		messages: {},
		attributes: {
			"ButtonEnabled": {
                "dataValueType": Terrasoft.DataValueType.BOOLEAN,
                "type": Terrasoft.ViewModelColumnType.VIRTUAL_COLUMN,
                "value": true
            }
		},
		methods: {
			onCardRendered: function() {
				this.callParent(arguments);
				var gridData = this.get("GridData");
                var activeRow = this.get("ActiveRow");
				if (gridData) {
					if (activeRow) {
						var activeRowData = gridData.get(activeRow);
						var activeRowDataGender = activeRowData.get("Gender");
						if (activeRowDataGender) {
							var enableButton = activeRowDataGender.displayValue !== "Female";
							this.set("ButtonEnabled", enableButton);
						} else {
							this.set("ButtonEnabled", false);
						}
					} 
				}
			},
		},
		diff: /**SCHEMA_DIFF*/[
			{
				"operation": "insert",
				"parentName": "CombinedModeActionButtonsCardLeftContainer",
				"propertyName": "items",
				"name": "NewButton",
				"values": {
					"itemType": Terrasoft.ViewItemType.BUTTON,
                    "caption": {bindTo: "Resources.Strings.NewButtonCaption"},
                    "classes": {"textClass": "actions-button-margin-right"},
					"click": {bindTo: "onSectionClick"},
					"style": Terrasoft.controls.ButtonEnums.style.RED,
					"enabled": {bindTo: "ButtonEnabled"}
				}
			}
		]/**SCHEMA_DIFF*/
	};
});

This will make the button to be enabled only in case gender of the current contact is "Male" and will be disabled in case gender of the current contact is "Female" or empty.

Олег Дробина,

 

But I need Enabled to depend on an attribute which is in ContactPageV2

Erlan Ibraev,

 

It will do the needed action, I've tested this code before providing it. The code is added to be used in the combined mode which means that when you open the contact page from the section then the logic from the ContactSectionV2 will be triggered (your initial question).

Show all comments

Hi Community,

 

We have this functionality that we are subscribing to message on load of record page. How we can unsubscribe once we close/cancel/discard the record page.



Below is the code how we subscribe during record on load.



    init: function() {

                this.callParent(arguments);

                this.subscriptionFunction();

                

            },

            

            subscriptionFunction: function() {

                Terrasoft.ServerChannel.on(Terrasoft.EventName.ON_MESSAGE,

                this.onMyProcessMessage, this);

            },

Like 0

Like

2 comments

To unsubscribe from the message when the page is closed/canceled/etc, add the following: 

destroy: function() {
    Terrasoft.ServerChannel.un(Terrasoft.EventName.ON_MESSAGE, this.onMyProcessMessage, this);
    this.callParent(arguments);
}

Ryan

Ryan Farley,

Thank you Ryan.

Show all comments

When open edit card, functional(visual and js) doesn't working and in console next error's:



 file: https://dogarray.com/core/hash/ng-core/src/polyfills-es5.js?hash=41f4be…

 line: 1

 column: 16702

 message: Uncaught Terrasoft.ItemNotFoundException: Property Ext is not defined in class Terrasoft.model.BaseViewModel 




*Helping out re-create edit page, but I don't like this way

Like 0

Like

1 comments

Hello,



Could you please specify how did you create this section\edit page?

 

Show all comments
Question

Hello, im trying to migrate a package to a new project, but i cant upload my files since the configuration is not available and I have not found a way to activate it.



I had tried to use the tutorial in creatio academy but is still confuse for me. 



Like 0

Like

1 comments

Hi Community,

 

We have two email address configured to create record in case via the out of the box functionality "register case from incoming emails". As per the OOB structure how we will identify the source email address of the created case record, as both of the emails are configured under supervisor.

 

  

Like 0

Like

1 comments

I assume what you're after is the mailbox that received the email that the case was created from. Correct? You can determine the mailbox that the case was created from by doing the following:

  1. Read Case to get "Parent activity" column. This is the email that created the case.
  2. Read from "Email message" where Activity = Parent Activity from the Case. This will give you the MailboxSyncSettings that the email is from as one of the columns. The MailboxSyncSettings record is the email account that received the email.
  3. Read the MailboxSyncSettings record returned from #2 to get the details about the mailbox that the email was received from.

Ryan

Show all comments

Hi, everybody!

 

Given:

There is a detail with an editable grid

It is necessary to apply some filter to the records of the part reference field, but only if there are no records in another part (OrderProduct object) (for a specific Order)

Solution attempt:

An attribute with lookup List Config has been added to the details page:

<br />
      "PrbProduct": {<br />
        "dataValueType": Terrasoft.DataValueType.LOOKUP,<br />
        "lookupListConfig": {<br />
          "filters": [<br />
            function() {<br />
              var subFilterGroup = this.Terrasoft.createFilterGroup();<br />
              subFilterGroup.addItem(this.Terrasoft.createColumnFilterWithParameter(this.Terrasoft.ComparisonType.EQUAL, "Order", this.$PrbOrder.value));<br />
              var filterGroup = this.Terrasoft.createFilterGroup();<br />
              filterGroup.logicalOperation = this.Terrasoft.LogicalOperatorType.OR;<br />
              filterGroup.addItem(this.Terrasoft.createNotExistsFilter("[OrderProduct].Id", subFilterGroup));<br />
              filterGroup.addItem(this.Terrasoft.createColumnFilterWithParameter("PrbOrder", this.$PrbOrder.value));<br />
              return filterGroup;<br />
            }<br />
          ]<br />
        }<br />
      },<br />

 

Problem:

It is not possible to find the correct path to the column in create Not Exists Filter. Or there is an error like "Column on the path [Order Product].Id was not found in the "Product" schema, or (with some other values) the filter does not work as needed.

Tell me, please, is it even possible to create Not Exists Filter/createExistsFilter without binding to the detail object?

How to correctly specify the "path to the column" in this case?

Like 0

Like

4 comments
Best reply

Fariz Mamedov,

 

Just open the console in browser (F12 in Chrome) and go to the "Network" tab. And then find the correspondent SelectQuery request and review its body:

Hello Fariz,

 

The task is to create a filter starting from the object of the lookup column for which we are creating the lookupListConfig. The easiest way to properly build path to the needed column is creating the same filter, but using advanced filters in the section. This will result in the SelectQuery request where filters can be reviewed and the content of the filter copied which will show you an accurate path to the column needed.

Oleg Drobina,

Thank you! Interesting trick.

Please, provide details about: "This will result in the SelectQuery request where filters can be reviewed" - how exactly I can review such a request? 

Fariz Mamedov,

 

Just open the console in browser (F12 in Chrome) and go to the "Network" tab. And then find the correspondent SelectQuery request and review its body:

Oleg Drobina, Super thx!

Show all comments

Hello,

 

I am trying to add a new record in a detail inside to another one. The + button is missing even the object permission are configured for this role. (attach Creatio1.png)

 

When I change the detail with option "Make the list editable"  (attach Creatio2.png), the button is shown but the business rules and filters are not applied.  (attach Creatio3.png)

 

Any idea how to fix this issue?

Like 0

Like

4 comments
Best reply

Hello Denisa,

 

I would be happy to provide you with additional information regarding the database connections for the detail in question.

The detail must be connected to the SysModuleEntity record, which was added to the portal (SysModuleEntityInPortal table) to display for portal users.

Also, the detail must be connected to the SysModuleEntity record with no connection to the portal setting (SysModuleEntityInPortal table) to display for system users.



You have to create separate records  for details in the SysModuleEntity table:



1. The required connections for system users:

SysModuleEntity (Id column) - SysModuleEdit (SysModuleEntityId column).

2. The required connections for portal users :

SysModuleEntityInPortal (SysModuleEntityId column) - SysModuleEntity (Id column) - SysModuleEdit (SysModuleEntityId column).

 

By confirming the presence of these connections, you can ensure that the detail is properly configured to be displayed for both system users and portal users.

 

Best regards,

Kate

Hello!

 

It seems that you use the same detail for the main and portal page. To resolve the current issue, we recommend creating a separate detail for the portal page.

Here are the steps you can follow:

1) Go to the portal master wizard for your section.

2) Remove the existing detail from the portal edit page.

3) Create and add a new detail specifically designed for portal users in the detail section wizard, based on the existing object.

4) Add the new detail to the portal page.

5) Make sure to save the changes.

 

By creating a separate detail for the portal page, you can ensure that the issue you are experiencing is addressed and the users have the appropriate functionality.

 

Best regards,

Kate

Kate Karpik,

Hello Kate,

 

Thank you for your response. Your steps seems to be ok if the detail is related with section, because you have the possibility to have two section pages for full and portal and then relate full/portal detail schema in each page.

 

The issue I'm facing is with detail inside the detail. The system create only one page for the parent detail and if you have another detail inside the first one, even if you create two different details, the page of the parent detail is only one so the cardschema is the same for both full/portal of the child detail and the parent detail page is related only with one of them

Hello Denisa,

 

I would be happy to provide you with additional information regarding the database connections for the detail in question.

The detail must be connected to the SysModuleEntity record, which was added to the portal (SysModuleEntityInPortal table) to display for portal users.

Also, the detail must be connected to the SysModuleEntity record with no connection to the portal setting (SysModuleEntityInPortal table) to display for system users.



You have to create separate records  for details in the SysModuleEntity table:



1. The required connections for system users:

SysModuleEntity (Id column) - SysModuleEdit (SysModuleEntityId column).

2. The required connections for portal users :

SysModuleEntityInPortal (SysModuleEntityId column) - SysModuleEntity (Id column) - SysModuleEdit (SysModuleEntityId column).

 

By confirming the presence of these connections, you can ensure that the detail is properly configured to be displayed for both system users and portal users.

 

Best regards,

Kate

Kate Karpik,

 

Thanks for the detailed explanation, it worked out:)

 

The code in case that someone has the same issue:

-- 1. (Manual input) Change caption: with the caption of the new entity related with new detail
-- In my case the new object, the page and both details (full/portal) begin with ne same contain same caption. 
DECLARE @Caption as varchar(200) = 'Loan proposed terms and condition'
 
--2. (Manual input) Change Name: with the Name of the Parent Page of new detail 
DECLARE @CardSchemaUId uniqueidentifier = (
	SELECT	UId 
	FROM	SysSchema 
	WHERE	Name='FZSchema584f510ePage' 
)
-- 3. (Automatic) Get Uid of entityschema related to new detail
DECLARE @SysEntitySchemaUId uniqueidentifier = ( 
	SELECT	TOP 1 UId 
	FROM	dbo.SysSchema 
	WHERE	Caption like '%' + @Caption +'%' and ManagerName = 'EntitySchemaManager' 
)
 
-- 4. (Automatic) Insert if not exist on SysModuleEntityInPortal
INSERT INTO [dbo].[SysModuleEntityInPortal] ([Id], [CreatedOn], [CreatedById], [ModifiedOn], [ModifiedById], [ProcessListeners], [SysPortalId], [SysModuleEntityId])
SELECT	[Id] = NEWID(), [CreatedOn] = getDate(), [CreatedById]=CreatedById, [ModifiedOn] = getDate(), [ModifiedById]= CreatedById, [ProcessListeners]=0, 
		[SysPortalId] = 'C8565240-1DA3-4A68-BD4E-280F17B0D32E', [SysModuleEntityId] = SysModuleEntity.Id
FROM	(
			SELECT	id, [CreatedById], SysEntitySchemaUId
			FROM	dbo.SysModuleEntity
			WHERE	SysEntitySchemaUId = @SysEntitySchemaUId
		) SysModuleEntity		
		OUTER APPLY (
			SELECT	count (1) AS NR
			FROM	dbo.SysModuleEntityInPortal scp
					INNER JOIN dbo.SysModuleEntity sm ON scp.SysModuleEntityId = sm.Id
			WHERE	sm.SysEntitySchemaUId = @SysEntitySchemaUId
		) InSysPortal
WHERE	InSysPortal.NR IS NULL OR InSysPortal.NR = 0
 
-- 5. (Automatic) Insert if not exist on SysDetail
INSERT INTO [dbo].[SysDetail] ([Id], [CreatedOn], [CreatedById], [ModifiedOn], [ModifiedById], [ProcessListeners], [Caption], [DetailSchemaUId], [EntitySchemaUId])
SELECT	[Id] = NEWID(), [CreatedOn]= getDate(), [CreatedById], [ModifiedOn]= getDate(), [ModifiedById], [ProcessListeners], 
		[Caption] = SysSchema.Caption, [DetailSchemaUId] = SysSchema.Uid, [EntitySchemaUId] = @SysEntitySchemaUId
FROM	dbo.SysSchema 
WHERE	Caption like '%' + @Caption +'%' AND [Name] like '%Detail' AND ManagerName ='ClientUnitSchemaManager'
		AND Uid not in (Select [DetailSchemaUId] from SysDetail)
 
-- 6. (Automatic) Insert if not exist on SspPageDetail
INSERT INTO [dbo].[SspPageDetail] ([Id], [CreatedOn], [CreatedById], [ModifiedOn], [ModifiedById], [ProcessListeners], [CardSchemaUId], [EntitySchemaUId], [SysDetailId])
Select	[Id] = NEWID(), [CreatedOn]= getDate(), [CreatedById], [ModifiedOn]= getDate(), [ModifiedById], [ProcessListeners], 
		[CardSchemaUId] = @CardSchemaUId, [EntitySchemaUId] = SysDetail.EntitySchemaUId, [SysDetailId] = SysDetail.Id
FROM	SysDetail 
WHERE	EntitySchemaUId=@SysEntitySchemaUId and Caption like '%portal%'
		and Id not in ( Select SysDetailId FROM SspPageDetail )
 
-- 7. (Automatic) Insert if not exist on SysModuleEntity
INSERT INTO [dbo].[SysModuleEntity] ([Id], [CreatedOn], [CreatedById], [ModifiedOn], [ModifiedById], [TypeColumnUId], [ProcessListeners], [SysEntitySchemaUId])
SELECT	[Id] = NEWID(), [CreatedOn]= getDate(), [CreatedById], [ModifiedOn]= getDate(), [ModifiedById], [TypeColumnUId], [ProcessListeners], [SysEntitySchemaUId]
FROM	dbo.SysModuleEntity
WHERE	SysEntitySchemaUId = @SysEntitySchemaUId AND 
		(
			SELECT	count (1) 
			FROM	dbo.SysModuleEntity
			WHERE	SysEntitySchemaUId = @SysEntitySchemaUId
		) &lt; 2
 
-- 8. (Automatic) Insert if not exist on SysModuleEdit also the new recored that was insertet on previos step
INSERT INTO [dbo].[SysModuleEdit] ([Id], [CreatedOn], [CreatedById], [ModifiedOn], [ModifiedById], [SysModuleEntityId], [TypeColumnValue], [UseModuleDetails], [Position], [HelpContextId], [ProcessListeners], [SysPageSchemaUId], [CardSchemaUId], [ActionKindCaption], [ActionKindName], [PageCaption], [MiniPageSchemaUId], [SearchRowSchemaUId], [MiniPageModes])
SELECT	TOP 1 [Id] = NEWID(), [CreatedOn] = getDate(), [CreatedById], [ModifiedOn] = getDate(), [ModifiedById], 
		[SysModuleEntityId] = new.SysModuleEntityId, [TypeColumnValue], [UseModuleDetails], [Position], [HelpContextId], [ProcessListeners]=0, [SysPageSchemaUId], [CardSchemaUId], [ActionKindCaption], [ActionKindName], [PageCaption], [MiniPageSchemaUId], [SearchRowSchemaUId], [MiniPageModes]
FROM	SysModuleEdit ref
		CROSS JOIN (
			SELECT	s.id as SysModuleEntityId
			FROM	SysModuleEntity s
					LEFT JOIN SysModuleEdit t On t.SysModuleEntityId = s.Id 
			WHERE	SysEntitySchemaUId = @SysEntitySchemaUId AND t.id IS NULL
		) new 
WHERE	ref.SysModuleEntityId in (
			SELECT	id
			FROM	dbo.SysModuleEntity
			WHERE	SysEntitySchemaUId = @SysEntitySchemaUId
		)

 

Show all comments