Skip to content

Commit 3cdbc60

Browse files
Merge pull request #2443 from Accenture/bug/2439-createdDate-and-modifiedDate-saved-as-0001-01-01T00-00-00-after-update
bug/2439 refresh createdDate and modifiedDate after updating scripts
2 parents 8894b1d + 0ac128b commit 3cdbc60

6 files changed

Lines changed: 38 additions & 4 deletions

File tree

@types/lib/metadataTypes/Script.d.ts

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

@types/lib/metadataTypes/Script.d.ts.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/metadataTypes/Script.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,22 @@ class Script extends MetadataType {
8383
return super.updateREST(script, '/automation/v1/scripts/' + script.ssjsActivityId);
8484
}
8585

86+
/**
87+
* helper for {@link MetadataType.updateREST} and {@link MetadataType.updateSOAP}
88+
*
89+
* @param {MetadataTypeItem} metadataEntry a single metadata Entry
90+
* @param {object} apiResponse varies depending on the API call
91+
* @returns {Promise.<object>} apiResponse, potentially modified
92+
*/
93+
static async postUpdateTasks(metadataEntry, apiResponse) {
94+
// script update endpoint returns wrong values for createdDate and modifiedDate - need to re-retrieve to get correct values
95+
const ssjsActivityId = apiResponse?.ssjsActivityId;
96+
if (ssjsActivityId) {
97+
apiResponse = await this.client.rest.get('/automation/v1/scripts/' + ssjsActivityId);
98+
}
99+
return apiResponse;
100+
}
101+
86102
/**
87103
* Creates a single Script
88104
*
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"ssjsActivityId": "39f6a488-20eb-4ba0-b0b9-023725b574e4",
3+
"name": "testExisting_script",
4+
"key": "testExisting_script",
5+
"description": "updated on deploy",
6+
"script": "<script runat=\"server\">\n// dummy updated\n</script>",
7+
"categoryId": 304,
8+
"createdDate": "2022-10-20T00:41:26.163",
9+
"modifiedDate": "2022-10-20T00:41:26.163"
10+
}

test/resources/9999999/automation/v1/scripts/39f6a488-20eb-4ba0-b0b9-023725b574e4/patch-response.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
"description": "updated on deploy",
66
"script": "<script runat=\"server\">\n// dummy updated\n</script>",
77
"categoryId": 304,
8-
"createdDate": "2022-10-20T00:41:26.163",
9-
"modifiedDate": "2022-10-20T00:41:26.163"
8+
"createdDate": "0001-01-01T00:00:00",
9+
"modifiedDate": "0001-01-01T00:00:00"
1010
}

test/type.script.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ describe('type: script', () => {
261261
// check number of API calls
262262
assert.equal(
263263
testUtils.getAPIHistoryLength(),
264-
4,
264+
5,
265265
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
266266
);
267267
return;

0 commit comments

Comments
 (0)