# How-to-fix-Dev2Prod-failure_688988351
## Symptom

If you have created two identical custom actions for the same record type in both source and target tenants, the Dev2Prod process fails. The error messages are as follows:

```
> Customization1 Metadata element <entity_type>.CustomActionName_c.Localized Label Key is invalid.
> Update of existing element descriptor's attributes is not available through customization. Refer to: Customization1.
>
> Customization1 Metadata element <entity_type>.CustomActionName_c.Tooltip Localized Label Key is invalid.
Update of existing element descriptor's attributes is not available through customization. Refer to: Customization1.
>
> Customization1 Metadata element <entity_type>.CustomActionName_c.Placeholder Localized Label Key is invalid.
> Update of existing element descriptor's attributes is not available through customization. Refer to: Customization1.
>
> Customization1 Metadata element EntityType.CustomActionCount_c.Localized Label Key is invalid.
> Update of existing element descriptor's attributes is not available through customization. Refer to: Customization1.
>
> Customization1 Metadata element <entity_type>.CustomActionCount_c.Tooltip Localized Label Key is invalid.
> Update of existing element descriptor's attributes is not available through customization. Refer to: Customization1.
>
> Customization1 Metadata element EntityType.CustomActionCount_c.Placeholder Localized Label Key is invalid.
> Update of existing element descriptor's attributes is not available through customization. Refer to: Customization1.
```

## Resolution

This resolution applies to SMAX versions from 2023.05 to 24.1.

**Note:** For example, the verion number is \*\*\\<version\\>\*\*, export from \*\*\\<dev\_tenant\\>\*\* and import into \*\*\\<prod\_tenant\\>\*\*, the related entities are \*\*\\<entity\_type1\\>\*\* and \*\*\\<entity\_type2\\>\*\*.

Step 1. Choose \*\*xservices-ems\*\*, execute the following queries on both <dev\_tenant> and <prod\_tenant>, and keep the results for later steps.

Step 1.1. Run the following command:

```
\`\`\`SQL
SELECT
    ed.tenant_id AS "version",
    pd.tenant_id,
    pd.parent_descriptor_id AS entity_type_id,
    ed."name" AS entity_name,
    pd."name" AS field_name,
    pd.localization_key,
    ed."name" || '.' || pd."name" || '.localized-label-key' as localization_key_new
FROM
    property_descriptor pd
    LEFT JOIN entity_descriptor ed ON pd.parent_descriptor_id = ed.id
WHERE
    pd."name" IN ('CustomActionName_c', 'CustomActionCount_c')
    AND ed.tenant_id = '<version>'
    AND pd.tenant_id IN ('<dev_tenant>', '<prod_tenant>')
    AND ed."name" IN ('<entity_type1>', '<entity_type2>');
\`\`\`
```

For example, in the following case, \\<version\\> is "v26", <dev\_tenant> is "100000001", <prod\_tenant> is "100000002", <entity\_type1> is "Request", <entity\_type2> is "Incident". The script would be:

```
\`\`\`SQL
SELECT
    ed.tenant_id AS "version",
    pd.tenant_id,
    pd.parent_descriptor_id AS entity_type_id,
    ed."name" AS entity_name,
    pd."name" AS field_name,
    pd.localization_key,
    ed."name" || '.' || pd."name" || '.localized-label-key' as localization_key_new
FROM
    property_descriptor pd
    LEFT JOIN entity_descriptor ed ON pd.parent_descriptor_id = ed.id
WHERE
    pd."name" IN ('CustomActionName_c', 'CustomActionCount_c')
    AND ed.tenant_id = 'v26'
    AND pd.tenant_id IN ('100000001', '100000002')
    AND ed."name" IN ('Request', 'Incident');
\`\`\`
```

The output would be:

```
table1
| version | tenant_id | entity_type_id | entity_name | field_name          | localization_key                    | localization_key_new                             |
| ------- | --------- | -------------- | ----------- | ------------------- | ----------------------------------- | ------------------------------------------------ |
| v26     | 100000001 | 247            | Incident    | CustomActionCount_c | CustomActionCount_c_1710482969177_c | Incident.CustomActionCount_c.localized-label-key |
| v26     | 100000001 | 247            | Incident    | CustomActionName_c  | CustomActionName_c_1710482969053_c  | Incident.CustomActionName_c.localized-label-key  |
| v26     | 100000001 | 375            | Request     | CustomActionCount_c | CustomActionCount_c_1710482749123_c | Request.CustomActionCount_c.localized-label-key  |
| v26     | 100000001 | 375            | Request     | CustomActionName_c  | CustomActionName_c_1710482749001_c  | Request.CustomActionName_c.localized-label-key   |
| v26     | 100000002 | 247            | Incident    | CustomActionCount_c | CustomActionCount_c_1710482925908_c | Incident.CustomActionCount_c.localized-label-key |
| v26     | 100000002 | 247            | Incident    | CustomActionName_c  | CustomActionName_c_1710482925779_c  | Incident.CustomActionName_c.localized-label-key  |
| v26     | 100000002 | 375            | Request     | CustomActionCount_c | CustomActionCount_c_1710482721555_c | Request.CustomActionCount_c.localized-label-key  |
| v26     | 100000002 | 375            | Request     | CustomActionName_c  | CustomActionName_c_1710482721392_c  | Request.CustomActionName_c.localized-label-key   |
```

Step 1.2. Run the following command:

```
\`\`\`SQL
SELECT
    tenant_id,
    property_descriptor_name, 
    entity_descriptor_name, 
    placeholder_key,
    entity_descriptor_name || '.' || property_descriptor_name || '.placeholder' AS placeholder_key_new,
    tooltip_key,
    entity_descriptor_name || '.' || property_descriptor_name || '.tooltip' AS tooltip_key_new
FROM 
    property_descriptor_ui 
WHERE 
    property_descriptor_name IN ('CustomActionName_c', 'CustomActionCount_c')
    AND tenant_id IN ('<dev_tenant>', '<prod_tenant>')
    AND entity_descriptor_name IN ('<entity_type1>', '<entity_type2>');
\`\`\`
```

In our case, the script would be:

```
\`\`\`SQL
SELECT
    tenant_id,
    property_descriptor_name, 
    entity_descriptor_name, 
    placeholder_key,
    entity_descriptor_name || '.' || property_descriptor_name || '.placeholder' AS placeholder_key_new,
    tooltip_key,
    entity_descriptor_name || '.' || property_descriptor_name || '.tooltip' AS tooltip_key_new
FROM 
    property_descriptor_ui 
WHERE 
    property_descriptor_name IN ('CustomActionName_c', 'CustomActionCount_c')
    AND tenant_id IN ('100000001', '100000002')
    AND entity_descriptor_name IN ('Request', 'Incident');
\`\`\`
table2
| tenant_id | property_descriptor_name | entity_descriptor_name | placeholder_key                                 | placeholder_key_new                      | tooltip_key                                 | tooltip_key_new                      |
| --------- | ------------------------ | ---------------------- | ----------------------------------------------- | ---------------------------------------- | ------------------------------------------- | ------------------------------------ |
| 100000001 | CustomActionCount_c      | Incident               | CustomActionCount_c_PLACEHOLDER_1710482969177_c | Incident.CustomActionCount_c.placeholder | CustomActionCount_c_TOOLTIP_1710482969177_c | Incident.CustomActionCount_c.tooltip |
| 100000001 | CustomActionCount_c      | Request                | CustomActionCount_c_PLACEHOLDER_1710482749123_c | Request.CustomActionCount_c.placeholder  | CustomActionCount_c_TOOLTIP_1710482749123_c | Request.CustomActionCount_c.tooltip  |
| 100000001 | CustomActionName_c       | Incident               | CustomActionName_c_PLACEHOLDER_1710482969053_c  | Incident.CustomActionName_c.placeholder  | CustomActionName_c_TOOLTIP_1710482969053_c  | Incident.CustomActionName_c.tooltip  |
| 100000001 | CustomActionName_c       | Request                | CustomActionName_c_PLACEHOLDER_1710482749001_c  | Request.CustomActionName_c.placeholder   | CustomActionName_c_TOOLTIP_1710482749001_c  | Request.CustomActionName_c.tooltip   |
| 100000002 | CustomActionCount_c      | Incident               | CustomActionCount_c_PLACEHOLDER_1710482925908_c | Incident.CustomActionCount_c.placeholder | CustomActionCount_c_TOOLTIP_1710482925908_c | Incident.CustomActionCount_c.tooltip |
| 100000002 | CustomActionCount_c      | Request                | CustomActionCount_c_PLACEHOLDER_1710482721555_c | Request.CustomActionCount_c.placeholder  | CustomActionCount_c_TOOLTIP_1710482721555_c | Request.CustomActionCount_c.tooltip  |
| 100000002 | CustomActionName_c       | Incident               | CustomActionName_c_PLACEHOLDER_1710482925779_c  | Incident.CustomActionName_c.placeholder  | CustomActionName_c_TOOLTIP_1710482925779_c  | Incident.CustomActionName_c.tooltip  |
| 100000002 | CustomActionName_c       | Request                | CustomActionName_c_PLACEHOLDER_1710482721392_c  | Request.CustomActionName_c.placeholder   | CustomActionName_c_TOOLTIP_1710482721392_c  | Request.CustomActionName_c.tooltip   |
```

Step 2. Choose \*\*xservices-rms\*\*, update all <localization\_key> with <localization\_key\_new>, all <placeholder\_key> with <placeholder\_key\_new> and all <tooltip\_key> with <tooltip\_key\_new> both on <dev\_tenant> and <prod\_tenant> based on \*\*"table1"\*\* and \*\*"table2"\*\*.

```
\`\`\`SQL
UPDATE 
    "ResourceBundle_<tenant>" 
SET 
    body = jsonb_set(body, '{Key}', '"<localization_key_new>"')
WHERE 
    body->>'Key' = '<localization_key>';

UPDATE 
    "ResourceBundle_<tenant>" 
SET 
    body = jsonb_set(body, '{Key}', '"<placeholder_key_new>"')
WHERE 
    body->>'Key' = '<placeholder_key>';

UPDATE 
    "ResourceBundle_<tenant>" 
SET 
    body = jsonb_set(body, '{Key}', '"<tooltip_key_new>"')
WHERE 
    body->>'Key' = '<tooltip_key>';
\`\`\`
```

In our case, it would be：

```
\`\`\`SQL
UPDATE 
    "ResourceBundle_100000001" 
SET 
    body = jsonb_set(body, '{Key}', '"Incident.CustomActionCount_c.localized-label-key"')
WHERE 
    body->>'Key' = 'CustomActionCount_c_1710482969177_c';
......
UPDATE 
    "ResourceBundle_100000002" 
SET 
    body = jsonb_set(body, '{Key}', '"Request.CustomActionName_c.localized-label-key"')
WHERE 
    body->>'Key' = 'CustomActionName_c_1710482721392_c';

UPDATE 
    "ResourceBundle_100000001" 
SET 
    body = jsonb_set(body, '{Key}', '"Incident.CustomActionCount_c.placeholder"')
WHERE 
    body->>'Key' = 'CustomActionCount_c_PLACEHOLDER_1710482969177_c';

UPDATE 
    "ResourceBundle_100000001" 
SET 
    body = jsonb_set(body, '{Key}', '"Incident.CustomActionCount_c.tooltip"')
WHERE 
    body->>'Key' = 'CustomActionCount_c_TOOLTIP_1710482969177_c';
......

UPDATE 
    "ResourceBundle_100000002" 
SET 
    body = jsonb_set(body, '{Key}', '"Request.CustomActionName_c.placeholder"')
WHERE 
    body->>'Key' = 'CustomActionName_c_PLACEHOLDER_1710482721392_c';

UPDATE 
    "ResourceBundle_100000002" 
SET 
    body = jsonb_set(body, '{Key}', '"Request.CustomActionName_c.tooltip"')
WHERE 
    body->>'Key' = 'CustomActionName_c_TOOLTIP_1710482721392_c';
\`\`\`
```

Step 3. Choose \*\*xservices-ems\*\*, execute the following updates on both <dev\_tenant> and <prod\_tenant>.

```
\`\`\`SQL
UPDATE
    property_descriptor pd
SET
    localization_key = ed."name" || '.' || pd."name" || '.localized-label-key',
    flavors = 'EMS'
FROM
    entity_descriptor ed
WHERE
    pd.parent_descriptor_id = ed.id
    AND pd."name" IN ('CustomActionCount_c', 'CustomActionName_c')
    AND ed.tenant_id = '<version>'
    AND pd.tenant_id IN ('<dev_tenant>', '<prod_tenant>')
    AND ed."name" IN ('<entity_type1>', '<entity_type2>');

UPDATE
    property_descriptor_ui
SET
    placeholder_key = entity_descriptor_name || '.' || property_descriptor_name || '.placeholder',
    tooltip_key = entity_descriptor_name || '.' || property_descriptor_name || '.tooltip'
WHERE
    property_descriptor_name IN ('CustomActionCount_c', 'CustomActionName_c')
    AND tenant_id IN ('<dev_tenant>', '<prod_tenant>')
    AND entity_descriptor_name IN ('<entity_type1>', '<entity_type2>');
\`\`\`
```

In our case, it would be:

```
\`\`\`SQL
UPDATE
    property_descriptor pd
SET
    localization_key = ed."name" || '.' || pd."name" || '.localized-label-key',
    flavors = 'EMS'
FROM
    entity_descriptor ed
WHERE
    pd.parent_descriptor_id = ed.id
    AND pd."name" IN ('CustomActionCount_c', 'CustomActionName_c')
    AND ed.tenant_id = 'v26'
    AND pd.tenant_id IN ('100000001', '100000002')
    AND ed."name" IN ('Request', 'Incident');

UPDATE
    property_descriptor_ui
SET
    placeholder_key = entity_descriptor_name || '.' || property_descriptor_name || '.placeholder',
    tooltip_key = entity_descriptor_name || '.' || property_descriptor_name || '.tooltip'
WHERE
    property_descriptor_name IN ('CustomActionCount_c', 'CustomActionName_c')
    AND tenant_id IN ('100000001', '100000002')
    AND entity_descriptor_name IN ('Request', 'Incident');
\`\`\`
```

Step 4. It is recommended to restart the platform where the modified tenant is located:

```
\`\`\`sh
kubectl rollout restart deployment itom-xruntime-platform -n itsma-xxxxx
\`\`\`
```

Step 5. Redo the export and import operations.
