# Calculators

**URL:** https://community.synatic.com/c/faqs/calculators/14.md

[Latest](https://community.synatic.com/latest.md) · [Categories](https://community.synatic.com/categories.md) · [Tags](https://community.synatic.com/tags.md)

---

## [About the Calculators category](https://community.synatic.com/t/about-the-calculators-category/23)

<div class="topic-metadata">

**Author:** [@shaun](https://community.synatic.com/u/shaun)\
**Replies:** 0

</div>

---

## [Using utility methods in Calculators](https://community.synatic.com/t/using-utility-methods-in-calculators/185)

<div class="topic-metadata">

**Author:** [@navessa](https://community.synatic.com/u/navessa)\
**Replies:** 0\
**Last updated:** [February 17, 2022, 12:41pm UTC](https://community.synatic.com/t/using-utility-methods-in-calculators/185 "2022-02-17T12:41:25Z")

</div>

The below are some utils methods that can be used in a Calculator step. Datatype conversion You can convert a value to a different datatype: let newValue = utils.convert(val, toType, format); Objects You can copy …

---

## [How to decode base64 string to text](https://community.synatic.com/t/how-to-decode-base64-string-to-text/347)

<div class="topic-metadata">

**Author:** [@Faizel](https://community.synatic.com/u/Faizel)\
**Replies:** 0\
**Last updated:** [May 3, 2023, 2:46pm UTC](https://community.synatic.com/t/how-to-decode-base64-string-to-text/347 "2023-05-03T14:46:37Z")

</div>

If you require to decode a base64 string to text, please follow the instructions below: Illustrated in the image below is an example of a flow where the payload is from a Record Generator source step which decodes the b…

---

## [How to reference a solution/ global parameter (many static parameters) in a Calculator step & send an email notification](https://community.synatic.com/t/how-to-reference-a-solution-global-parameter-many-static-parameters-in-a-calculator-step-send-an-email-notification/280)

<div class="topic-metadata">

**Author:** [@navessa](https://community.synatic.com/u/navessa)\
**Replies:** 0\
**Last updated:** [August 8, 2022, 4:41pm UTC](https://community.synatic.com/t/how-to-reference-a-solution-global-parameter-many-static-parameters-in-a-calculator-step-send-an-email-notification/280 "2022-08-08T16:41:00Z")

</div>

If you require to reference a solution/ global parameter in a Calculator step, follow the below instructions: Illustrated below is an example of a flow where a file is being retrieved from an SFTP Server source step and…

---

## [How to add a token as a parameter and reference it in the HTTP Service destination step](https://community.synatic.com/t/how-to-add-a-token-as-a-parameter-and-reference-it-in-the-http-service-destination-step/321)

<div class="topic-metadata">

**Author:** [@navessa](https://community.synatic.com/u/navessa)\
**Replies:** 0\
**Last updated:** [February 7, 2023, 3:57pm UTC](https://community.synatic.com/t/how-to-add-a-token-as-a-parameter-and-reference-it-in-the-http-service-destination-step/321 "2023-02-07T15:57:56Z")

</div>

If you require to add a token as a parameter and reference it in the HTTP Service destination step, please follow the below instructions: The token is first added as a parameter using JSON code in the Calculator step a…

---

## [How to delete a duplicate record/ element in an array](https://community.synatic.com/t/how-to-delete-a-duplicate-record-element-in-an-array/294)

<div class="topic-metadata">

**Author:** [@navessa](https://community.synatic.com/u/navessa)\
**Replies:** 0\
**Last updated:** [October 7, 2022, 1:18pm UTC](https://community.synatic.com/t/how-to-delete-a-duplicate-record-element-in-an-array/294 "2022-10-07T13:18:22Z")

</div>

The below example is how to delete a duplicate record/ element in an array. Illustrated below is an example payload that is used in a Record Generator source step. As shown in the image, there are 2 records/ elements in…

---

## [Inserting a new line in a string](https://community.synatic.com/t/inserting-a-new-line-in-a-string/286)

<div class="topic-metadata">

**Author:** [@mc\_lwcc](https://community.synatic.com/u/mc_lwcc)\
**Replies:** 5\
**Last updated:** [September 2, 2022, 2:19pm UTC](https://community.synatic.com/t/inserting-a-new-line-in-a-string/286 "2022-09-02T14:19:51Z")

</div>

Is there a way to introduce a new line character in a string variable? I tried several variations on the new line character but they all resulted in errors. "\\n" "\\\\n" "\\\\\\\\n" I am trying insert a new line between two…

---

## [How to manipulate records in an array](https://community.synatic.com/t/how-to-manipulate-records-in-an-array/285)

<div class="topic-metadata">

**Author:** [@navessa](https://community.synatic.com/u/navessa)\
**Replies:** 0\
**Last updated:** [August 31, 2022, 8:47pm UTC](https://community.synatic.com/t/how-to-manipulate-records-in-an-array/285 "2022-08-31T20:47:09Z")

</div>

The below are examples of how you can manipulate records in an array. Illustrated below is an example of a JSON payload that has an array. To remove an email domain from the Email field (trim a field with a specific …

---

## [How to split values in a field and return the values as 2 separate records](https://community.synatic.com/t/how-to-split-values-in-a-field-and-return-the-values-as-2-separate-records/274)

<div class="topic-metadata">

**Author:** [@navessa](https://community.synatic.com/u/navessa)\
**Replies:** 0\
**Last updated:** [July 22, 2022, 5:30pm UTC](https://community.synatic.com/t/how-to-split-values-in-a-field-and-return-the-values-as-2-separate-records/274 "2022-07-22T17:30:05Z")

</div>

Illustrated below is an example of a flow where the Record Generator is used as a source step. The image below consists of the data that is in the Record Generator step. The output of the data in the Record Generat…

---

## [How to remove fields/ keys with null values in a dataset](https://community.synatic.com/t/how-to-remove-fields-keys-with-null-values-in-a-dataset/260)

<div class="topic-metadata">

**Author:** [@navessa](https://community.synatic.com/u/navessa)\
**Replies:** 0\
**Last updated:** [June 29, 2022, 5:11pm UTC](https://community.synatic.com/t/how-to-remove-fields-keys-with-null-values-in-a-dataset/260 "2022-06-29T17:11:03Z")

</div>

Illustrated below is an example of a flow where the Record Generator is the source step. The below page is the dataset which contains fields that have null values. To remove the fields that have null values in the…

---

## [How to remove the default buffer fields/ columns](https://community.synatic.com/t/how-to-remove-the-default-buffer-fields-columns/257)

<div class="topic-metadata">

**Author:** [@navessa](https://community.synatic.com/u/navessa)\
**Replies:** 0\
**Last updated:** [June 29, 2022, 10:55am UTC](https://community.synatic.com/t/how-to-remove-the-default-buffer-fields-columns/257 "2022-06-29T10:55:13Z")

</div>

Buffers contain 2 default fields which are “\_id” field and the “\_dateUpdated” field. If you don’t require these fields from your Buffer source step, you can delete the fields by adding a Calculator step after the Buffer…

---

## [How to create a new field/ column](https://community.synatic.com/t/how-to-create-a-new-field-column/258)

<div class="topic-metadata">

**Author:** [@navessa](https://community.synatic.com/u/navessa)\
**Replies:** 0\
**Last updated:** [June 29, 2022, 12:17pm UTC](https://community.synatic.com/t/how-to-create-a-new-field-column/258 "2022-06-29T12:17:02Z")

</div>

Illustrated below is a flow where the Record Generator is the source step. The below image consists of the data that is in the Record Generator. The output results is in the below image. A new field/ column call…

---

## [How to reference a field with whitespaces in a Calculator step](https://community.synatic.com/t/how-to-reference-a-field-with-whitespaces-in-a-calculator-step/252)

<div class="topic-metadata">

**Author:** [@navessa](https://community.synatic.com/u/navessa)\
**Replies:** 0\
**Last updated:** [June 15, 2022, 2:45pm UTC](https://community.synatic.com/t/how-to-reference-a-field-with-whitespaces-in-a-calculator-step/252 "2022-06-15T14:45:31Z")

</div>

Illustrated below is a flow where the Record Generator is the source. The output of the Record Generator is in the below image. Highlighted are whitespaces in a field. To reference a field with whitespaces in a Ca…

---

## [How to generate a JWT Token synchronously in a Calculator step](https://community.synatic.com/t/how-to-generate-a-jwt-token-synchronously-in-a-calculator-step/226)

<div class="topic-metadata">

**Author:** [@navessa](https://community.synatic.com/u/navessa)\
**Replies:** 0\
**Last updated:** [May 13, 2022, 4:06pm UTC](https://community.synatic.com/t/how-to-generate-a-jwt-token-synchronously-in-a-calculator-step/226 "2022-05-13T16:06:17Z")

</div>

Illustrated in the image below is a Calculator step with the code that is used to generate a JWT Token. The value for the “payload” field can be any payload. You can copy and paste the below code in your Calculator st…

---

## [How to trim an array record](https://community.synatic.com/t/how-to-trim-an-array-record/212)

<div class="topic-metadata">

**Author:** [@navessa](https://community.synatic.com/u/navessa)\
**Replies:** 0\
**Last updated:** [April 20, 2022, 3:08pm UTC](https://community.synatic.com/t/how-to-trim-an-array-record/212 "2022-04-20T15:08:23Z")

</div>

Elements in an array can contain whitespaces after the variable. To trim the whitespaces in an array, follow the below steps: Illustrated in the below image is an example of the flow where we are using the Record Genera…

---

## [How to convert a PDF file to a Base64 file](https://community.synatic.com/t/how-to-convert-a-pdf-file-to-a-base64-file/160)

<div class="topic-metadata">

**Author:** [@navessa](https://community.synatic.com/u/navessa)\
**Replies:** 0\
**Last updated:** [December 23, 2021, 2:48pm UTC](https://community.synatic.com/t/how-to-convert-a-pdf-file-to-a-base64-file/160 "2021-12-23T14:48:12Z")

</div>

The below image is an example of the steps that are required. You can add any destination step to the flow. I added a Run File step to view the pdf document after the conversion before it is sent to a destination. In…

---

## [How to convert a Base64 file to Binary](https://community.synatic.com/t/how-to-convert-a-base64-file-to-binary/179)

<div class="topic-metadata">

**Author:** [@navessa](https://community.synatic.com/u/navessa)\
**Replies:** 0\
**Last updated:** [February 1, 2022, 9:45am UTC](https://community.synatic.com/t/how-to-convert-a-base64-file-to-binary/179 "2022-02-01T09:45:46Z")

</div>

Illustrated below is an example of a flow with the Record Generator as the source step and the HTTP Service step as the destination step. The image below is the Record Generator step which is populated with the Base6…

---

## [How to replace a letter, character or word in a value](https://community.synatic.com/t/how-to-replace-a-letter-character-or-word-in-a-value/170)

<div class="topic-metadata">

**Author:** [@navessa](https://community.synatic.com/u/navessa)\
**Replies:** 0\
**Last updated:** [January 19, 2022, 5:55pm UTC](https://community.synatic.com/t/how-to-replace-a-letter-character-or-word-in-a-value/170 "2022-01-19T17:55:23Z")

</div>

Illustrated in the below image is an example of a flow where the Record Generator is the source step. In the image below, The Record Generator step is populated with data. The field names are “Description1”, “Descrip…

---

## [How to merge every 2 records into one row](https://community.synatic.com/t/how-to-merge-every-2-records-into-one-row/182)

<div class="topic-metadata">

**Author:** [@navessa](https://community.synatic.com/u/navessa)\
**Replies:** 0\
**Last updated:** [February 7, 2022, 12:06pm UTC](https://community.synatic.com/t/how-to-merge-every-2-records-into-one-row/182 "2022-02-07T12:06:58Z")

</div>

Illustrated in the below image is an example of a flow with the Record Generator step as the source step. In the below image, the Record Generator is populated with a field where the value will have a number next to …

---

## [How to convert a Base64 file to a string datatype](https://community.synatic.com/t/how-to-convert-a-base64-file-to-a-string-datatype/161)

<div class="topic-metadata">

**Author:** [@navessa](https://community.synatic.com/u/navessa)\
**Replies:** 0\
**Last updated:** [December 23, 2021, 3:12pm UTC](https://community.synatic.com/t/how-to-convert-a-base64-file-to-a-string-datatype/161 "2021-12-23T15:12:47Z")

</div>

The below code in the Calculator is used to convert a Base64 file to a string datatype. Copy and paste the code below: let base64String=createBuffer(input.record).toString(‘base64’); Additional information:

---

## [How to convert/ change a field to a value and to set the field name as the value in an object](https://community.synatic.com/t/how-to-convert-change-a-field-to-a-value-and-to-set-the-field-name-as-the-value-in-an-object/172)

<div class="topic-metadata">

**Author:** [@navessa](https://community.synatic.com/u/navessa)\
**Replies:** 0\
**Last updated:** [January 25, 2022, 4:39pm UTC](https://community.synatic.com/t/how-to-convert-change-a-field-to-a-value-and-to-set-the-field-name-as-the-value-in-an-object/172 "2022-01-25T16:39:28Z")

</div>

The below image is an example of a flow where a Record Generator step is used as a source step. In the Record Generator step, it is populated with a data load as per the image below. Illustrated in the image belo…

---

## [How to convert a value to a field in an object & set the value as null](https://community.synatic.com/t/how-to-convert-a-value-to-a-field-in-an-object-set-the-value-as-null/168)

<div class="topic-metadata">

**Author:** [@navessa](https://community.synatic.com/u/navessa)\
**Replies:** 0\
**Last updated:** [January 14, 2022, 4:52pm UTC](https://community.synatic.com/t/how-to-convert-a-value-to-a-field-in-an-object-set-the-value-as-null/168 "2022-01-14T16:52:21Z")

</div>

The below image is an example of a flow where a Record Generator step is used as a source step. In the Record Generator step, it is populated with a data load as per the image below. Illustrated in the image below …

---

## [How to capitalize the first letter of a value using handlebars/ string helpers](https://community.synatic.com/t/how-to-capitalize-the-first-letter-of-a-value-using-handlebars-string-helpers/171)

<div class="topic-metadata">

**Author:** [@navessa](https://community.synatic.com/u/navessa)\
**Replies:** 0\
**Last updated:** [January 24, 2022, 5:29pm UTC](https://community.synatic.com/t/how-to-capitalize-the-first-letter-of-a-value-using-handlebars-string-helpers/171 "2022-01-24T17:29:47Z")

</div>

In the below image, the Record Generator is used as the source step in this example. Illustrated in the below image is the data that is populated in the Record Generator step. Highlighted in yellow is the first letter…

---

## [How to join a key and value pair in an object](https://community.synatic.com/t/how-to-join-a-key-and-value-pair-in-an-object/164)

<div class="topic-metadata">

**Author:** [@navessa](https://community.synatic.com/u/navessa)\
**Replies:** 0\
**Last updated:** [January 7, 2022, 4:41pm UTC](https://community.synatic.com/t/how-to-join-a-key-and-value-pair-in-an-object/164 "2022-01-07T16:41:58Z")

</div>

The below image is an example of a flow where a Record Generator step is used as a source step. In the Record Generator step, it is populated with a data load as per the image below. Illustrated in the image below…

---

## [How to convert a number to have separators and rounding](https://community.synatic.com/t/how-to-convert-a-number-to-have-separators-and-rounding/132)

<div class="topic-metadata">

**Author:** [@navessa](https://community.synatic.com/u/navessa)\
**Replies:** 0\
**Last updated:** [November 5, 2021, 8:30am UTC](https://community.synatic.com/t/how-to-convert-a-number-to-have-separators-and-rounding/132 "2021-11-05T08:30:56Z")

</div>

This can be useful when working with numbers for measurements, currency, pricing, etc. It limits/ trims the numbers after the separator/ point to 2 decimal places. The number has to be in a number format and not a s…

---

## [Decoding a JWT Token](https://community.synatic.com/t/decoding-a-jwt-token/122)

<div class="topic-metadata">

**Author:** [@sanushin](https://community.synatic.com/u/sanushin)\
**Replies:** 0\
**Last updated:** [June 18, 2021, 11:07am UTC](https://community.synatic.com/t/decoding-a-jwt-token/122 "2021-06-18T11:07:26Z")

</div>

“JSON Web Tokens (JWT) are an open, industry standard \[RFC 7519\] method for representing claims securely between two parties.” - https://jwt.io/ To decode a token, the following logic can be used: JWT Token is receiv…

---

## [Cannot read property 'map' of undefined](https://community.synatic.com/t/cannot-read-property-map-of-undefined/65)

<div class="topic-metadata">

**Author:** [@shaun](https://community.synatic.com/u/shaun)\
**Replies:** 0\
**Last updated:** [March 5, 2021, 12:06pm UTC](https://community.synatic.com/t/cannot-read-property-map-of-undefined/65 "2021-03-05T12:06:12Z")

</div>

If you see the error “Cannot read property ‘map’ of undefined”, it implies you are trying to map to a empty array or set of values. Typically, the javascript code within the calculator will appear as below: inputRecord…

---

## [Miscellaneous Calculator Functions](https://community.synatic.com/t/miscellaneous-calculator-functions/64)

<div class="topic-metadata">

**Author:** [@martin](https://community.synatic.com/u/martin)\
**Replies:** 0\
**Last updated:** [March 4, 2021, 6:43pm UTC](https://community.synatic.com/t/miscellaneous-calculator-functions/64 "2021-03-04T18:43:05Z")

</div>

The calculator has several general helper functions: utils.hash(obj) Creates a unique string hash of the object. utils.round(num, precision) Rounds a float to the specified precision

---

## [String Helpers in Calculators](https://community.synatic.com/t/string-helpers-in-calculators/63)

<div class="topic-metadata">

**Author:** [@martin](https://community.synatic.com/u/martin)\
**Replies:** 0\
**Last updated:** [March 3, 2021, 8:39am UTC](https://community.synatic.com/t/string-helpers-in-calculators/63 "2021-03-03T08:39:40Z")

</div>

The calculator has a set of string helper functions under the stringHelper class Example let str=stringHelper.capitalize('this is a test'); //results in This Is A Test stringHelper.clean(s) Trim and replace multi…

---

## [Logging data for debugging](https://community.synatic.com/t/logging-data-for-debugging/62)

<div class="topic-metadata">

**Author:** [@martin](https://community.synatic.com/u/martin)\
**Replies:** 0\
**Last updated:** [March 2, 2021, 6:06pm UTC](https://community.synatic.com/t/logging-data-for-debugging/62 "2021-03-02T18:06:30Z")

</div>

It can sometimes be useful to log certain data in a calculator for debugging or trouble shooting reasons. You can do this by using the log event method: logEvent({Any}); This will write it to the event log of the run…

[Next page](https://community.synatic.com/c/faqs/calculators/14.md?page=1)
