Skip to content

Commit

Permalink
tUpgradeCodeunitJobQueuewaldo
Browse files Browse the repository at this point in the history
  • Loading branch information
waldo1001 committed Dec 19, 2022
1 parent 0f0723f commit 21375f1
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
@@ -1,6 +1,9 @@
# Change Log
All notable changes to the "crs-al-language-extension" extension:

## [1.5.23] - 2022-12-19
- New snippet `tUpgradeCodeunitJobQueuewaldo`: schedule upgrade routine with Job Queue.

## [1.5.22] - 2022-12-05
- Snippet contribution from [christianbraeunlich](https://github.com/christianbraeunlich). Thanks!
- Support for multiple affixes by [pri-kise](https://github.com/pri-kise). Thanks for [the PR](https://github.com/waldo1001/crs-al-language-extension/pull/254)!
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -2,7 +2,7 @@
"name": "crs-al-language-extension",
"displayName": "waldo's CRS AL Language Extension",
"description": "Make working with the (Dynamics NAV / 365) AL Language easier and more efficient.",
"version": "1.5.22",
"version": "1.5.23",
"publisher": "waldo",
"icon": "images/waldo.png",
"author": {
Expand Down
57 changes: 57 additions & 0 deletions snippets/upgrade.json
Expand Up @@ -74,5 +74,62 @@
"end;",
"Move${1:TableExtension}Data(); //Move this to the OnUpgradePer..trigger"
]
},
"Upgrade started from the Job Queue": {
"prefix": "tUpgradeCodeunitJobQueuewaldo",
"description": "Upgrade started from the Job Queue",
"body": [
"codeunit ${1:Id} \"Upgr ${2:MyCodeunit}\"",
"{",
"\tSubtype = Upgrade;",
"",
"\ttrigger OnUpgradePerCompany()",
"\tvar",
"\t\t${2:MyCodeunit}: Codeunit \"DoUpgr ${2:MyCodeunit}\";",
"\tbegin",
"\t\t${2:MyCodeunit}.ScheduleUpgrade();",
"\tend;",
"}",
"",
"codeunit ${3:Id} \"DoUpgr ${2:MyCodeunit}\"",
"{",
" trigger OnRun()",
" var",
" UpgradeTag: Codeunit \"Upgrade Tag\";",
" begin",
" if UpgradeTag.HasUpgradeTag(${4:Reason}Lbl) then exit;",
"",
" PerformUpgrade();",
"",
" UpgradeTag.SetUpgradeTag(${4:Reason}Lbl);",
" end;",
"",
" procedure ScheduleUpgrade() // can be local",
" var",
" JobQueueEntry: Record \"Job Queue Entry\";",
" UpgradeTag: Codeunit \"Upgrade Tag\";",
" RecId: RecordId;",
" begin",
" if UpgradeTag.HasUpgradeTag(${4:Reason}Lbl) then exit;",
"",
" JobQueueEntry.ScheduleJobQueueEntry(Codeunit::\"DoUpgr ${2:MyCodeunit}\", RecId);",
" end;",
"",
" local procedure PerformUpgrade()",
" begin",
" ${0}",
" end;",
"",
" [EventSubscriber(ObjectType::Codeunit, Codeunit::\"Upgrade Tag\", 'OnGetPerCompanyUpgradeTags', '', false, false)]",
" local procedure OnGetPerCompanyUpgradeTags(var PerCompanyUpgradeTags: List of [Code[250]]);",
" begin",
" PerCompanyUpgradeTags.Add(${4:Reason}Lbl);",
" end;",
"",
"",
"\tvar",
"\t\t${4:Reason}Lbl: Label '${5:CompanyName}-${4:Reason}-${CURRENT_YEAR}${CURRENT_MONTH}${CURRENT_DATE}', Locked = true;",
"}"
]
}
}

0 comments on commit 21375f1

Please sign in to comment.