Other functions
- Default functions
- allMatch
- getMainEnergyMeter
- convertUnit
- getFilePrivateUrl
- getUnit
- exportURL
- getOrgFileUrl
- getOrgDownloadUrl
- encodeFileToBase64Binary
- getTinyUrl
- getFileName
- picklist
- getUserName
- getUserEmail
- mergeJson
- getTimeIntervals
- getUserNameForId
- isUserInSiteScope
- getLatLngForSite
- encodeUrl
- exportURLAsFile
- tagAssetAsRotating
- updateStatus
- getDelegations
- getBlobFile
- getPermaLinkUrl
- getMaintenancePermaLinkUrl
- exportURLWithFileReturn
- getTransitionPermaLink
- getApprovalPermaLink
- getPermaLinkToken
- getAudiencePeople
- updateVendorPortalAccess
- revokeVendorPortalAccess
- updateTenantPortalAccess
- revokeTenantPortalAccess
- addInviteRecordViaV3Chain
- calculateHistoryForFormula
- postWithFiles
Default functions#
allMatch#
The allMatch() function takes list as an argument and returns true if all values in that list are same, or returns false.
Syntax:
new NameSpace("default").allMatch(
listlistVariable);
Parameters:
| Param | Data type | Description |
|---|---|---|
| listVariable | list | A list containing values. |
Returns: Boolean
Example:
listVariable = [1,1,1,1];response = new NameSpace("default").allMatch(listVariable);log response; //truegetMainEnergyMeter#
The getMainEnergyMeter() function takes buildingId as an argument and returns Main energy meter ID of the building.
Syntax:
new NameSpace( "default").getMainEnergyMeter(
NumberbuildingId);
Parameters:
| Param | Data type | Description |
|---|---|---|
| buildingId | Number | The buildingId of the main energy meter. |
Returns: String
Example:
buildingId = 1;mainEnergyMeterId = new NameSpace( "default").getMainEnergyMeter(buildingId);log mainEnergyMeterId;convertUnit#
The convertUnit() function takes value, fromUnit and toUnit as arguments and returns converted value.
Syntax:
new NameSpace( "default").convertUnit(
Numbervalue,NumberfromUnitId,NumbertoUnitId);
Parameters:
| Param | Data type | Description |
|---|---|---|
| value | Number | The value to be converted. |
| fromUnitId | Number | The Id of the convert from unit. |
| toUnitId | Number | The Id of the convert to unit. |
Returns: Number
Example:
value = 1000;fromUnit = "<from unit id>"; // millilitertoUnit = "<to unit id>"; // literconvertedValue = new NameSpace( "default").convertUnit(value, fromUnit, toUnit);log convertedValue;getFilePrivateUrl#
The getFilePrivateUrl() function will generate a new unique private URL for the given fileId.
Syntax:
new NameSpace( "default").getFilePrivateUrl(
NumberfileId);
Parameters:
| Param | Data type | Description |
|---|---|---|
| fileID | Number | The fileId to generate private URL. |
Returns: String
Example:
fileId = 1;privateURL = new NameSpace( "default").getFilePrivateUrl(fileId);log privateURL;getUnit#
The getUnit() function used to get display unit of the given fieldName and moduleName.
Syntax:
new NameSpace( "default").getUnit(
StringfieldName,StringmoduleName);
Parameters:
| Param | Data type | Description |
|---|---|---|
| fieldName | String | The field name to get display unit. |
| moduleName | String | The module name of the field. |
Returns: Number
Example:
fieldName = "cost";moduleName = "workorder";displayUnit = new NameSpace("default").getUnit(fieldName, moduleName);log displayUnit;exportURL#
The exportURL() function used to export an URL as PDF.
Syntax:
new NameSpace( "default").exportURL(
StringURL);
Parameters:
| Param | Data type | Description |
|---|---|---|
| URL | String | The url to be exported as PDF. |
Returns: String
Example:
url = "<some url>";exportedFileDownloadURL = new NameSpace("default").exportURL(url);log exportedFileDownloadURL;getOrgFileUrl#
The getOrgDownloadUrl() function is used to get Org file URL of the given fileId.
Syntax:
new NameSpace( "default").getOrgFileUrl(
NumberfileId);
Parameters:
| Param | Data type | Description |
|---|---|---|
| fileId | Number | The fileId to get file URL. |
Returns: String
Example:
fileId = 1;fileOrgURL = new NameSpace("default").getOrgFileUrl(fileId);log fileOrgURL;getOrgDownloadUrl#
The getOrgDownloadUrl() function is used to get download URL of the given fileId.
Syntax:
new NameSpace( "default").getOrgDownloadUrl(
NumberfileId);
Parameters:
| Param | Data type | Description |
|---|---|---|
| fileId | Number | The fileId to get download URL. |
Returns: String
Example:
fileId = 1;fileDownloadURL = new NameSpace("default").getOrgDownloadUrl(fileId);log fileDownloadURL;encodeFileToBase64Binary#
The encodeFileToBase64Binary() function is used to get encoded file in base64 binary format of the given fileId.
Syntax:
new NameSpace( "default").encodeFileToBase64Binary(
NumberfileId);
Parameters:
| Param | Data type | Description |
|---|---|---|
| fileId | Number | The fileId to get download URL. |
Returns: String
Example:
fileId = 1;encodedfile = new NameSpace("default").encodeFileToBase64Binary(fileId);log encodedfile;getTinyUrl#
The getTinyUrl() function is used to genrate short (tiny) URL from long URL.
Syntax:
new NameSpace( "default").getTinyUrl(
StringURL);
Parameters:
| Param | Data type | Description |
|---|---|---|
| URL | String | The URL to be shorten. |
Returns: String
Example:
longURL = "<some long url>";shortURL = new NameSpace("default").getTinyUrl(longURL);log shortURL;getFileName#
The getFileName() function used to get file name from the file id.
Syntax:
new NameSpace( "default").getFileName(
NumberfileId);
Parameters:
| Param | Data type | Description |
|---|---|---|
| fileId | Number | The Id of the file. |
Returns: String
Example:
fileId = 1;fileName = new NameSpace("default").getFileName(fileId);log fileName;picklist#
The picklist() function takes module name as input and returns picklist.
Syntax:
new NameSpace( "default").picklist(
Stringmodule);
Parameters:
| Param | Data type | Description |
|---|---|---|
| moduleName | String | The module name of the field. |
Returns: Map
Example:
pick = new NameSpace("default").picklist("workorder");log pick; //{6675775=Application Enable Access, 6723294=test, 6700293=Application Enable Access}getUserName#
The getUserName() function returns the name of the current user logged in.
Syntax:
new NameSpace( "default").getUserName();
Returns: String
Example:
name = new NameSpace("default").getUserName();log name;getUserEmail#
The getUserEmail() function returns the name of the current user logged in.
Syntax:
new NameSpace( "default").getUserEmail();
Returns: String
Example:
mail = new NameSpace("default").getUserEmail("workorder");log mail;mergeJson#
The mergeJson() function returns the merged json, it takes two json map as input.
Syntax:
new NameSpace("default").mergeJson(
MapparsedMap,MapparsedMap2);
Parameters:
| Param | Data type | Description |
|---|---|---|
| parsedMap | Map | The json containing map to which the other map is going to be merged. |
| parsedMap2 | Map | The other json map which needed to be merged. |
Returns: jsonMap
Example:
jsonString = "{\"employee\":{\"name\":\"User\",\"id\":1,\"role\":\"Manager\",\"department\":\"Engineering\"}}"; // escaped json stringparsedMap = new NameSpace("map").parse(jsonString);jsonString2 = "{\"employee\":{\"employ\":\"facilio\"}}";parsedMap2 = new NameSpace("map").parse(jsonString2);finalMap = new NameSpace("default").mergeJson(parsedMap,parsedMap2);log parsedMap; //{"employee":{"employ":"facilio","role":"Manager","name":"User","id":1,"department":"Engineering"}}getTimeIntervals#
The getTimeIntervals() function returns the list of intervals for the given startTime and endTime, provided in what interval should the time should be splitted.
Syntax:
new NameSpace("default").getTimeIntervals(
NumberstartTime,NumberendTime,NumberseperationTime);
Parameters:
| Param | Data type | Description |
|---|---|---|
| startTime | Number | The ending time for which interval should be splitted. |
| endTime | Number | The ending time for which interval should be splitted. |
| seperationTime | Number | This specifies in what interval the time between start and end time to be splitted(in seconds). |
Returns: List
Example:
intervals = new NameSpace("default").getTimeIntervals(1644387103000,1644473503000,300);log intervals;getUserNameForId#
The getUserNameForId() function returns the name of the given orgId.
Syntax:
new NameSpace("default").getUserNameForId(
Numberid);
Parameters:
| Param | Data type | Description |
|---|---|---|
| id | Number | The orgId for which the name to be generated. |
Returns: String
Example:
id=1;username = new NameSpace("default").getUserNameForId(id);log username;isUserInSiteScope#
The isUserInSiteScope() function returns whether true or false, if the assigned user id is present inside the site.
Syntax:
new NameSpace("default").isUserInSiteScope(
NumbersiteId,NumberassignedToId);
Parameters:
| Param | Data type | Description |
|---|---|---|
| siteId | Number | The siteId could be found on site tab. |
| assignedToId | Number | The assignedToId can be got from the name, check the workorder for name to whom it is assigned |
Returns: Boolean
Example:
bool_val = new NameSpace("default").isUserInSiteScope(2,1);log bool_val; //true or falsegetLatLngForSite#
The getLatLngForSite() function returns the url containing latitude and longitude of the site for given siteId.
Syntax:
new NameSpace("default").getLatLngForSite(
NumbersiteId);
Parameters:
| Param | Data type | Description |
|---|---|---|
| siteId | Number | The siteId could be found on site tab. |
Returns: String
Example:
latlongVal = new NameSpace("default").getLatLngForSite(1070146);log latlongVal; //https://www.google.com/maps?saddr=My+Location&daddr=13.0108917,80.2148945encodeUrl#
The encodeUrl() function returns the utf-8 encode url for the given url as input.
Syntax:
new NameSpace("default").encodeUrl(
Stringurl);
Parameters:
| Param | Data type | Description |
|---|---|---|
| url | String | Any URL to be encoded in UTF-8 fromat. |
Returns: String
Example:
url="https://stage.facilio.in/app/workflow";encoded_url = new NameSpace("default").encodeUrl(url);log encoded_url; //https%3A%2F%2Fstage.facilio.in%2Fapp%2FworkflowexportURLAsFile#
The exportURLAsFile() function takes url as input and returns the file id.
Syntax:
new NameSpace("default").exportURLAsFile(
Stringurl);
Parameters:
| Param | Data type | Description |
|---|---|---|
| url | String | Any URL to be converted to a file. |
Returns: Number
Example:
url="https://stage.facilio.in/app/workflow";encoded_url = new NameSpace("default").exportURLAsFile(url);log encoded_url; //54586624tagAssetAsRotating#
The tagAssetAsRotating() function takes the asset id as input, for which the tag is set as rotating.
Syntax:
new NameSpace("default").tagAssetAsRotating(
NumberassetId);
Parameters:
| Param | Data type | Description |
|---|---|---|
| assetId | Number | Id of the asset to tag it as rotating. |
Returns: Void
Example:
status = new NameSpace("default").tagAssetAsRotating(3);updateStatus#
The updateStatus() function takes the record, module name and status name as input and updates the status of that record.
Syntax:
new NameSpace("default").updateStatus(
Maprecord,StringmoduleName,StringstatusName);
Returns: Void
Example:
statusUpdate = new NameSpace("default").updateStatus(record,moduleName,statusName);log statusUpdate;getDelegations#
getDelegation function returns the list of assigned delegation.
Syntax:
new NameSpace("default").getDelegations();
Returns: List
Example:
response = new NameSpace("default").getDelegations();log response;getBlobFile#
The getBlobFile function hits the url,gets the file and saves the file and returns the fileId.
Syntax:
new NameSpace("default").getBlobFile(
Stringurl,Mapheaders,Mapparams,StringfileName,StringassetId);
Returns: Number
getPermaLinkUrl#
The getPermaLinkUrl() function is used to genrate Perma link URL from given URL.
Syntax:
new NameSpace( "default").getPermaLinkUrl(
StringURL,Stringtoken,NumberstartDate,NumberendDate,Stringuser);
Parameters:
| Param | Data type | Description |
|---|---|---|
| URL | String | The URL given. |
| user | String | The user. |
| token | String | The token to be given. |
| startDate | String | The starting date. |
| endDate | String | The ending date. |
Returns: String
Example:
URL = "<some long url>";user= "<user>";token = "<some token>";startDate = "<some date>";endDate = "<some date>";permaLinkURL = new NameSpace("default").getPermaLinkUrl(URL,token,startDate,endDate,user);log permaLinkURL;getMaintenancePermaLinkUrl#
The getMaintenancePermaLinkUrl function is used to generate maintenance perma link URL from given URL.
Syntax:
new NameSpace( "default").getMaintenancePermaLinkUrl(
StringURL,Stringtoken,NumberstartDate,NumberendDate,Stringuser,Stringdashboard);
Parameters:
| Param | Data type | Description |
|---|---|---|
| URL | String | The URL given. |
| user | String | The user. |
| token | String | The token to be given. |
| startDate | String | The starting date. |
| endDate | String | The ending date. |
| dashboard | String | The context. |
Returns: String
Example:
URL = "<some long url>";user= "<user>";token = "<some token>";startDate = "<some date>";endDate = "<some date>";dashboard = "<dashboard context>";mainPermaLinkURL = new NameSpace("default").getMaintenancePermaLinkUrl(URL,startDate,endDate,operatorId,user,dashboard);log mainPermaLinkURL;exportURLWithFileReturn#
The exportURLWithFileReturn() function used to export an URL as PDF and it returns the fileId.
Syntax:
new NameSpace( "default").exportURLWithFileReturn(
StringURL);
Parameters:
| Param | Data type | Description |
|---|---|---|
| URL | String | The url to be exported as PDF. |
Returns: Long
Example:
URL = "<some url>";fileId = new NameSpace("default").exportURLWithFileReturn(URL);log fileId;getTransitionPermaLink#
The getTransitionPermaLink function is used to generate transistion perma link URL from given URL when permalLinkURL,recordId and moduleName are given as input.
Syntax:
new NameSpace( "default").getTransitionPermaLink(
Stringdomain,LongrecordId,StringallowUrl,StringmoduleName);
Parameters:
| Param | Data type | Description |
|---|---|---|
| domain | String | The URL given. |
| recordId | Long | The recordId given. |
| allowUrl | String | The token to be given. |
| moduleName | String | The name of the module |
Returns: String
Example:
URL = "<some url>";recordId = 123;moduleName = "<any module>";allowUrl = "<the allowed urls>";permaLinkURL = new NameSpace("default").getTransitionPermaLink(domain,recordId,allowUrl,moduleName);log permaLinkURL;getApprovalPermaLink#
The getApprovalPermaLink function is used to generate approval link URL from given URL when permalLinkURL,recordId and moduleName are given as input.
Syntax:
new NameSpace( "default").getApprovalPermaLink(
LongrecordId,StringURL,StringmoduleName);
Parameters:
| Param | Data type | Description |
|---|---|---|
| domain | String | The URL given. |
| recordId | Long | The recordId given. |
| allowUrl | String | The token to be given. |
| moduleName | String | The name of the module |
Returns: String
Example:
URL = "<some url>";recordId = 123;moduleName = "<any module>";allowUrl = "<the allowed urls>";permaLinkURL = new NameSpace("default").getApprovalPermaLink(domain,recordId,allowUrl,moduleName);log permaLinkURL;getPermaLinkToken#
The getPermaLinkToken function is used to generate link URL token from given URL when permalLinkURL,recordId and moduleName are given as input.
Syntax:
new NameSpace( "default").getPermaLinkToken(
StringURL,MapsessionObject,Stringemail);
Parameters:
| Param | Data type | Description |
|---|---|---|
| sessionobj | Map | The recordId given. |
| URL | String | The URL given. |
| String | The emailId |
Returns: String
Example:
URL = "<some url>";emailid = "<some emailid>";sessionObj = "<session Object Map>";permaLinkURL = new NameSpace("default").getPermaLinkToken(sessionObj,URL,emailid);log permaLinkURL;getAudiencePeople#
The getAudiencePeople function is used to get all the audience people from given id,page,perpage is given.
Syntax:
new NameSpace( "default").getAudiencePeople(
ListId,Longpage,LongperPage);
Parameters:
| Param | Data type | Description |
|---|---|---|
| Id | List | Audience Id |
| page | Long | The page |
| perPage | Long | per page number |
Returns: List
Example:
id = "<some Ids>";page = "<page value>";perPage = "<per page count>";audience = new NameSpace("default").getAudiencePeople(id,page,perPage);log audience;updateVendorPortalAccess#
The updateVendorPortalAccess() function is used to update the access to the vendor portal.
Syntax:
new NameSpace("default").updateVendorPortalAccess(
LongvendorContactId ,LongvendorId);
Parameters:
| Param | Data type | Description |
|---|---|---|
| vendorContactId | Long | The vendor contactId |
| vendorId | Long | The vendor Id |
Returns: Void
Example:
vendorContactId="<some vendor contact>";vendorId="<vendorId>";new NameSpace("default").updateVendorPortalAccess(vendorContactId,vendorId);revokeVendorPortalAccess#
The revokeVendorPortalAccess() function is used to revoke the access to the vendor portal.
Syntax:
new NameSpace("default").revokeVendorPortalAccess(
StringvendorContactId ,StringvendorId);
Parameters:
| Param | Data type | Description |
|---|---|---|
| vendorContactId | String | The vendor contact |
| vendorId | String | The vendor Id |
Returns: Void
Example:
vendorContactId="<some vendor contact>";vendorId="<some vendor Id>";new NameSpace("default").revokeVendorPortalAccess(vendorContactId,vendorId);updateTenantPortalAccess#
The updateTenantPortalAccess() function is used to update the access to the tenant portal.
Syntax:
new NameSpace("default").updateTenantPortalAccess(
StringtenantContactId ,StringtenantId);
Parameters:
| Param | Data type | Description |
|---|---|---|
| tenantContactId | String | The tenant contact |
| tenantId | String | The tenantId |
Returns: Void
Example:
tenantContactId="<some tenant contact>";tenantId="<some tenantId>";new NameSpace("default").updateTenantPortalAccess(tenantContactId,tenantId);revokeTenantPortalAccess#
The revokeTenantPortalAccess() function is used to revoke the access to the tenant portal.
Syntax:
new NameSpace("default").revoketenantPortalAccess(
StringtenantContactId ,StringtenantId);
Parameters:
| Param | Data type | Description |
|---|---|---|
| tenantContactId | String | The tenant contact |
| tenantId | String | The tenantId |
Returns: Void
Example:
tenantContactId="<some tenant contact>";tenantId="<some tenantId>";new NameSpace("default").revokeTenantPortalAccess(tenantContactId,tenantId);
addInviteRecordViaV3Chain#
The addInviteRecordViaV3Chain function takes list of records and module name as an argument and add it to invites.
Syntax:
new NameSpace("default").addInviteRecordViaV3Chain(
Listrecords,StringmoduleName);
Parameters:
| Param | Data type | Description |
|---|---|---|
| records | list | A list containing records. |
| moduleName | String | The name of the module |
Returns: Void
Example:
recordList = "<some record list>";moduleName = "<some module name>";new NameSpace("default").addInviteRecordViaV3Chain(moduleName,recordList);calculateHistoryForFormula#
The calculateHistoryForFormula function takes formulaField, date range, formula and resourceList as an argument and schedule formula calculation.
Syntax:
new NameSpace("default").calculateHistoryForFormula(
LongformulaField,NumberstartTime,NumberendTime,ListresourceList,BooleanisInclude,Booleancalc_vm_through_formula,Booleanskip_optimised_wf);
Parameters:
| Param | Data type | Description |
|---|---|---|
| formulaField | Long | The formula field to be given |
| startTime | Number | The starting date. |
| endTime | Number | The ending date. |
| resourceList | List | The list of resourceId |
| isInclude | Boolean | To include the formula |
| calc_vm_through_formula | Boolean | To calculate through formula |
| skip_optimize_wf | Boolean | To skip optimized workflow |
Returns: String
Example:
formulaField = "<some formula field>";startTime = "<some date>";endTime = "<some date>";resourceList="[resource list]";isInclude = true;calculate_vm_through_formula = true;skip_optimised_workflow = true;status=new NameSpace("default").calculateHistoryForFormula(formulaField,startTime,endTime,resourceList,isInclude,calculate_vm_through_formula, skip_optimised_workflow);log status;postWithFiles#
The postWithFiles() function used to implement post along with the files when URL,header, param and fieldIdMap is given as input and returns the status.
Syntax:
new NameSpace( "default").postWithFiles(
StringURL,Mapheaders,Mapparams,MapfileIdMap);
Parameters:
| Param | Data type | Description |
|---|---|---|
| URL | String | The url to be posted. |
| headers | Map | The Map of headers. |
| params | Map | The Map of parameters. |
| fileIdMap | Map | The Map of fileId. |
Returns: String
Example:
URL = "<some url>";header = "<some headers>";params = "<some parameters>";fileIdMap="<some fileId>";status = new NameSpace("default").postWithFiles(URL,header,params,fileIdMap);log status;