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

    Function replaceInjectablesWithElementValues

    • Replace the {ELEMENT:<elementName>} values in text while a form is being filled out. 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 { text: url } =
      submissionService.replaceInjectablesWithElementValues(
      'https://example.com/path?search{ELEMENT:search}',
      {
      formatDate: (value) => new Date(value).toDateString(),
      formatDateTime: (value) => new Date(value).toString(),
      formatTime: (value) => new Date(value).toTimeString(),
      formatNumber: (value) => Number(value).toString(),
      formatCurrency: (value) => Number(value).toFixed(2),
      submission: {
      search: 'Entered By User',
      },
      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,
      },
      ],
      userProfile: {
      userId: 'abc123',
      username: 'john-user',
      email: 'john.user@domain.com',
      },
      },
      )

      Parameters

      • text: string
      • options: { formElements: FormElement[] } & ReplaceInjectablesFormatters & {
            excludeNestedElements?: boolean;
            submission: { [name: string]: unknown };
            task: undefined | Task;
            taskGroup: undefined | TaskGroup;
            taskGroupInstance: undefined | TaskGroupInstance;
            userProfile: undefined | UserProfile;
        }
        • OptionalexcludeNestedElements?: boolean

          Determine if only root level elements should be replaced.

          false will replace "{ELEMENT:Parent_Name}" and "{ELEMENT:Children|Name}".

          true will replace "{ELEMENT:Parent_Name}" but will NOT replace {ELEMENT:Children|Name}.

        • submission: { [name: string]: unknown }
        • task: undefined | Task
        • taskGroup: undefined | TaskGroup
        • taskGroupInstance: undefined | TaskGroupInstance
        • userProfile: undefined | UserProfile

      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.