Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions schemas/json/text-resources/text-resources.schema.v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@
{ "$ref": "#/definitions/dataSource-instanceContext" },
{ "$ref": "#/definitions/dataSource-applicationSettings" }
]
},
"defaultValue": {
"type": "string",
"title": "Default value of a variable",
"description": "The default value that you want to display if there is no value in the data model for the variable."
}
},
"required": [
Expand Down
10 changes: 10 additions & 0 deletions src/hooks/useLanguage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,16 @@ function replaceVariables(text: string, variables: IVariable[], dataSources: Tex
value = applicationSettings && variable.key in applicationSettings ? applicationSettings[variable.key] : value;
}

if (value === variable.key) {
/*
By returning value if variable.defaultValue is null, we ensure
that we are returning the dataModel path string instead of blank
value. If app developers want to return blank value, they should
set defaultValue to a blank space.
*/
value = variable.defaultValue || value;
}

out = out.replaceAll(`{${idx}}`, value);
}

Expand Down
1 change: 1 addition & 0 deletions src/types/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ export interface ITextResource {
export interface IVariable {
key: string;
dataSource: string;
defaultValue?: string;
}

export interface IAttachmentGrouping {
Expand Down