0

When I am trying to convert a long string containing numbers to an integer using BIGINT in javascript for LWC it throws an error while editing that field in Omniscript. I want to take large input from UI which is text input having a large number of characters and make an addition to it in JS while converting it to an integer using BIGINT but that throws an error in UI when testing.

Am I missing some imports for this?

Example -:

console.log("numberstartNumberInt "+ BigInt("12345678901234567890222222222222"));

enter image description here

This page has an error. You might just need to refresh it. First, would you give us some details? (We're reporting this as error ID: -171077647)

These are the imports:-

import { LightningElement, track,api } from 'lwc';

import { OmniscriptBaseMixin } from "vlocity_cmt/omniscriptBaseMixin";

import { NavigationMixin } from 'lightning/navigation';

import { ShowToastEvent } from 'lightning/platformShowToastEvent';
1
  • 1
    If possible can you please provide the full LWC code? Commented Jun 25 at 11:55

1 Answer 1

0

Try this. I tried this code in LWC and hosted it on Omniscript. It is working as expected. Happy coding!


let num1 = "12345678901234567890123456789012";
let num2 = "98765432109876543210987654321098";

// Convert the strings to BigInt
let bigIntNum1 = BigInt(num1);
let bigIntNum2 = BigInt(num2);

// Add the two BigInt numbers
let sum = bigIntNum1 + bigIntNum2;

// Convert the result back to a string if needed
let sumString = sum.toString();

console.log('Sum is '+sumString);

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .