Skip to content

Commit

Permalink
SQL_ObjectTemplates_WithMissingLocalization (#144)
Browse files Browse the repository at this point in the history
Co-authored-by: Kubilay <khusmeno@khusmeno.com>
  • Loading branch information
khusmeno and Kubilay authored Mar 19, 2024
1 parent 4870e4d commit acb068b
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -610,9 +610,29 @@ order by 5 desc
'@

$SQL_SCSM_MS['SQL_ObjectTemplates_WithMissingLocalizations']=@'
--show Templates which do not have any localized string which would cause Connector (e.g. Exchange Connector) Wizard to crash (Bug 936430)
select * from ObjectTemplate ot
where not exists (select * from LocalizedText lt where ot.ObjectTemplateId = lt.LTStringId and LTStringType=1)
--show IR,SR Templates which do not have any localized string and would therefore cause the Exchange Connector Wizard to crash (Bug 936430)
select
ObjectTemplateName as "Template Name to be edited"
, ltMT.LTValue as BasedOnClass_DisplayName_ENU, ot.ManagementPackId
from ObjectTemplate ot
left join TypeProjection tp on ot.ObjectTemplateTypeId=tp.TypeProjectionId
left join ManagedType mt on TypeProjectionSeed=mt.ManagedTypeId
left join LocalizedText lt on ot.ObjectTemplateId = lt.LTStringId and lt.LTStringType=1 and lt.LanguageCode='ENU'
left join LocalizedText ltMT on mt.ManagedTypeId = ltMT.LTStringId and ltMT.LTStringType=1 and ltMT.LanguageCode='ENU'
left join LocalizedText ltTP on tp.TypeProjectionId = ltTP.LTStringId and ltTP.LTStringType=1 and ltTP.LanguageCode='ENU'
where lt.ltvalue is null
and mt.TypeName in ('System.WorkItem.Incident','System.WorkItem.ServiceRequest')
union all
select
ObjectTemplateName as Template_Name, ltMT.LTValue as BasedOnClass_DisplayName_ENU, ot.ManagementPackId
from ObjectTemplate ot
inner join ManagedType mt on ot.ObjectTemplateTypeId=mt.ManagedTypeId
left join LocalizedText lt on ot.ObjectTemplateId = lt.LTStringId and lt.LTStringType=1 and lt.LanguageCode='ENU'
left join LocalizedText ltMT on mt.ManagedTypeId = ltMT.LTStringId and ltMT.LTStringType=1 and ltMT.LanguageCode='ENU'
where ot.ObjectTemplateTypeId != '0814D9A7-8332-A5DF-2EC8-34D07F3D40DB' -- != System.Notification.Template.SMTP
and lt.ltvalue is null
and mt.TypeName in ('System.WorkItem.Incident','System.WorkItem.ServiceRequest')
order by 1
'@

$SQL_SCSM_MS['SQL_fn_GetEntityChangeLogGroomingWatermark']=@'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
function Check_ObjectTemplates_WithNoLocalizations() {

$dataRow = GetEmptyResultRow
$dataRow.RuleName="Templates with no localizations"
$dataRow.RuleName="IR and SR Templates with no localizations"
$dataRow.RuleDesc=@"
This rule checks if Templates exist that do not have any localized string. This would cause Connector (e.g. Exchange Connector) Wizard to crash the Console (bug 936430).
This rule checks if Templates (only if based on Incident or Service Request) exist that do not have any localized Name or Description value. This would crash the Console (bug 936430) when attempting to create a new Exchange Connector or when opening an existing one.
"@
$dataRow.RuleResult="No such templates found."
$dataRow.SAPCategories = "Console"
$dataRow.ProblemSeverity=[ProblemSeverity]::Error

$connectors = ConvertFrom-Csv (GetSanitizedCsv (GetFileContentInSourceFolder SQL_Connectors.csv) )
$exchangeConnectors = $connectors | ? { $_.'Data Provider Name' -eq "Exchange Connector"}
if ($exchangeConnectors.Count -eq 0) {
$dataRow.ProblemSeverity=[ProblemSeverity]::Warning
}
else {
$dataRow.ProblemSeverity=[ProblemSeverity]::Error
}

$linesIn_SQL_ObjectTemplates_WithMissingLocalizations = ConvertFrom-Csv (GetSanitizedCsv ( GetFileContentInSourceFolder SQL_ObjectTemplates_WithMissingLocalizations.csv ) )

Expand All @@ -16,8 +24,23 @@ This rule checks if Templates exist that do not have any localized string. This
}
else {
$dataRow.RuleResult = @"
Looks like problematic templates found. Please check in $(CollectorLink SQL_ObjectTemplates_WithMissingLocalizations.csv). $(IgnoreRuleIfText) no Exchange Connector exists. However, it is strongly suggested to add localized string values to these templates to avoid problems in the future.
Looks like problematic templates found. To resolve this issue, please do the following steps:
<br/> 1. Open $(CollectorLink SQL_ObjectTemplates_WithMissingLocalizations.csv).
<br/> 2. Copy the value of the 1st column "Template Name to be edited".
<br/> 3. Open the SM console and navigate to Library/Templates.
<br/> 4. Find/Filter the template (like "Template.59d3859b0aca4bd0aec5f64e3b6059e2") and click Properties.
<br/> 5. Make a modification in the Name or Description fields.
<br/> 6. Uncheck the "When I click OK, open the template form" checkbox at the very end. Don't worry if you forget to uncheck.
<br/> 7. Click the OK button.
<br/> Repeat steps 2-7 for each row in $(CollectorLink SQL_ObjectTemplates_WithMissingLocalizations.csv).
"@

if ($exchangeConnectors.Count -eq 0) {
$dataRow.RuleResult += @"
<br/>
<br/> $(IgnoreRuleIfText) you do not plan to create an Exchange Connector. However, it is strongly recommended to do the steps mentioned above, in order to avoid problems in the future.
"@
}
$Result_Problems += $dataRow
}
}

0 comments on commit acb068b

Please sign in to comment.