Skip to content
This repository was archived by the owner on Mar 10, 2024. It is now read-only.

Commit 221099d

Browse files
authored
Merge pull request forcedotcom#268 from forcedotcom/develop
Code cleanup
2 parents 8b1dc6c + 6a90e3a commit 221099d

File tree

6 files changed

+12
-67
lines changed

6 files changed

+12
-67
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
```bash
1616
### ------------------------------------------- ###
17-
### - *** Latest version: v3.9.3 *** - ###
17+
### - *** Latest version: v3.9.4 *** - ###
1818
### ------------------------------------------- ###
1919
### - *** Make sure, that you have *** - ###
2020
### - *** the latest version installed *** - ###

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "sfdmu",
33
"description": "The Salesforce Data Loader SFDX Plugin (SFDMU) will help you to populate your org (scratch / dev / sandbox / production) with data imported from another org or CSV files. It supports all important CRUD operations (Insert/Update/Upsert/Delete) also for multiple related sObjects.",
4-
"version": "3.9.3",
4+
"version": "3.9.4",
55
"author": "Haim Knokh",
66
"bugs": "https://github.com/forcedotcom/SFDX-Data-Move-Utility/issues",
77
"dependencies": {

src/modules/components/common_components/common.ts

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -999,36 +999,10 @@ export class Common {
999999
*/
10001000
public static getRecordValue(thisSobjectName: string, record: any, propName: string, sObjectName?: string, sFieldName?: string): any {
10011001
if (!record) return null;
1002-
let value = record[sFieldName || propName];
1003-
if (!value) return value;
1004-
//sObjectName = sObjectName || record["SobjectType"];
1005-
//if (thisSobjectName == CONSTANTS.RECORD_TYPE_SOBJECT_NAME && propName == CONSTANTS.DEFAULT_RECORD_TYPE_ID_EXTERNAL_ID_FIELD_NAME) {
1006-
// return String(value).split(CONSTANTS.COMPLEX_FIELDS_SEPARATOR)[0] + CONSTANTS.COMPLEX_FIELDS_SEPARATOR + sObjectName;
1007-
//} else {
1008-
return value;
1009-
//}
1010-
}
1011-
1012-
/**
1013-
* Parsed value and retrieves clear value.
1014-
* For example for the field RecordType.DeveloperName: "AccountRT;Account" => "AccountRT"
1015-
*
1016-
* @static
1017-
* @param {string} sObjectName The sObject name
1018-
* @param {*} rawFieldValue The raw field value to transform
1019-
* @param {string} fieldName The field name
1020-
* @returns {string}
1021-
* @memberof Common
1022-
*/
1023-
public static getFieldValue(sObjectName: string, rawFieldValue: any, fieldName: string): any {
1024-
//if (!rawFieldValue) return rawFieldValue;
1025-
//if (sObjectName == CONSTANTS.RECORD_TYPE_SOBJECT_NAME && fieldName == CONSTANTS.DEFAULT_RECORD_TYPE_ID_EXTERNAL_ID_FIELD_NAME) {
1026-
// //"AccountRT;Account" => "AccountRT"
1027-
// return String(rawFieldValue).split(CONSTANTS.COMPLEX_FIELDS_SEPARATOR)[0];
1028-
//}
1029-
return rawFieldValue;
1002+
return record[sFieldName || propName];
10301003
}
10311004

1005+
10321006
/**
10331007
* Returns true if this object is custom
10341008
*

src/modules/components/common_components/sfdx.ts

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -241,18 +241,7 @@ export class Sfdx implements IFieldMapping {
241241
return parsedRecords;
242242
}
243243

244-
function ___formatRecords(records: Array<any>, soqlFormat: [string, Map<string, Array<string>>, Array<string>, string]): Array<any> {
245-
// Trasnform RecordType.DeveloperName object fields into proper format
246-
//let recordTypeExtIdPropName = CONSTANTS.RECORD_TYPE_SOBJECT_NAME + "." + CONSTANTS.DEFAULT_RECORD_TYPE_ID_EXTERNAL_ID_FIELD_NAME;
247-
//records.forEach(record => {
248-
// if (record.hasOwnProperty(recordTypeExtIdPropName)) {
249-
// record[recordTypeExtIdPropName] = Common.getRecordValue(CONSTANTS.RECORD_TYPE_SOBJECT_NAME,
250-
// record,
251-
// CONSTANTS.DEFAULT_RECORD_TYPE_ID_EXTERNAL_ID_FIELD_NAME,
252-
// soqlFormat[3],
253-
// recordTypeExtIdPropName);
254-
// }
255-
//});
244+
function ___formatRecords(records: Array<any>, soqlFormat: [string, Map<string, Array<string>>, Array<string>, string]): Array<any> {
256245
// Process complex keys}
257246
if (soqlFormat[1].size == 0) {
258247
return records;

src/modules/models/job_models/migrationJobTask.ts

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ export default class MigrationJobTask {
355355
return;
356356
}
357357
// Missing id column but __r column provided.
358-
let desiredExternalIdValue = parentTask.getRecordValue(csvRow, parentExternalId, self.sObjectName, columnName__r);
358+
let desiredExternalIdValue = parentTask.getRecordValue(csvRow, parentExternalId);
359359
if (desiredExternalIdValue) {
360360
isFileChanged = true;
361361
let parentCsvRow = parentCSVRowsMap.get(desiredExternalIdValue);
@@ -447,7 +447,7 @@ export default class MigrationJobTask {
447447
}
448448
});
449449
[...childFileMap.values()].forEach(csvRow => {
450-
let extIdValue = self.getRecordValue(csvRow, parentOriginalExternalIdColumnName, childTask.sObjectName, columnChildOriginalName__r);
450+
let extIdValue = self.getRecordValue(csvRow, parentOriginalExternalIdColumnName);
451451
if (extIdValue && parentCSVExtIdMap.has(extIdValue)) {
452452
csvRow[columnChildNameId] = parentCSVExtIdMap.get(extIdValue)["Id"];
453453
csvRow[columnChildIdName__r] = csvRow[columnChildNameId];
@@ -480,17 +480,12 @@ export default class MigrationJobTask {
480480
* for this sobject
481481
*
482482
* @param {*} record The record
483-
* @param {string} propName The property name to extract value from the record object
484-
* @param {string} [sObjectName] If the current task is RecordType and propName = DeveloperName -
485-
* pass here the SobjectType
486-
* @param {string} [sFieldName] If the current task is RecordType and propName = DeveloperName -
487-
* pass here the property name to extract value from the record object
488-
* instead of passing it with the "propName" parameter
489-
* @returns {*}
483+
* @param {string} propName The property name to extract value from the record object
490484
* @memberof MigrationJobTask
491485
*/
492-
getRecordValue(record: any, propName: string, sObjectName?: string, sFieldName?: string): any {
493-
return Common.getRecordValue(this.sObjectName, record, propName, sObjectName, sFieldName);
486+
getRecordValue(record: any, propName: string): any {
487+
if (!record) return null;
488+
return record[propName];
494489
}
495490

496491
/**
@@ -1633,7 +1628,7 @@ export default class MigrationJobTask {
16331628
// For target => |TARGET Account|Name IN (|SOURCE Account|Name....)
16341629
if (field.isSimple && field.isExternalIdField) {
16351630
// Only for current object's external id (f.ex.: Name) - not complex and not Id - only simple
1636-
fieldsToQueryMap.set(field, [...this.sourceData.extIdRecordsMap.keys()].map(value => Common.getFieldValue(this.sObjectName, value, field.name)));
1631+
fieldsToQueryMap.set(field, [...this.sourceData.extIdRecordsMap.keys()]);
16371632
}
16381633
}
16391634
});

src/modules/models/script_models/script.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -308,19 +308,6 @@ export default class Script {
308308
externalId
309309
});
310310

311-
//if (referencedObjectType == CONSTANTS.RECORD_TYPE_SOBJECT_NAME) {
312-
// let objectsWithRecordTypeFields = this.objects.filter(x => x.hasRecordTypeIdField).map(x => x.name);
313-
// thisField.parentLookupObject.parsedQuery = parseQuery(thisField.parentLookupObject.query);
314-
// thisField.parentLookupObject.parsedQuery.fields.push(getComposedField("SobjectType"));
315-
// thisField.parentLookupObject.parsedQuery.where = Common.composeWhereClause(thisField.parentLookupObject.parsedQuery.where, "SobjectType", objectsWithRecordTypeFields);
316-
// thisField.parentLookupObject.parsedQuery.orderBy = <OrderByClause>({
317-
// field: "SobjectType",
318-
// order: "ASC"
319-
// });
320-
// thisField.parentLookupObject.query = composeQuery(thisField.parentLookupObject.parsedQuery);
321-
322-
//}
323-
324311
isParentLookupObjectAdded = true;
325312

326313
}

0 commit comments

Comments
 (0)