How to get GPS Coordinates in Action Item script

pbodlev
Tera Contributor

Hello,

 

In mobile app builder I have created custom form and I wanted to track user's location when user submit the form.

 

I have added GPS Coordinates to my Input Form Screen. But when I try to access this variable in action item script - its empty. I have turned on Location tracking on my mobile device.

 

Thanx!

2 REPLIES 2

Jakub M
Tera Contributor

Hey @pbodlev I had similar problem recently.

 

If you will assign your input variable to some variable and then use function to change the format you will be able to use it. Some code below: 

var coordinates = parm_variable["coordinates"];
	if (coordinates != undefined) {
        input.Coordinate = new sn_fsm_mobile.FSMMobileAppUtil().formatGPSCoordinates(coordinates);
    } else {
        input.Coordinate = '';
    }

You can find this example in "wot_check_in" Action item (part of FSM plugin)

YazminM
Giga Contributor

I faced a similar issue recently as well. The approach that worked for me was to first assign the input variable to a local variable, and then use a function to format it before setting the final value. For example, I used parm_variable["coordinates"] and passed it through formatGPSCoordinates() from FSMMobileAppUtil.