-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix for Document Exists issue and DataRaptor Mappings out of order
- Loading branch information
Adam Rutland
committed
Jun 13, 2022
1 parent
863bbed
commit b370b34
Showing
7 changed files
with
502 additions
and
10 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
DataPackSettings/latest/DataRaptor/DataRaptor-Migration/DataRaptor-Migration_DataPack.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
{ | ||
"%vlocity_namespace%__BatchSize__c": 200, | ||
"%vlocity_namespace%__CheckFieldLevelSecurity__c": false, | ||
"%vlocity_namespace%__CustomInputClass__c": "", | ||
"%vlocity_namespace%__CustomOutputClass__c": "", | ||
"%vlocity_namespace%__DRMapItem__c": "DataRaptor-Migration_Mappings.json", | ||
"%vlocity_namespace%__DRMapName__c": "DataRaptor Migration", | ||
"%vlocity_namespace%__DeleteOnSuccess__c": false, | ||
"%vlocity_namespace%__Description__c": "", | ||
"%vlocity_namespace%__GlobalKey__c": "DataRaptor Migration", | ||
"%vlocity_namespace%__IgnoreErrors__c": false, | ||
"%vlocity_namespace%__InputCustom__c": "", | ||
"%vlocity_namespace%__InputJson__c": "", | ||
"%vlocity_namespace%__InputType__c": "", | ||
"%vlocity_namespace%__InputXml__c": "", | ||
"%vlocity_namespace%__InterfaceObject__c": "JSON", | ||
"%vlocity_namespace%__IsDefaultForInterface__c": false, | ||
"%vlocity_namespace%__IsProcessSuperBulk__c": false, | ||
"%vlocity_namespace%__OMplusSyncEnabled__c": true, | ||
"%vlocity_namespace%__OuboundStagingObjectDataField__c": "", | ||
"%vlocity_namespace%__OutboundConfigurationField__c": "", | ||
"%vlocity_namespace%__OutboundConfigurationName__c": "", | ||
"%vlocity_namespace%__OutboundStagingObjectName__c": "", | ||
"%vlocity_namespace%__OutputType__c": "", | ||
"%vlocity_namespace%__OverwriteAllNullValues__c": false, | ||
"%vlocity_namespace%__PreprocessorClassName__c": "", | ||
"%vlocity_namespace%__ProcessNowThreshold__c": -1, | ||
"%vlocity_namespace%__RequiredPermission__c": "", | ||
"%vlocity_namespace%__RollbackOnError__c": false, | ||
"%vlocity_namespace%__SalesforcePlatformCacheType__c": "", | ||
"%vlocity_namespace%__SampleInputCustom__c": "", | ||
"%vlocity_namespace%__SampleInputJSON__c": "", | ||
"%vlocity_namespace%__SampleInputRows__c": "", | ||
"%vlocity_namespace%__SampleInputXML__c": "", | ||
"%vlocity_namespace%__TargetOutCustom__c": "", | ||
"%vlocity_namespace%__TargetOutDocuSignTemplateId__c": "", | ||
"%vlocity_namespace%__TargetOutJson__c": "", | ||
"%vlocity_namespace%__TargetOutPdfDocName__c": "", | ||
"%vlocity_namespace%__TargetOutXml__c": "", | ||
"%vlocity_namespace%__TimeToLiveMinutes__c": "", | ||
"%vlocity_namespace%__Type__c": "Migration", | ||
"%vlocity_namespace%__UseAssignmentRules__c": false, | ||
"%vlocity_namespace%__XmlOutputSequence__c": "", | ||
"%vlocity_namespace%__XmlRemoveDeclaration__c": false, | ||
"Name": "DataRaptor Migration", | ||
"VlocityDataPackType": "SObject", | ||
"VlocityRecordSObjectType": "%vlocity_namespace%__DRBundle__c", | ||
"VlocityRecordSourceKey": "%vlocity_namespace%__DRBundle__c/DataRaptor Migration" | ||
} |
322 changes: 322 additions & 0 deletions
322
DataPackSettings/latest/DataRaptor/DataRaptor-Migration/DataRaptor-Migration_Mappings.json
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
insert new Document(Name='OmniScript URL Document Do Not Delete', Body=Blob.valueOf('txt'),FolderId=UserInfo.getUserId()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
|
||
module.exports = async function(vlocity, currentContextData, jobInfo, callback) { | ||
|
||
let metadataToDataBindings = [{ | ||
metadataQuery: "Select Id, DeveloperName from OmniUiCardConfig", | ||
dataQuery: "Select Id, Name, AuthorName, VersionNumber from OmniUiCard", | ||
keyFields: [ "Name", "AuthorName", "VersionNumber" ], | ||
type: "OmniUiCardConfig" | ||
},{ | ||
metadataQuery: "Select Id, DeveloperName from OmniScriptConfig", | ||
dataQuery: "Select Id, Type, SubType, Language, VersionNumber from OmniProcess", | ||
keyFields: [ "Type", "SubType", "Language", "VersionNumber" ], | ||
type: "OmniScriptConfig" | ||
},{ | ||
metadataQuery: "Select Id, DeveloperName from OmniIntegrationProcConfig", | ||
dataQuery: "Select Id, Type, SubType, Language, VersionNumber from OmniProcess", | ||
keyFields: [ "Type", "SubType", "Language", "VersionNumber" ], | ||
type: "OmniIntegrationProcConfig" | ||
}, | ||
{ | ||
metadataQuery: "Select Id, DeveloperName from OmniDataTransformConfig", | ||
dataQuery: "Select Id, Name, VersionNumber from OmniDataTransform", | ||
keyFields: [ "Name", "VersionNumber" ], | ||
type: "OmniDataTransformConfig" | ||
}]; | ||
|
||
try { | ||
let allMetadataToDelete = []; | ||
for (let binding of metadataToDataBindings) { | ||
vlocity.jsForceConnection.version = "54.0"; | ||
let foundMetadataComponents = await vlocity.jsForceConnection.tooling.query(binding.metadataQuery); | ||
|
||
if (foundMetadataComponents.records == 0) { | ||
continue; | ||
} | ||
|
||
foundMetadataComponents = foundMetadataComponents.records; | ||
|
||
let foundDataComponents = await vlocity.jsForceConnection.query(binding.dataQuery); | ||
|
||
foundDataComponents = foundDataComponents.records; | ||
let dataComponentKeys = []; | ||
|
||
for (let dataRecord of foundDataComponents) { | ||
let metadataKey = ""; | ||
|
||
for (let key of binding.keyFields) { | ||
if (metadataKey) { | ||
metadataKey += "_"; | ||
} | ||
|
||
metadataKey += dataRecord[key]; | ||
} | ||
|
||
dataComponentKeys.push(metadataKey); | ||
} | ||
|
||
for (let metadataRecord of foundMetadataComponents) { | ||
if (!dataComponentKeys.includes(metadataRecord.DeveloperName)) { | ||
allMetadataToDelete.push(metadataRecord); | ||
} | ||
} | ||
} | ||
|
||
let iterations = 0; | ||
|
||
while (allMetadataToDelete.length > 0 && iterations < 10) { | ||
iterations++; | ||
|
||
let failedMetadata = []; | ||
|
||
for (let metadataRecord of allMetadataToDelete) { | ||
try { | ||
await vlocity.jsForceConnection.tooling.delete(metadataRecord.attributes.type, metadataRecord.Id); | ||
VlocityUtils.log("Delete Success", metadataRecord.DeveloperName); | ||
} catch (e) { | ||
failedMetadata.push(metadataRecord); | ||
VlocityUtils.log("Delete Failed", metadataRecord.DeveloperName); | ||
} | ||
} | ||
|
||
allMetadataToDelete = failedMetadata; | ||
} | ||
|
||
|
||
|
||
} catch (e) { | ||
VlocityUtils.error(e); | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters