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#
allMatchThe 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(
list
listVariable);
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; //true
#
getMainEnergyMeterThe getMainEnergyMeter() function takes buildingId as an argument and returns Main energy meter ID of the building.
Syntax:
new NameSpace( "default").getMainEnergyMeter(
Number
buildingId);
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;
#
convertUnitThe convertUnit() function takes value, fromUnit and toUnit as arguments and returns converted value.
Syntax:
new NameSpace( "default").convertUnit(
Number
value,Number
fromUnitId,Number
toUnitId);
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;
#
getFilePrivateUrlThe getFilePrivateUrl() function will generate a new unique private URL for the given fileId.
Syntax:
new NameSpace( "default").getFilePrivateUrl(
Number
fileId);
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;
#
getUnitThe getUnit() function used to get display unit of the given fieldName and moduleName.
Syntax:
new NameSpace( "default").getUnit(
String
fieldName,String
moduleName);
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;
#
exportURLThe exportURL() function used to export an URL as PDF.
Syntax:
new NameSpace( "default").exportURL(
String
URL);
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;
#
getOrgFileUrlThe getOrgDownloadUrl() function is used to get Org file URL of the given fileId.
Syntax:
new NameSpace( "default").getOrgFileUrl(
Number
fileId);
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;
#
getOrgDownloadUrlThe getOrgDownloadUrl() function is used to get download URL of the given fileId.
Syntax:
new NameSpace( "default").getOrgDownloadUrl(
Number
fileId);
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;
#
encodeFileToBase64BinaryThe encodeFileToBase64Binary() function is used to get encoded file in base64 binary format of the given fileId.
Syntax:
new NameSpace( "default").encodeFileToBase64Binary(
Number
fileId);
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;
#
getTinyUrlThe getTinyUrl() function is used to genrate short (tiny) URL from long URL.
Syntax:
new NameSpace( "default").getTinyUrl(
String
URL);
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;
#
getFileNameThe getFileName() function used to get file name from the file id.
Syntax:
new NameSpace( "default").getFileName(
Number
fileId);
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;
#
picklistThe picklist() function takes module name as input and returns picklist.
Syntax:
new NameSpace( "default").picklist(
String
module);
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}
#
getUserNameThe 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;
#
getUserEmailThe 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;
#
mergeJsonThe mergeJson() function returns the merged json, it takes two json map as input.
Syntax:
new NameSpace("default").mergeJson(
Map
parsedMap,Map
parsedMap2);
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"}}
#
getTimeIntervalsThe 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(
Number
startTime,Number
endTime,Number
seperationTime);
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;
#
getUserNameForIdThe getUserNameForId() function returns the name of the given orgId.
Syntax:
new NameSpace("default").getUserNameForId(
Number
id);
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;
#
isUserInSiteScopeThe isUserInSiteScope() function returns whether true or false, if the assigned user id is present inside the site.
Syntax:
new NameSpace("default").isUserInSiteScope(
Number
siteId,Number
assignedToId);
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 false
#
getLatLngForSiteThe getLatLngForSite() function returns the url containing latitude and longitude of the site for given siteId.
Syntax:
new NameSpace("default").getLatLngForSite(
Number
siteId);
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.2148945
#
encodeUrlThe encodeUrl() function returns the utf-8 encode url for the given url as input.
Syntax:
new NameSpace("default").encodeUrl(
String
url);
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%2Fworkflow
#
exportURLAsFileThe exportURLAsFile() function takes url as input and returns the file id.
Syntax:
new NameSpace("default").exportURLAsFile(
String
url);
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; //54586624
#
tagAssetAsRotatingThe tagAssetAsRotating() function takes the asset id as input, for which the tag is set as rotating.
Syntax:
new NameSpace("default").tagAssetAsRotating(
Number
assetId);
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);
#
updateStatusThe updateStatus() function takes the record, module name and status name as input and updates the status of that record.
Syntax:
new NameSpace("default").updateStatus(
Map
record,String
moduleName,String
statusName);
Returns: Void
Example:
statusUpdate = new NameSpace("default").updateStatus(record,moduleName,statusName);log statusUpdate;
#
getDelegationsgetDelegation function returns the list of assigned delegation.
Syntax:
new NameSpace("default").getDelegations();
Returns: List
Example:
response = new NameSpace("default").getDelegations();log response;
#
getBlobFileThe getBlobFile function hits the url,gets the file and saves the file and returns the fileId.
Syntax:
new NameSpace("default").getBlobFile(
String
url,Map
headers,Map
params,String
fileName,String
assetId);
Returns: Number
#
getPermaLinkUrlThe getPermaLinkUrl() function is used to genrate Perma link URL from given URL.
Syntax:
new NameSpace( "default").getPermaLinkUrl(
String
URL,String
token,Number
startDate,Number
endDate,String
user);
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;
#
getMaintenancePermaLinkUrlThe getMaintenancePermaLinkUrl function is used to generate maintenance perma link URL from given URL.
Syntax:
new NameSpace( "default").getMaintenancePermaLinkUrl(
String
URL,String
token,Number
startDate,Number
endDate,String
user,String
dashboard);
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;
#
exportURLWithFileReturnThe exportURLWithFileReturn() function used to export an URL as PDF and it returns the fileId.
Syntax:
new NameSpace( "default").exportURLWithFileReturn(
String
URL);
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;
#
getTransitionPermaLinkThe 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(
String
domain,Long
recordId,String
allowUrl,String
moduleName);
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;
#
getApprovalPermaLinkThe 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(
Long
recordId,String
URL,String
moduleName);
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;
#
getPermaLinkTokenThe 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(
String
URL,Map
sessionObject,String
email);
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;
#
getAudiencePeopleThe getAudiencePeople function is used to get all the audience people from given id,page,perpage is given.
Syntax:
new NameSpace( "default").getAudiencePeople(
List
Id,Long
page,Long
perPage);
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;
#
updateVendorPortalAccessThe updateVendorPortalAccess() function is used to update the access to the vendor portal.
Syntax:
new NameSpace("default").updateVendorPortalAccess(
Long
vendorContactId ,Long
vendorId);
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);
#
revokeVendorPortalAccessThe revokeVendorPortalAccess() function is used to revoke the access to the vendor portal.
Syntax:
new NameSpace("default").revokeVendorPortalAccess(
String
vendorContactId ,String
vendorId);
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);
#
updateTenantPortalAccessThe updateTenantPortalAccess() function is used to update the access to the tenant portal.
Syntax:
new NameSpace("default").updateTenantPortalAccess(
String
tenantContactId ,String
tenantId);
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);
#
revokeTenantPortalAccessThe revokeTenantPortalAccess() function is used to revoke the access to the tenant portal.
Syntax:
new NameSpace("default").revoketenantPortalAccess(
String
tenantContactId ,String
tenantId);
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);
#
addInviteRecordViaV3ChainThe addInviteRecordViaV3Chain function takes list of records and module name as an argument and add it to invites.
Syntax:
new NameSpace("default").addInviteRecordViaV3Chain(
List
records,String
moduleName);
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);
#
calculateHistoryForFormulaThe calculateHistoryForFormula function takes formulaField, date range, formula and resourceList as an argument and schedule formula calculation.
Syntax:
new NameSpace("default").calculateHistoryForFormula(
Long
formulaField,Number
startTime,Number
endTime,List
resourceList,Boolean
isInclude,Boolean
calc_vm_through_formula,Boolean
skip_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;
#
postWithFilesThe 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(
String
URL,Map
headers,Map
params,Map
fileIdMap);
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;