Skip to main content

Other functions

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(list listVariable);

Parameters:

ParamData typeDescription
listVariablelistA list containing values.

Returns: Boolean

Example:

listVariable = [1,1,1,1];response = new NameSpace("default").allMatch(listVariable);log response;  //true

getMainEnergyMeter#

The getMainEnergyMeter() function takes buildingId as an argument and returns Main energy meter ID of the building.

Syntax:

new NameSpace( "default").getMainEnergyMeter(Number buildingId);

Parameters:

ParamData typeDescription
buildingIdNumberThe 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(Number value, Number fromUnitId, Number toUnitId);

Parameters:

ParamData typeDescription
valueNumberThe value to be converted.
fromUnitIdNumberThe Id of the convert from unit.
toUnitIdNumberThe 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(Number fileId);

Parameters:

ParamData typeDescription
fileIDNumberThe 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(String fieldName, String moduleName);

Parameters:

ParamData typeDescription
fieldNameStringThe field name to get display unit.
moduleNameStringThe 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(String URL);

Parameters:

ParamData typeDescription
URLStringThe 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(Number fileId);

Parameters:

ParamData typeDescription
fileIdNumberThe 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(Number fileId);

Parameters:

ParamData typeDescription
fileIdNumberThe 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(Number fileId);

Parameters:

ParamData typeDescription
fileIdNumberThe 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(String URL);

Parameters:

ParamData typeDescription
URLStringThe 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(Number fileId);

Parameters:

ParamData typeDescription
fileIdNumberThe 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(String module);

Parameters:

ParamData typeDescription
moduleNameStringThe 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(Map parsedMap,Map parsedMap2);

Parameters:

ParamData typeDescription
parsedMapMapThe json containing map to which the other map is going to be merged.
parsedMap2MapThe 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(Number startTime,Number endTime, Number seperationTime);

Parameters:

ParamData typeDescription
startTimeNumberThe ending time for which interval should be splitted.
endTimeNumberThe ending time for which interval should be splitted.
seperationTimeNumberThis 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(Number id);

Parameters:

ParamData typeDescription
idNumberThe 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(Number siteId,Number assignedToId);

Parameters:

ParamData typeDescription
siteIdNumberThe siteId could be found on site tab.
assignedToIdNumberThe 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

getLatLngForSite#

The getLatLngForSite() function returns the url containing latitude and longitude of the site for given siteId.

Syntax:

new NameSpace("default").getLatLngForSite(Number siteId);

Parameters:

ParamData typeDescription
siteIdNumberThe 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

encodeUrl#

The encodeUrl() function returns the utf-8 encode url for the given url as input.

Syntax:

new NameSpace("default").encodeUrl(String url);

Parameters:

ParamData typeDescription
urlStringAny 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

exportURLAsFile#

The exportURLAsFile() function takes url as input and returns the file id.

Syntax:

new NameSpace("default").exportURLAsFile(String url);

Parameters:

ParamData typeDescription
urlStringAny 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

tagAssetAsRotating#

The tagAssetAsRotating() function takes the asset id as input, for which the tag is set as rotating.

Syntax:

new NameSpace("default").tagAssetAsRotating(Number assetId);

Parameters:

ParamData typeDescription
assetIdNumberId 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(Map record,String moduleName,String statusName);

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(String url,Map headers,Map params,String fileName,String assetId);

Returns: Number

getPermaLinkUrl#

The 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:

ParamData typeDescription
URLStringThe URL given.
userStringThe user.
tokenStringThe token to be given.
startDateStringThe starting date.
endDateStringThe 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(String URL, String token, Number startDate, Number endDate, String user, String dashboard);

Parameters:

ParamData typeDescription
URLStringThe URL given.
userStringThe user.
tokenStringThe token to be given.
startDateStringThe starting date.
endDateStringThe ending date.
dashboardStringThe 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(String URL);

Parameters:

ParamData typeDescription
URLStringThe 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(String domain,Long recordId,String allowUrl, String moduleName);

Parameters:

ParamData typeDescription
domainStringThe URL given.
recordIdLongThe recordId given.
allowUrlStringThe token to be given.
moduleNameStringThe 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(Long recordId,String URL,String moduleName);

Parameters:

ParamData typeDescription
domainStringThe URL given.
recordIdLongThe recordId given.
allowUrlStringThe token to be given.
moduleNameStringThe 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(String URL, Map sessionObject, String email);

Parameters:

ParamData typeDescription
sessionobjMapThe recordId given.
URLStringThe URL given.
EmailStringThe 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(List Id, Long page, Long perPage);

Parameters:

ParamData typeDescription
IdListAudience Id
pageLongThe page
perPageLongper 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(Long vendorContactId ,Long vendorId);

Parameters:

ParamData typeDescription
vendorContactIdLongThe vendor contactId
vendorIdLongThe 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(String vendorContactId ,String vendorId);

Parameters:

ParamData typeDescription
vendorContactIdStringThe vendor contact
vendorIdStringThe 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(String tenantContactId ,String tenantId);

Parameters:

ParamData typeDescription
tenantContactIdStringThe tenant contact
tenantIdStringThe 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(String tenantContactId ,String tenantId);

Parameters:

ParamData typeDescription
tenantContactIdStringThe tenant contact
tenantIdStringThe 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(List records,String moduleName);

Parameters:

ParamData typeDescription
recordslistA list containing records.
moduleNameStringThe 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(Long formulaField,Number startTime,Number endTime, List resourceList, Boolean isInclude, Boolean calc_vm_through_formula, Boolean skip_optimised_wf);

Parameters:

ParamData typeDescription
formulaFieldLongThe formula field to be given
startTimeNumberThe starting date.
endTimeNumberThe ending date.
resourceListListThe list of resourceId
isIncludeBooleanTo include the formula
calc_vm_through_formulaBooleanTo calculate through formula
skip_optimize_wfBooleanTo 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(String URL,Map headers, Map params, Map fileIdMap);

Parameters:

ParamData typeDescription
URLStringThe url to be posted.
headersMapThe Map of headers.
paramsMapThe Map of parameters.
fileIdMapMapThe 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;