The class you will need to make a Restful API call is WebServices
Please refer to attached eForm for a working sample by uploading to your Company. This sample form will match the project users which this form is working under. By doing so, you can manage your users via the Admin Portal, and let the form to pick up the users that are available dynamically without modifying and uploading the data file.
Note: You will need to change the Authorization information under the web service header section based on your company setting.
To initialize a call, you will need to assign the endpoint your web services provider is located using
Endpoint: Web services provider URI
Method: GET, POST
then, you can add the HhtmlHeader where the Authorization or other information that is required from your Web services provider.
Header: Header Vame (ex: Authorization)
Value: Header Value (ex: Basic Token)
You could also add a parameter to your API request as follows:
Key: Parameter Key (ex: ID)
Value: Parameter Value (ex: 5)
Below is a complete Sample of calling Field2Base UserAPI Web Service.
WebServices.addHtmlHeader("Authorization", "Authentication CompanyID:Username:Password:API_Token);
Please check the Authorization required in calling F2B Web Services is in the following format:
CompanyID: Your F2B company ID
Username: Your API Account
Password: Your API Account Password
API_Token: Your API Sync Key
Befoe digging into the code, let's take a look on the response from this UserAPI Web Service.
Now, let's look at the sample of the handleUserList function
var projectID = Field2Base.getProjectId();
var username = Field2Base.getUsername();
var resultObj = eval(result);
var userList = ;
for (var i=0; i < resultObj.length; i++)
if(resultObj[i].UserName == username) continue; // Skip current user
for(var j=0; j< resultObj[i].Projects.length; j++)
if(resultObj[i].Projects[j] == projectID)
userList.push(resultObj[i].UserName); // If project ID matched, push into userList array
First, the Web Services will return a string(result) that contains the JSON data we see above.
We can get the current project ID by using Field2Base.getProjectId(), then match each of the return user's project record into userList array. Finally, assign the datasource with this array
Let's give it a try in our Mobile Form...