Skip to content

Commit

Permalink
Added ability to create custom form replacement values based on reque…
Browse files Browse the repository at this point in the history
…st headers. Also added the ability to parse URLs and retrieve search parameters as part of the custom form replacement value generation.
  • Loading branch information
shilob committed Oct 14, 2019
1 parent 0428fcf commit f4701a5
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions typescript/api/controllers/RecordController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { Observable } from 'rxjs/Rx';
import moment from 'moment-es6';
import * as tus from 'tus-node-server';
import * as fs from 'fs';
import * as url from 'url';
declare var _;

declare var FormsService, RecordsService, WorkflowStepsService, BrandingService, RecordTypesService, TranslationService, User, EmailService, RolesService;
Expand Down Expand Up @@ -801,10 +802,17 @@ export module Controllers {
case 'user':
replacement = req.user[customConfig.field];
break;
case 'header':
replacement = req.get(customConfig.field);
break;
}
}

if (!_.isEmpty(replacement)) {
if (customConfig.parseUrl && customConfig.searchParams) {
const urlParsed = new url.URL(replacement);
replacement = urlParsed.searchParams.get(customConfig.searchParams);
}
_.set(field.definition, fieldName, fieldTarget.replace(customKey, replacement));
}
}
Expand Down

0 comments on commit f4701a5

Please sign in to comment.