JavaScript Reference

JavaScript Reference

Overview

Form Designers with knowledge of JavaScript can add business rules and customized actions to their Field2Base Forms. You can access the Forms Designer script editor by clicking on the Script icon in the Home tab. The JavaScript Sample Form 7.0 attached at the bottom of this article contains examples of all available script calls.



Events


Form_Started()

Event raised when the user starts work on a new form.

  1. function Form_Started() {
  2.     var objUser = Field2Base.getUser();   
  3.     var userFullName = objUser.firstName + " " + objUser.lastName;
  4.     Form.getRegion("Page3@Form_Started_Message").setValue("The Form Draft has been opened by " + userFullName + ".");
  5. }

Form_Validating(objValidationLog)

Event raised before the form gets sent. You can use objValidationLog.addRegionErrorMessage to display a validation error and prevent the user from sending the form until conditions are met.

objValidationLog.addRegionErrorMessage(region, strMessage)
The Validation Log records problems discovered during form validation. If the log contains any entries then the form cannot be sent. This method will only work in the Form_Validating() function.

  1. function Form_Validating(objValidationLog) {
  2.     var rgnValidation = Form.getRegion("Page3@Form_Validating_Required");
  3.     if (!rgnValidation.getValue()) {
  4.         objValidationLog.addRegionErrorMessage(rgnValidation, "Please fill out the Form Validating Region before sending.");
  5.     }
  6. }

Form_Sending()

Event raised after the user specifies that the form is ready to be sent. Be cautious about script in the Sending event. You generally should not make changes to form data because the user may not have a chance to see and validate the new values. If the user opens and resends a form (for example, as part of a workflow), the Sending event will be raised again. Users may also have an option to resend a form without opening it, in which case the Sending event may not be raised before re-transmitting form data. The Sending event may also be raised multiple times before sending the form if the client gives the user a way to cancel the transmission after the event has already been raised. 

  1. function Form_Sending() {
  2.     Form.getRegion("Page3@Form_Sending_Message").setValue("The Form has been sent.");
  3. }

Form_DataChanged(objArgs)

Event raised when the value is changed in any Region on the form.

  1. function Form_DataChanged(objArgs) {
  2.     var rgnCurrent = objArgs.getRegion();
  3.     var regionName = rgnCurrent.getName();
  4.     if (regionName.indexOf("Rating") >= 0) {
  5.         var regionValue = rgnCurrent.getValue();
  6.         var lineNum = regionName.slice(7);
  7.         var pageNum = rgnCurrent.getOwningPage().getUserPageNumber();
  8.         var rgnWarning = Form.getRegion("Page" + pageNum + "@Warning_" + lineNum);
  9.         if (regionValue <= 2) {            
  10.             rgnWarning.setValue("! LOW");
  11.         } else {
  12.             rgnWarning.clearValue();
  13.         }
  14.     }
  15. }
Note: When adding script to the Form_DataChanged event, you may encounter data processing errors if you have a large number of regions with initial values. In order to avoid this error and unnecessary data processing, you should create IF statements to narrow down the targeted regions before manipulating region values. For example, in the script above, the Region Name must contain "Rating" before any values are changed inside the body of the IF statement, as opposed to being globally declared within the Form_DataChanged event.

PageNum_Region_ValueChanged(objArgs)

Event raised when a single Region's value is changed.

  1. function Page4_Text_To_Change_ValueChanged(objArgs) {
  2.     var count = Form.getRegion("Page4@Count_hidden").getValue();
  3.     var pluralTime = "time";
  4.     count++;
  5.     if (count > 1) {
  6.         pluralTime = "times";
  7.     }
  8.     Form.getRegion("Page4@Count_hidden").setValue(count);
  9.     Form.getRegion("Page4@Value_Changed_Count").setValue("The region has been changed " + count + " " + pluralTime + ".");
  10. }

PageNum_Region_DoneInking(objArgs)

Event raised 3 seconds after a user stops inking in a Region. 

  1. function Page4_Signature_DoneInking(objArgs) {
  2.     if (objArgs.getRegion().getHasStrokes()) {    
  3.         var timestamp = new Date().getTime();
  4.         var convertedTimestamp = new Date(timestamp);
  5.         var month = (convertedTimestamp.getMonth() + 1);
  6.         var day = convertedTimestamp.getDate();
  7.         var year = convertedTimestamp.getFullYear();
  8.         Form.getRegion("Page4@Signature_Date").setValue("Signed on: " + month + "/" + day + "/" + year);        
  9.     } else { 
  10.         Form.getRegion("Page4@Signature_Date").clearValue();
  11.     }
  12. }
Note: Global variables do not work consistently across all platforms. We do not recommend using global variables. In cases where global variables are needed, you can use a hidden region to store a value that can be used like a global variable in your script. To hide a region, right click on the region and choose "Remove from Page".


Form

The Form class is the root node in the form object tree. There is a global instance called Form that is the object for the user's current eForm.

Form.getName()

Returns the name of the Form Template.

  1. function getFormName() {
  2.     var formName = Form.getName();
  3.     Form.getRegion("Page5@FormName").setValue(formName);
  4. }


Form.getPagesCount()

Returns the number of pages in the Form.

  1. function getFormPageCount() {
  2.     var pageCount = Form.getPagesCount();
  3.     Form.getRegion("Page5@PageCount").setValue(pageCount);
  4. }


Form.getPageByUserPageNumber(pgNum)

Returns the page with the given user page number.

  1. function changeRegionValueUsingPageNumber() {
  2.     var pg5 = Form.getPageByUserPageNumber(5);
  3.     pg5.getRegion("GetPageByNumber").setValue("This Region has been changed using Form.getPageByUserPageNumber().");
  4. }


Form.getPageAtIndex(pgNum)

Returns the page at the given position at the given index. The index is the 0-based position of the page in the Form.

  1. function getIndex() {
  2.     var pgIndex4 = Form.getPageAtIndex(4);
  3.     var pageIndex = Form.getPageIndex(pgIndex4);
  4.     pgIndex4.getRegion("PageIndex").setValue(pageIndex);  
  5. }


Form.getPageIndex(page)

Returns an integer of the index of the given page. The index is the 0-based position of the page in the Form. 

Note: The index, unlike the user page number, will change if a page is inserted before it.
  1. function getIndex() {
  2.     var pgIndex4 = Form.getPageAtIndex(4);
  3.     var pageIndex = Form.getPageIndex(pgIndex4);
  4.     pgIndex4.getRegion("PageIndex").setValue(pageIndex);  
  5. }


Form.insertPage(page, pgIndex)

Inserts a given page into the Form at the given index.

  1. function insertOrderPage() {
  2.     var pgOrderOfOps = Form.getPageByUserPageNumber(2);
  3.     var pgNewOrderOfOps = pgOrderOfOps.duplicateTemplate();
  4.     Form.insertPage(pgNewOrderOfOps, Form.getPagesCount());
  5. }

Form.getRegion(rgnName)

Returns the given Region.

  1. function changeRegionValueUsingForm() {
  2.     Form.getRegion("Page5@FormGetRegion").setValue("This Region has been changed using Form.getRegion().");
  3. }


Form.lockRegionValues()

Locks all Regions in the Form.

  1. function lockAll() {
  2.     Form.lockRegionValues();
  3. }

Form.unlockRegionValues()

Unlocks all Regions in the Form.

  1. function unlockAll() {
  2.     Form.unlockRegionValues();
  3. }


Page

The Page class is a container for Regions.

Page.getName()

Returns the name of a page.

  1. function getPageName() {
  2.     var pageName = Form.getPageByUserPageNumber(6).getName();
  3.     Form.getRegion("Page6@PageName").setValue(pageName);
  4. }


Page.setName(newName)

Sets the name of a page.

  1. function changePageName() {
  2.     var newPageName = Form.getRegion("Page6@NewPageName").getValue();
  3.     Form.getPageByUserPageNumber(6).setName(newPageName);
  4. }


Page.getUserPageNumber()

Returns the page number of a page.

  1. function getPageNumber() {
  2.     var pageNumber = Form.getPageAtIndex(5).getUserPageNumber();
  3.     Form.getRegion("Page" + pageNumber +"@PageNumber").setValue(pageNumber);
  4. }


Page.setVisible(boolean)

Sets whether a page is visible or not.

  1. function toggleVisibility() {
  2.     var pgOrderOfOps = Form.getPageByUserPageNumber(2);
  3.     var isVisible = pgOrderOfOps.getVisible();
  4.     if (isVisible) {
  5.         pgOrderOfOps.setVisible(false);
  6.     } else {
  7.         pgOrderOfOps.setVisible(true);
  8.     }
  9. }

Page.getVisible()

Returns boolean for whether or not a page is visible or not.

  1. function viewIsVisible() {
  2.     var pgOrderOfOps = Form.getPageByUserPageNumber(2);
  3.     var isVisible = pgOrderOfOps.getVisible();
  4.     Form.getRegion("Page7@Visibility").setValue(isVisible);
  5. }

 

Page.duplicateTemplate()

Returns a copy of the page template (background and Regions). The page data is not copied.

  1. function insertOrderPage() {
  2.     var pgOrderOfOps = Form.getPageByUserPageNumber(2);
  3.     var pgNewOrderOfOps = pgOrderOfOps.duplicateTemplate();
  4.     Form.insertPage(pgNewOrderOfOps, Form.getPagesCount());
  5. }

 

Page.getRegion(rgnName)

Returns the specified Region on a page.

  1. function changeRegionValueUsingPage() {
  2.     var pg7 = Form.getPageByUserPageNumber(7);
  3.     pg7.getRegion("PageGetRegion").setValue("This Region has been changed using Page.getRegion().");
  4. }

 

Page.lockRegionValues()

Locks all Regions on a page.

  1. function lockAllPage() {
  2.     var pg7 = Form.getPageByUserPageNumber(7);
  3.     pg7.lockRegionValues();
  4. }


Page.unlockRegionValues()

Unlocks all Regions on a page.

  1. function unlockAllPage() {
  2.     var pg7 = Form.getPageByUserPageNumber(7);
  3.     pg7.unlockRegionValues();
  4. }



Region

The Region class represents fields on the Form.

Region.setValue(newValue)

Sets the value of the Region.

  1. function changeRegionValue() {
  2.     var rgnExample = Form.getRegion("Page8@RegionExample");
  3.     rgnExample.setValue("This Region has been set using Region.setValue().");
  4. }


Region.getValue()

Returns the value of the Region.
  1. function getRegionValue() {
  2.     var rgnExample = Form.getRegion("Page8@RegionExample");
  3.     var exampleRegionValue = rgnExample.getValue();
  4.     View.showDialog("The value of the top region is: " + exampleRegionValue, 0);
  5. }

Region.clearValue()

Clears the value of the Region.

  1. function clearRegionValue() {
  2.    var rgnExample = Form.getRegion("Page8@RegionExample");
  3.    rgnExample.clearValue();
  4. }


Region.lockValue()

Locks the Region.

  1. function lockRegion() {
  2.     var rgnExample = Form.getRegion("Page8@RegionExample");
  3.     rgnExample.lockValue();
  4. }


Region.unlockValue()

Unlocks the Region.

  1. function unlockRegion() {
  2.     var rgnExample = Form.getRegion("Page8@RegionExample");
  3.     rgnExample.unlockValue();
  4. }


Region.getIsLocked()

Returns a boolean of whether the Region is locked or unlocked.

  1. function checkRegionLocked() {
  2.     var rgnExample = Form.getRegion("Page8@RegionExample");
  3.     var regionLocked = rgnExample.getIsLocked();
  4.     Form.getRegion("Page8@RegionCheckLocked").setValue(regionLocked);
  5. }


Region.setIsRequired(boolean)

Sets whether the Region is required or not.

  1. function requireRegion() {
  2.     var rgnExample = Form.getRegion("Page8@RegionExample");
  3.     rgnExample.setIsRequired(true);
  4. }

  1. function doNotRequireRegion() {
  2.     var rgnExample = Form.getRegion("Page8@RegionExample");
  3.     rgnExample.setIsRequired(false);
  4. }


Region.isRequired()

Returns a boolean of whether the Region is required or not.

  1. function checkRegionRequired() {
  2.     var rgnExample = Form.getRegion("Page8@RegionExample");
  3.     var checkRequired = rgnExample.isRequired();
  4.     Form.getRegion("Page8@RegionCheckRequired").setValue(checkRequired);
  5. }


Region.getName()

Returns the name of the Region.
  1. function getRegionName() {
  2.     var rgnExample = Form.getRegion("Page8@RegionExample");
  3.     var regionName = rgnExample.getName();
  4.     Form.getRegion("Page8@RegionGetName").setValue(regionName);
  5. }


Region.getOwningPage()

Returns the page that the Region is on.

  1. function getRegionPage() {
  2.     var rgnExample = Form.getRegion("Page8@RegionExample");
  3.     var page = rgnExample.getOwningPage();
  4.     var pageName = page.getName();
  5.     Form.getRegion("Page8@RegionGetPageName").setValue(pageName);
  6. }


CAMERA REGIONS

Region.getHasImage()

Returns a boolean of whether the Camera Region has an image or not.

  1. function checkCameraImage() {
  2.     var rgnCameraExample = Form.getRegion("Page9@CameraExample");
  3.     var checkImage = rgnCameraExample.getHasImage();
  4.     Form.getRegion("Page9@CameraCheckImage").setValue(checkImage);
  5. }


Region.clearImage()

Clears the current image from the Camera Region.

  1. function clearCameraImage() {
  2.    var rgnCameraExample = Form.getRegion("Page9@CameraExample");
  3.    rgnCameraExample.clearImage();
  4. }


CHECKBOX REGIONS

Region.setChecked(boolean)

Sets the Checkbox Region to checked or unchecked.

  1. function toggleCheckboxRegion() {
  2.     var rgnCheckboxExample = Form.getRegion("Page9@CheckboxExample");
  3.     var checked = rgnCheckboxExample.getChecked();
  4.     if (!checked) {
  5.         rgnCheckboxExample.setChecked(true);
  6.     } else {
  7.         rgnCheckboxExample.setChecked(false);
  8.     }
  9. }


Region.getChecked()

Returns a boolean of whether the Checkbox Region is currently checked or unchecked.

  1. function checkCheckboxRegion() {
  2.     var rgnCheckboxExample = Form.getRegion("Page9@CheckboxExample");
  3.     var checked = rgnCheckboxExample.getChecked();
  4.     Form.getRegion("Page9@CheckboxCheck").setValue(checked);
  5. }


DATASOURCE REGIONS

Region.hasDatasourceList()

Returns boolean of whether the Datasource Region has a list or not. 

  1. function checkDatasourceRegion() {
  2.     var rgnDatasourceExample = Form.getRegion("Page10@DatasourceExample");
  3.     var hasList = rgnDatasourceExample.hasDatasourceList();
  4.     Form.getRegion("Page10@DatasourceCheckList").setValue(hasList);
  5. }


Region.getDatasourceList()

Returns an array of the list for the Datasource Region.

  1. function getList() {
  2.     var rgnDatasourceExample = Form.getRegion("Page10@DatasourceExample");
  3.     var list = rgnDatasourceExample.getDatasourceList();
  4.     Form.getRegion("Page10@DatasourceList").setValue(list);
  5. }

 

Region.setDatasourceList(array)

Sets the list for the Datasource Region. The parameter must be an array of string values.

  1. function replaceList() {
  2.     var rgnDatasourceExample = Form.getRegion("Page10@DatasourceExample");
  3.     var newListArr = ["new item 1","new item 2", "new item 3"];
  4.     rgnDatasourceExample.setDatasourceList(newListArr);
  5. }


GPS REGIONS

Region.takeLatestCoordinate()

Returns the most recent location as the value for a GPS region.

Note: May be a stale value if the Form has stopped receiving location updates or it may not have any value if the Form has not yet received any location updates.
  1. function getGPSCoordinates() {
  2.     var rgnGPS = Form.getRegion("Page10@GPSCoordinates");
  3.     rgnGPS.takeLatestCoordinate();
  4. }


Region.getCoordinates() 

Returns an object containing the latitude, longitude, elevation, and timestamp for the most recent location. Only latitude and longitude are guaranteed to be present; elevation and timestamp may be null. When timestamp is present, it is a UTC value formatted as an ISO 8601 string.
Note: This method only works in eForm Templates Version 7.0 and higher.
  1. function getGPSObject() {
  2.     var rgnGPSObject = Form.getRegion("Page10@GPSObject");
  3.     var latitude = rgnGPSObject.getCoordinates().latitude;
  4.     var longitude = rgnGPSObject.getCoordinates().longitude;
  5.     var elevation = rgnGPSObject.getCoordinates().elevation;
  6.     var timestamp = rgnGPSObject.getCoordinates().timestamp;
  7.     Form.getRegion("Page10@GPSDisplay").setValue("Latitude: " + latitude + "\nLongitude: " + longitude + "\nElevation: " + elevation + "\nTimestamp: " + timestamp);
  8. }

PEN REGIONS

Region.getHasStrokes()

Returns a boolean of whether the Pen Region contains any ink strokes or not.

  1. function checkPenRegion() {
  2.     var rgnPenExample = Form.getRegion("Page11@PenExample");
  3.     var hasStrokes = rgnPenExample.getHasStrokes();
  4.     Form.getRegion("Page11@PenCheck").setValue(hasStrokes);
  5. }

 

Region.clearStrokes()

Clears all ink strokes from the Pen Region.

  1. function clearPenRegion() {
  2.     var rgnPenExample = Form.getRegion("Page11@PenExample");
  3.     rgnPenExample.clearStrokes();
  4. }



View

The View class exposes control features for an eForm editing view. There is a single global instance called View that lets script access the client's currently active view if there is one. If a client supports more than one open eForm view then this instance will manipulate whichever view the client has specified as the active view, which may change as the user works with the form.

View.showDialog(strMessage, intDialogType, callback)

Shows a popup message box with a message and a chosen button configuration. The button configuration specifies which buttons are available for the user to select.

Possible button configurations are:
0 OK
1 OK, Cancel
3 Yes, No, Cancel
4 Yes, No
The return value indicates which button the user chose. Values are:
1 OK
2 Cancel
6 Yes
7 No
  1. function view0() {
  2.     View.showDialog("Are You Sure?", 0, "dialogResultHandler0");
  3. }
  4. function dialogResultHandler0(result){
  5.     var returnValue;
  6.     if (result == 1) {
  7.          returnValue = "OK";
  8.     }  
  9.     Form.getRegion("Page12@Dialog0").setValue("You clicked: " + returnValue);
  10. }

  1. function view1() {
  2.     View.showDialog("Are You Sure?", 1, "dialogResultHandler1");
  3. }
  4. function dialogResultHandler1(result){
  5.     var returnValue;
  6.     if (result == 1) {
  7.          returnValue = "OK";
  8.     } else if (result == 2) {
  9.         returnValue = "Cancel";
  10.     }
  11.     Form.getRegion("Page12@Dialog1").setValue("You clicked: " + returnValue);
  12. }

  1. function view3() {
  2.     View.showDialog("Are You Sure?", 3, "dialogResultHandler3");
  3. }
  4. function dialogResultHandler3(result){
  5.     var returnValue;
  6.     if (result == 2) {
  7.         returnValue = "Cancel";
  8.     } else if (result == 6) {
  9.         returnValue = "Yes";
  10.     } else if (result == 7) {
  11.        returnValue = "No";
  12.     }
  13.     Form.getRegion("Page12@Dialog3").setValue("You clicked: " + returnValue);
  14. }

  1. function view4() {
  2.     View.showDialog("Are You Sure?", 4, "dialogResultHandler4");
  3. }
  4. function dialogResultHandler4(result){
  5.     var returnValue;
  6.     if (result == 6) {
  7.         returnValue = "Yes";
  8.     } else if (result == 7) {
  9.        returnValue = "No";
  10.     }
  11.     Form.getRegion("Page12@Dialog4").setValue("You clicked: " + returnValue);
  12. }

View.openURL(strURL)

Opens a URL in a web browser. For web sites, the URL string must include the "http://" or "https://" for the method to run correctly. The default browser will be used to open the URL specified.

  1. function openF2BSite() {
  2.     View.openURL("http://www.field2base.com");
  3. }

View.openURL(strURL, boolean)

Note: This method only works in eForm Templates Version 7.0 and higher.

Set boolean to true to open the URL in a Web View within the Mobile Forms app. False opens the URL in an external browser (default).
  1. function openF2BSiteWebView() {
  2.     View.openURL("http://www.field2base.com", true);
  3. }

View.showUserPageNumber(pgNum)

Navigates to the specified page.

  1. function goToMainMenu() {
  2.     View.showUserPageNumber(1);
  3. }



Field2Base

The Field2Base class provides information about the current F2B user's session. There is a single global instance called Field2Base.

Field2Base.send()

Sends the current draft. This initiates validation and other send processing. Calling this method is equivalent to the user clicking Send in the App UI. All validation and on-send processing occurs as it normally would. 

  1. function submitForm() {
  2.     Field2Base.send();
  3. }


Field2Base.closeDraft(boolPrompt)

Closes the current draft and uses the boolean parameter to show (true) or not show (false) the Save Draft prompt. If using 'false', the draft is automatically discarded.

This function cannot be called from the Form_Sending Event, and it does not factor in the Save Draft Prompt config; it uses the boolean parameter instead, overriding the Save Draft Prompt config.
  1. function closeDraftPrompt() {
  2.     Field2Base.closeDraft(true);
  3. }


  1. function closeDraftNoPrompt() {
  2.     Field2Base.closeDraft(false);
  3. }

Field2Base.getUser()

Note: This method only works in eForm Templates Version 7.0 and higher.
Returns an object with User information.
  1. function getUserInfo() {
  2.     var objUser = Field2Base.getUser();
  3.     var firstName = objUser.firstName;
  4.     var lastName = objUser.lastName;
  5.     var email = objUser.email;
  6.     var username = objUser.username;
  7.     // Personnel must be enabled for the company for the following details to be available
  8.     var ID = objUser.personnelID;  
  9.     var title = objUser.jobTitle;
  10.     var type = objUser.personnelType;
  11.     var defaultLocation = objUser.defaultLocation;  
  12.     var defaultApproval = objUser.defaultGroup;
  13.  
  14.     Form.getRegion("Page13@UserInfo").setValue("First name: " + firstName + "   Last name: " + lastName + "\nEmail: " + email + "\nUsername: " + username + "\nID: " + ID + "   Title: " + title + "   Type: " + type + "\nLocation: " + defaultLocation + "   Approval: " + defaultApproval);
  15. }

Field2Base.getUsername()

Returns the username of the logged-in User.

  1. function getUsername() {
  2.     Form.getRegion("Page13@Username").setValue(Field2Base.getUsername());
  3. }


Field2Base.getUserFirstName()

Returns the first name of the logged-in User.

  1. function getFirstName() {
  2.     Form.getRegion("Page13@FirstName").setValue(Field2Base.getUserFirstName());
  3. }


Field2Base.getUserLastName()

Returns the last name of the logged-in User.

  1. function getLastName() {
  2.     Form.getRegion("Page13@LastName").setValue(Field2Base.getUserLastName());
  3. }


Field2Base.getUserPhoneNumber()

Returns the phone number of the logged-in User.

There is no validation on the Phone Number field in the User Profile so other information (employee ID, etc...) can be used to be pulled into forms.
  1. function getPhoneNumber() {
  2.     Form.getRegion("Page14@PhoneNumber").setValue(Field2Base.getUserPhoneNumber());
  3. }


Field2Base.getUserEmail()

Returns the e-mail address of the logged-in User.

  1. function getEmail() {
  2.     Form.getRegion("Page14@Email").setValue(Field2Base.getUserEmail());
  3. }

Field2Base.getLocationNames() 

Note: This method only works in eForm Templates Version 7.0 and higher.
Note: Locations must be enabled for the company.
Returns an array of the Location names.
  1. function getLocations() {
  2.     var locations = Field2Base.getLocationNames();

  3.     Form.getRegion("Page14@Locations").setDatasourceList(locations);
  4. }

Field2Base.getLocationDetails(LocationName)

Returns an object with the details for the specified Location.
  1. function getDetails() {
  2.     var locations = Field2Base.getLocationNames();
  3.     var location1Obj = Field2Base.getLocationDetails(locations[0]);
  4.     var name = location1Obj.name;
  5.     var type = location1Obj.type;
  6.     var contact = location1Obj.contactName;
  7.     var contactEmail = location1Obj.contactEmail;
  8.     var contactPhone = location1Obj.contactPhone;
  9.     var group = location1Obj.groupName;
  10.     var requirements = location1Obj.requirements;

  11.     Form.getRegion("Page14@LocationDetails").setValue("Name: " + name + "   Type: " + type + "\nContact: " + contact + "   Email: " + contactEmail + "   Phone: " + contactPhone + "\nGroup: " + group + "\nRequirements: " + requirements);
  12. }

Field2Base.getProjectId()

Returns the unique id of the Form's Folder.

  1. function getFolderID() {
  2.     Form.getRegion("Page14@FolderID").setValue(Field2Base.getProjectId());
  3. }


Field2Base.getProjectName()

Returns the name of the form's Folder.

  1. function getFolderName() {
  2.     Form.getRegion("Page14@FolderName").setValue(Field2Base.getProjectName());
  3. }

 


Environment and Locale

The Environment class provides information about the current environment where the app is running and returns the current Locale object of the Environment which can only be used in conjunction with the Locale properties (Code, Language, and Region). 

Note: This is not implemented on Web App.

Environment.getCurrentLocale().getCode()

Returns the full language and territory code of the Locale instance. Typically, the two letter language code and the two letter territory code that will be separated by a hyphen or an underscore. For example, a device running the US English Language would have a code of "en_US" or "en-US". The codes returned are dependent on the Operating System so it is NOT recommended as the best way to determine a User's Language due to the lack of uniform returned values.

  1. function getPlatformCode() {
  2.     var code = Environment.getCurrentLocale().getCode();
  3.     Form.getRegion("Page15@LocaleCode").setValue(code);
  4. }


Environment.getCurrentLocale().getLanguage()

Returns the language code of the Locale instance. Typically, the two letter language code will be returned for this property. For that reason, this is the recommended way to determine a User's Language.

  1. function getPlatformLanguage() {
  2.     var lang = Environment.getCurrentLocale().getLanguage();
  3.     Form.getRegion("Page15@LocaleLanguage").setValue(lang);
  4. }


Environment.getCurrentLocale().getRegion()

Returns the region (or territory) code of the Locale instance. Typically, the two letter territory code will be returned for this property so values like "US" for the United States or "GB" for Great Britain will be returned.

  1. function getPlatformRegion() {
  2.     var region = Environment.getCurrentLocale().getRegion();
  3.     Form.getRegion("Page15@LocaleRegion").setValue(region);
  4. }



    • Popular Articles

    • Forms Designer Quick Start Guide

      Overview Field2Base Forms Designer is the proprietary software application that allows your existing paper forms to be quickly converted to a smart E-form available to your end users via our mobile and web-based Mobile Forms applications. This ...
    • Portal 11.28.2023 Release Notes

      Overview Our release notes offer brief descriptions of product enhancements and bug fixes. We include links to the current articles for any affected features. Those articles will be updated shortly after the Portal release to include new ...
    • Integration Service Configuration Guide

      How To Configure Integration Services To Allow Read/Write Access on a Network Path All of our Integration Products, including the DIM, DUU, and EDM have respective Windows Services responsible for communicating with our server. Occassionally, ...
    • Data Integration Module (DIM) Migration Guide

      Overview This article provides the information necessary to migrate the Field2Base Data Integration Module (DIM) over from one server to another. Please refer to the DIM Install Guide for the initial installation of the Field2Base DIM. Once that's ...
    • How to Check the Version of Integration Products Running on a Windows 10 Machine

      Right-click on the Start menu button. Click on Apps & Features. In the Apps & Features search bar type in the Integration Product you are looking for, eg. F2B Data Integration Module, F2B Data Upload, or F2B Enterprise Dispatch Module. Click to ...