@oneblink/sdk-core
    Preparing search index...

    Function replaceInjectablesWithSubmissionValues

    • Replace the {ELEMENT:<elementName>} values in text after a successful form submission as well as other replaceable parameters e.g. submissionId. The replacements are suppose to be user friendly and for display purposes, e.g. dates should be displayed in the user's desired format and timezone.

      const result = submissionService.replaceInjectablesWithSubmissionValues(
      'https://example.com/path?submissionId={SUBMISSION_ID}&externalId={EXTERNAL_ID}&search{ELEMENT:search}',
      {
      submissionId: 'abc-123',
      submissionTimestamp: '2021-07-02T02:19:13.670Z',
      formatDate: (value) => new Date(value).toDateString(),
      formatDateTime: (value) => new Date(value).toString(),
      formatTime: (value) => new Date(value).toTimeString(),
      submission: {
      search: 'Entered By User',
      },
      form: {
      id: 1,
      name: 'Form',
      organisationId: '',
      formsAppEnvironmentId: 1,
      formsAppIds: [],
      isAuthenticated: false,
      isMultiPage: false,
      isInfoPage: false,
      postSubmissionAction: 'FORMS_LIBRARY',
      cancelAction: 'FORMS_LIBRARY',
      submissionEvents: [],
      tags: [],
      elements: [
      {
      id: 'd4135b47-9004-4d75-aeb3-d2f6232da111',
      name: 'search',
      type: 'text',
      label: 'Search',
      readOnly: false,
      required: false,
      conditionallyShow: false,
      requiresAllConditionallyShowPredicates: false,
      isElementLookup: false,
      isDataLookup: false,
      },
      ],
      },
      },
      )

      Parameters

      Returns { hadAllInjectablesReplaced: boolean; text: string }

      • hadAllInjectablesReplaced: boolean

        Determine if replaceable strings could all be replaced. The text property returned will replace all injectable with empty strings if the value cannot be found. Use this boolean to either use the replaced string with missing data or implement some other logic to handle missing injectables.

      • text: string

        The text passed in with all injectables replaced with their corresponding values or empty strings.