diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index ccfb707..0000000 Binary files a/.DS_Store and /dev/null differ diff --git a/azure-devops-extension-dev.json b/azure-devops-extension-dev.json index 8328e73..0cf977d 100644 --- a/azure-devops-extension-dev.json +++ b/azure-devops-extension-dev.json @@ -1,6 +1,6 @@ { "id":"RestDataMappingPicklistDev", - "version": "0.3.7", + "version": "0.4.0", "baseUri": "https://localhost:44300", "public": false, "private":true diff --git a/azure-devops-extension.json b/azure-devops-extension.json index 5dcf62c..8916df6 100644 --- a/azure-devops-extension.json +++ b/azure-devops-extension.json @@ -2,7 +2,7 @@ "manifestVersion": 1.0, "id": "RestDataMappingPicklist", "publisher": "dedac", - "version": "0.3.7", + "version": "0.4.0", "name": "Rest Data Mapping Picklist", "description": "Load work item values from a specified REST endpoint and map additional REST data to your work item", "public": true, diff --git a/package-lock.json b/package-lock.json index 44bf564..64d8878 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "rest-data-mapping-picklist", - "version": "0.3.5", + "version": "0.4.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "rest-data-mapping-picklist", - "version": "0.3.5", + "version": "0.4.0", "license": "ISC", "dependencies": { "axios": "^0.24.0", diff --git a/package.json b/package.json index 73939f9..0e2529d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rest-data-mapping-picklist", - "version": "0.3.7", + "version": "0.4.0", "description": "An Azure DevOps Work Item Control for loading values from a Rest endpoint", "main": "index.js", "repository": { diff --git a/src/RestServiceData.ts b/src/RestServiceData.ts index 62c98b6..1c1113a 100644 --- a/src/RestServiceData.ts +++ b/src/RestServiceData.ts @@ -17,9 +17,9 @@ export class RestServiceData { } const keyFieldName = SDK.getConfiguration().witInputs.RestServiceKeyField; const arrayPath = SDK.getConfiguration().witInputs.PathToArray; - - var arrayData = get(resp.data, arrayPath, resp.data); - + if (resp !== undefined && resp.data !== undefined) { + var arrayData = get(resp.data, arrayPath, resp.data); + } if (arrayData) { if (arrayData.constructor !== Array) { console.dir(arrayData); diff --git a/src/parameter-replacement.ts b/src/parameter-replacement.ts index 0e6d55f..a727749 100644 --- a/src/parameter-replacement.ts +++ b/src/parameter-replacement.ts @@ -10,8 +10,15 @@ export async function ReplaceFieldParameters(hasFields:string) : Promise var replaceMe = hasFields.substring(index, endIndex + 1); var fieldName = replaceMe.replace('$(', '').replace(')', '').trim(); var value = await service.getFieldValue(fieldName, { returnOriginalValue: false }); - if (typeof value === "string") { - hasFields = hasFields.replace(replaceMe, value); + if (!!value && !!value.toString()) { + var escapedValue = JSON.stringify(value); + // remove outer quotes from the escaped value if they exist + // this assumes the user has added quotes of their own in the configuration + if (escapedValue.startsWith('"') && escapedValue.endsWith('"')) { + escapedValue = escapedValue.substring(1, escapedValue.length - 1); + } + + hasFields = hasFields.replace(replaceMe, escapedValue); } else { hasFields = hasFields.replace(replaceMe, ""); }