cancel
Showing results for 
Search instead for 
Did you mean: 

Java Script in SAP Build Apps

Rafael2493
Employee
Employee
0 Kudos

Hi,

Would like to ask if someone here has already used the JavaScript function in SAP Build Apps? I am new to Java Scripting and would like to see a guide on how to use this function as well as on what test cases can this be used.

Thank you

View Entire Topic
Dan_Wroblewski
Developer Advocate
Developer Advocate

You drag the flow function JavaScript into your logic flow.

If you double-click, you get the JavaScript editor.

  • You can define a set of inputs.
  • You can define a set of outputs. Each output represent an output node that can be used to continue the flow (above, my CheckLength has 2 outputs).

In the following, I have defined on the left a single input (which I can hardcode, set to a formula or variable), and 2 outputs on the right. Each output can provide a set of properties that can be passed o the following flow functions, just like Get record collection flow function will output a list of data.

The return statement will return an object, which is the default type for each output, though you can change this. If you have multiple outputs, you return a list, where the first item is a number indicating which output (starting with 0), and then the object.

More documentation: https://docs.appgyver.com/docs/custom-javascript

Just this week joe.binkley published a blog where he uses JavaScript to avoid a more complex flow function in his Tic-Tac-Toe game – https://groups.community.sap.com/t5/sap-builders-blog-posts/tic-tac-toe/ba-p/309372

Others use it to do things not available in other flow functions, like making HTTP calls or other JavaScript functions not exposed in the formula editor.

Hope this helps.

navalega0109
Participant
Dan_Wroblewski
Developer Advocate
Developer Advocate
0 Kudos
I'm not familiar with the Firebase use case (not the primary use case for SAP Build Apps anymore, it seems). I don't know if it will be related, but there seems to be a new version mostly surrounding BTP authentication available on mobile -- already available on web -- and this may help you. I would imagine another month. Of course, others using Firebase may be able to help sooner.