Tools commands

Tools commands

AddFileToTool

Add a file to a tool/equipment.

Input

toolid

number

The ID of the tool to add the file to.

filename

string

The name of the file, eg. “MyDocument.PDF”

filedata

binary

A binary stream. base64_encode(Required)

title

string

A file title (not a file name)

folder

string

The path of the folder, eg. "FilesFromAPI/Diagrams"

Output

None

-

-

AddPhotoToTool

Add a photo file to a tool/equipment.

Input



toolid

number

The ID of the tool to add the photo to.

title

string

A file title (not a file name)

imagedata

binary

A binary stream containing photo data in jpeg format.

onxnet

boolean

1 if the file should be visible on the extranet

createdate

date

When the photo was taken

createtime

time

When the photo was taken

tags

collection [number]

An optional collection of tags to attach to this image (tag IDs)

documentid

number

Optional ID of an existing file, to update the file instead of creating a new file

Output



document

document

A document object

GetMyTools

Get all tools carried by the current user

Input

none

-

-

Output

tools

collection[tool]

Collection of all carried tools, or an empty collection if no tools are carried.



GetToolTypes

Get all tool types.

Input

none

-

-

Output

types

collection[ tooltype ]

Collection of tooltype objects

classes

set

List of classes, the key is the class ID, the value is the class name



GetToolStates

Get all tool states.

Input

none

-

-

Output

types

collection [ toolstate ]

Collection of states, each state is a set with id, title, color and access

If access is 0 then the user is not allowed to select the state, but the state may still be displayed whenever a tool/equipment has the state.



ToolAttachToCustomer

Attach a tool to a company.

If the specified customerid is 0 then the tool will be detached.

Input

toolid

number

The ID of a tool

customerid

number

The ID of a customer

Output

none



ToolAttachToTodo

Attach a tool to a todo.

If the specified todoid is 0 then the tool will be detached.

Input

toolid

number

The ID of a tool

todoid

number

The ID of a todo

Output

none



CreateUpdateTool

Creates or updates a tool in Microbizz.

If a tool with the given tool id already exists, then the tool will be overwritten.

If the tool provided has a tool id of 0, a new tool will be created and a new tool id will be provided.

Input

tool

tool

The tool to create/update

attachto

object

An object with objecttype and objectid

noactivate

boolean

Set to 1 to prevent the tool from being assigned to current user and activated

If attachto is specified then the tool will be attached to the object; the only objecttype that is supported is 'todo'.

Output

tool

tool

The tool object as it is in Microbizz after the update



GetToolsByLastChange

Get a collection of tools changed since a given date and time.

Input

changedate

date

Return all tools on or after the provided date.

changetime

time

If this is provided only return tools changed after the provided date and time.

resumekey

string

If a partial result is returned, provide the resumekey received along with the partial result, to get the rest of the entries

ignoreclosed

bool

If 1 then don't sent tools that current user do not have access to

placeofhome

number

If 1 then only get tools which have a “place of home”, if 2 then only get tools which do not have a “place of home”

skip_deleted

bool

If 1 then don't send deleted tools

Output

tools

collection[ tool ]

A collection of the relevant tools, or an empty collection if no tools were found.

resumekey

string

Sometimes the entire result cannot be returned because it's to large. In that case a resumekey is returned along with the results. Execute the command again with this resumekey to get the remaining results.

customerids

collection[number]

List of Microbizz ID of customers which have tools which the app should download in order to ensure that the tools are available in case the app is offline, see GetToolsByField



GetToolsByTodoID

Get a collection of tools that are attached to a task.

Input

todoid

number

Return all tools that are attached to the task with this ID.

knowntools

collection[tooldate]

List of known tools and their change dates

Output

tools

collection[tool]

A collection of the relevant tools, or an empty collection if no tools were found.

Each tooldate object should contain the following fields:

toolid

number

The Microbizz ID of a tool

changedate

date

The changedate field from the tool

changetime

time

The changetime field from the tool

Microbizz may use this information to avoid sending tools that have not changed.

GetToolsByField

Get a collection of tools where a given field matches a value.

Input

field

string

Return tools where this field has the value specified in value.

value

string | collection[string]

Return tools where the field specified in field has a value or an array of values.

knowntools

collection[tooldate]

List of known tools and their change dates, see GetToolsByTodoID

resumekey

string



inclpic

boolean

1 to include the tool picture in the reply

Output

tools

collection[ tool ]

A collection of the relevant tools, or an empty collection if no tools were found.

resumekey

string

Sometimes the entire result cannot be returned because it's to large. In that case a resumekey is returned along with the results. Execute the command again with this resumekey to get the remaining results.

GetToolByID

Get a tool by their Microbizz tool id, This also includes services connected to the tools.

If no such tool exist an empty collection will be returned.

Input

toolid

number

The microbizz tool id of the tool to fetch

inclpic

boolean

1 to include the tool picture in the reply

Output

tools

collection[tool]

A collection either empty if no tool was found, or with exactly one element being the tool.

picture

binary

The tool picture as a base64 encoded string, only if inclpic was set when called

GetNearbyTools

Get all tools near the given coordinate

Input

longitude

float

GPS longitude

latitude

float

GPS latitude

Output

tools

collection[tool]

Collection of all nearby tools (if any).

PickupTool

Pick up the tool with the given ID. This command will always succeed, but the return variable indicates if the tool was actually picked up.

Input

toolid

number

ID of the tool, to be picked up.

longitude

float

GPS longitude where the tool was picked up

latitude

float

GPS latitude where the tool was picked up

Output

waspickedup

boolean

Indicates if the tool was picked up.

tool

tool

If the tool was picked up, the tool object is provided in this field.

message

string

Additional message to display regarding the pickup.

SetDownTool

Sets down the tool with the given ID. This command will always succeed, but the return variable indicates if the tool was actually set down.

Input

toolid

number

ID of the tool, to be set down.

answer

answer

If a question form is requested on set down, the answer can be provided here.

longitude

float

GPS longitude where the tool is set down

latitude

float

GPS latitude where the tool is set down

Output

wassetdown

boolean

Indicates if the tool was set down.

UseTool

Uses the tool with the given ID.

Input

toolid

number

ID of the tool, to be used.

longitude

float

GPS longitude where the tool was used

latitude

float

GPS latitude where the tool was used

date

date

Date of usage

time

time

Time of usage

Output

None

-

-



InstallTool

Installs the tool with the given ID at the current location.

Input

toolid

number

ID of the tool, to be used.

longitude

float

GPS longitude where the tool was installed

latitude

float

GPS latitude where the tool was installed

date

date

Date of usage

time

time

Time of usage

Output

None

-

-

ToolServiceProtocol

This reports a equipment service/inspection.

Input

toolid

number

ID of the tool which was serviced

answers

set

The answers from each of the question forms that were filled in, the key is the ID of the question form; the answers must appear in the same order as specified by the tool service protocol

date

date

Date of the service

time

time

Time of the service

protocolid

number

The ID of the service protocol that was executed; strictly speaking it is not required but you should always specify it, if not specified then MB will assume it was the first protocol in the list

todos

set

A list of task IDs; the task ID is the value, the question form ID is the key

iscomplete

bool

1 if this is service is complete; 0 if this is a call to save for later; default is 1

The answers set has the question form ID as name (or key) and a formanswer as value.

Output

None

-

-

Incomplete service

If the field iscomplete is set to 0 then the service protocol is considered incomplete. This mean that the last answer in the answers set is incomplete; the answers before that are considered complete. F.eks. if the protocol specifies that the question forms with IDs 111, 222, 333 and 444 should be filled in (in that order), then an incomplete service protocol may only include answers for 111 and 222, and the answer for 222 will be considered incomplete.

GetToolService

This reads details about the service protocol that is in progress / has been saved for later.

Input

toolid

number

ID of a tool

Output

service

set

Details about the service protocol that is in progress, if any

If no service is in progress / has been saved for later then service is an empty set. Otherwise service holds the following fields:

userid

number

The ID of the user who saved the service for later

date

date

When the service was saved for later

time

time

When the service was saved for later

protocolid

number

The ID of the tool service protocol that is in progress, see GetToolServiceProtocols below

answerids

set

The IDs of the question answers that have been filled in so far, the key is the ID of the question form, use GetAnswer to read the actual answers

openqfid

number

The ID of the question form that the user was in the process of filling in when save for later was chosen; the question answers before this are considered complete



GetToolServiceProtocols

Get the list of available tool service/inspection protocols.

Input

multiple

bool

Indicates that the app understands having multiple service protocols, only old, outdated apps do not set this to 1

asarray

bool

Indicates that the result should be send as a collection, instead of as a set

inspections

bool

Indicates that the app wants both the service protocols and the inspection protocols

Output

protocols

set

List of service protocols

The list in protocols uses the equipment type ID as key.

If multiple isn't set then each item in the list is a collection of question form IDs.

If multiple is set then each item in the list is a set of serviceprotocol objects. If asarray is set then the list if a collection, an each serviceprotocol object includes a groupid field indicating the ID of the tool type.