Search code examples
javascriptdata-bindingsyntaxgoogle-app-maker

Is there any formal documentation for Google App Maker syntax?


I'm developing an app using Google AppMaker. I don't have a lot of coding experience, so I'm learning as I go. I'm stuck on transforming a binded boolean value. I want the values to be Yes for true and No for false.

Using the documentation for App Maker, I tried both fromBoolean and boolToStr transformers, but they both return errors like "At column 69: Expected ')', but instead was (." So I looked up correct JavaScript syntax via Javascript.info and just got even more confused.

Here's what I've tried so far:

@datasources.AffectedFacilities.item.Cross_Bore_Involved_2#boolToStr(("0")= 'false', ("") = 'true');
@datasources.AffectedFacilities.item.Cross_Bore_Involved_2#fromBool(0 = 'NO', 1 = 'YES');

Instead of seeing the boolean fields converted, I just receive syntax errors. I just need to see coding examples, and the Google documentation doesn't offer that.


Solution

  • Based on the documentation here https://developers-dot-devsite-v2-prod.appspot.com/appmaker/scripting/api/transformers#boolToNum using 'boolToStr' is a literal transformer converting the true value to 'true'. And based on the documentation here https://developers-dot-devsite-v2-prod.appspot.com/appmaker/scripting/api/transformers#fromBoolean using 'fromBoolean' interprets a 'yes' into true.

    What you would want to do in your case is:

    @datasources.AffectedFacilities.item.Cross_Bore_Involved ? 'Yes' : 'No'