Newbie here. I have figured out how to connect my Xano data base to a weweb collection. In it I have a field called cost, which is stored as a decimal. I have successfully linked it to a text field but I cannot for the life of me figure out how to now format it as $currency. How do you do this?
Welcome.
What currency do you want to format it as?
I live in USA. So, I created a custom function to convert an integer.
Here is how you can do it:
-
Click on the data tab in the tool bar
-
Click on +Add Formula
-
name the formula. I used toCurrency
-
add 1 parameter, name it whatever you want (I used āitemā), and select number from the drop down.
-
in the function box, you will want to use something like below. The below code is JS that will take the incoming parameter, and apply the toLocaleString() Js function to it and return that.
return "$" + item.toLocaleString("en-US", {
style: 'currency',
currency: 'USD'
});
There are all types of different options in the toLocaleString, so google that and youāll find your country.
Once you have that done, now you can use the function anywhere in your site.
Go to the text that you currently have bound to your database. Click on the functions area (see image below), scroll down, and click on Custom.
This will show your custom function.
Use that, and put your decimal database value into there. It will return your currency.
OKā¦I think I get it, though I thought the whole point of this was nocodeā¦
But when I try it I get an error.
Hereās my formula entry which seemed to go well:
Appreciate your help!
Hmm. That looks good. Can you take out the item[ādataā][ācpuā] and just put in a number.
try toCurrency(25)
Does that work?
Also, you wonāt need the ā$ā +, since that will come through the toLocaleString function.
Also, I donāt know what that means. Iām guessing you are suggesting dropping the ā$ā + from the formula definition. which I will try.
Ah! I see it! You need a comma after currency:āUSDā
It should be currency: āUSDā,
Kevin, THANK YOU! that fixed it.
Nicely done! Well done to both of you
You could probably put something similar with the existing math and slice no-code formulas but @kevinwasieās solution is more elegant.
Iāve added āno-code currency styling formulasā to our list of product improvement requests so itās more straightforward in the future
Thanks Joyce!
Iāve been watching all of your videos. They are incredibly helpful. Thank you so much. Iām a bubbler and the transition was a bit rough at first, but I think Iām starting to get the hang of it as I slowly rebuild a former bubble app on weweb/Xano. Front end design is so much easier as is some of the logic of state/variable management. Though database integration is still a learning curve for me.
One ask for a video or tutorialā¦
A commonly used feature in bubble for me is the checkbox called āEnable auto-binding on parent elementās thingā. When checked for an element (say a text box in a repeating group), the controls allow the user to edit the field and on update, reflect the change results back into the data of the āThingā. I use this when I donāt want the properly permissioned user to have to open a separate form or pop-up simply to edit and submit a record. To mimic this functionality in WeWeb I assume I need to use a form control (say short text), populate itās initial value with the current database value, then create a workflow action for the field that if updated, on change, posts the revision back to Xano using a POST Api. Yet for the life of me I havenāt been able to figure out how to do it, so Iām guessing I might be setting up the POST wrong.
Is there a tutorial that might help me understand how to replicate this, āauto-bindingā functionality?
Al
Hi @Aloy
Thank you for the kind words, really appreciate it!
Hereās a tutorial on how to pre-fill a form with the current database value. The tutorial is with Airtable but the logic is the same for Xano except, as you mention, youāll have to create your own POST request.
Can you maybe create a new topic in the community and share a loom showing how things are currently setup in Xano and WeWeb, what youāre trying to do, and what error message you get from Xano when you test the action?
(a separate topic would be great because it helps others search for answers)
Can you please share an example of how to do it the no code way, also if there is a way to format for %