- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2023 05:57 AM
Hi,
I am working on a Flow Designer for using the Terraform third party API. One of the requirements is to pass the value on one of the Catalog Item fields to the Flow. The field is asking for the user to "Provide Drive Size in GBs". Unfortunately, the Terraform needs that value in Megabytes.
I need to convert whatever Gigabytes the user provides into Megabytes. Does anyone have a script that will help me to convert this?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2023 07:41 AM
Well this should suffice
var gb = 1; // take this as input form variable or field
var mb = parseInt(gb)*1024;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2023 03:19 PM
Hi, an exact script is dependent on a number of values that are not included in your post, required final format - decimal or binary; The format of your source data string\text, or some sort of numerical value.
Javascript will normally recognize and process string representations of numerical values correctly if you are using mathematical formula,
if it does not you can use one of the javascript number methods to convert the string to a numerical value before your calculation. eg parseInt() or parseFloat()
JavaScript Number Reference (w3schools.com)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2023 07:35 AM - edited 07-05-2023 07:35 AM
I know that 1 GB equals 1024 MB. So if the user puts 8 GB in the string text field (which is set to only accept numbers), I need to multiple that number by 1024 to get the MB number.
I just need a little help with script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2023 07:41 AM
Well this should suffice
var gb = 1; // take this as input form variable or field
var mb = parseInt(gb)*1024;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2023 09:57 AM
Thank you, @Anurag Tripathi