Skip to content

🔥 The free & Open Source DocuSign alternative

add replacemailvaribles function to change varibale from custom mail

prafull-opensignlabsb58c3fd4677d
diff --git a/apps/OpenSignServer/Utils.js b/apps/OpenSignServer/Utils.js
index 98c1a4366..8fc705ceb 100644
--- a/apps/OpenSignServer/Utils.js
+++ b/apps/OpenSignServer/Utils.js
@@ -17,3 +17,24 @@ export const color = [
'#66ccff',
'#ffffcc',
];
+
+export function replaceMailVaribles(subject, body, variables) {
+ let replacedSubject = subject;
+ let replacedBody = body;
+
+ for (const variable in variables) {
+ const regex = new RegExp(`{{${variable}}}`, 'g');
+ if (subject) {
+ replacedSubject = replacedSubject.replace(regex, variables[variable]);
+ }
+ if (body) {
+ replacedBody = replacedBody.replace(regex, variables[variable]);
+ }
+ }
+
+ const result = {
+ subject: replacedSubject,
+ body: replacedBody,
+ };
+ return result;
+}