Documentation

Items

Scope: catalog Permissions: all

You can find more details in RPA documentation.

Because items for each process are stored in a separate table - IDs for items within different processes will match.

That's why process ID typeId must be passed to all methods

rpa.item.*

Method Description Available from version
rpa.item.get({typeId: number, id: number}) Passes information about item with ID id of process with ID typeId. Parameters:
  • typeId - process ID
  • id - item ID

Ответ

{
    "item": {
        "id": 43,
        "stageId": 4,
        "previousStageId": 3,
        "name": "Item name",
        "typeId": 1,
        "createdBy": 1,
        "updatedBy": 1,
        "createdTime": "19.03.2020 13:07:39",
        "updatedTime": "23.03.2020 18:34:05",
        "movedTime": "23.03.2020 18:34:05",
        "detailUrl": "/rpa/item/1/43/",
        "movedBy": 1,
        "UF_RPA_1_NAME": "Item name",
        "tasksCounter": 0,
        "tasksFaces": {
            "completed": [
                1
            ],
            "running": [
                
            ],
            "all": [
                1
            ]
        },
        "users": {
            "1": {
                "id": "1",
                "name": "Anton",
                "secondName": null,
                "lastName": "",
                "title": null,
                "workPosition": null,
                "fullName": "Anton",
                "link": "/company/personal/user/1/"
            }
        }
    }
}

Here

  • stageId - stage ID to move the item
  • previousStageId - previous item's stage ID
  • name - item name
  • typeId - process ID
  • createdBy - user ID who created the item
  • updatedBy - user ID who updated the item
  • movedBy - user ID who updated the item stage
  • createdTime - time when item is created
  • updatedTime - time when item is updated
  • movedTime - time item stage is updated
  • detailUrl - URL to item details form
  • tasksCounter - number of item's user assignments
  • tasksFaces - data to display sequence of responsible users during approval process
    • completed - who completed the assignment
    • running - who executed the assignment
    • all - all participants
  • users - aggregated information on all users that are associated with item. List, where the key - is user ID.
    • id - identifier
    • name - name
    • secondName - middle name
    • lastName - last name
    • title - title
    • workPosition - position
    • fullName - formatted name
    • link - URL to profile
  • UF_RPA_... - user field value
    • multiple fields' values as an array
    • value for "file" type fields are passed as a list
      • id - identifier
      • url - URL to file at the account
      • urlMachine - URL for file at the application
rpa.item.list({typeId: number, order: ?{} = null, filter: ?{} = null, start: ?number = 0}) Method returns array of items of process with ID typeId. Parameters:
  • typeId - process ID
  • order - list for sorting, where key is the field, and value - ASC or DESC
  • filter - list for filtration. Keys for filtration by user fields must be specified UPPER_CASE the rest - in camelCase. Examples of filters are below
  • start - start for pagewise navigation

Response will contain only main item fields without assignment and user item data

{
    "items": [
        {},
        {}
    ]
}
Examples of filter
  1. Find items that have incomplete assignments of current user
    {
        "filter": {
            "tasks": "has_tasks"
        }
    }
    

    To find items that don't have user assignments, pass the value no_tasks

  2. Find items updated by user with identifier 4
    {
        "filter": {
            "=updatedBy": "4"
        }
    }
    
  3. Find items updated or shifted by user with identifier 4
    {
        "filter": {
            "logic": "or",
            "0": {
                "=updatedBy": "4"
            },
            "1": {
                "=movedBy": "4"
            }
        }
    }
    
  4. Find items that have a completed user field with code UF_RPA_1_STRING
    {
        "filter": {
            "!=UF_RPA_1_STRING": "",
        }   
    }
    
  5. Find items created, updated and moved during the period from 19.03 to 22.03
    {
        "filter": {
            ">createdTime":"2020-03-19T02:00:00+02:00",
            ">movedTime":"2020-03-19T02:00:00+02:00",
            ">updatedTime":"2020-03-19T02:00:00+02:00",
            "<createdTime":"2020-03-22T02:00:00+02:00",
            "<movedTime":"2020-03-22T02:00:00+02:00",
            "<updatedTime":"2020-03-22T02:00:00+02:00"
        }
    }
    
  6. Find items created or moved during period from 19.03 to 22.03
    {
        "filter": {
            "logic":"OR",
            "0":{
                  ">createdTime":"2020-03-19T02:00:00+02:00",
                  "<createdTime":"2020-03-22T02:00:00+02:00"
            },
            "1":{
                  ">movedTime":"2020-03-19T02:00:00+02:00",
                  "<movedTime":"2020-03-22T02:00:00+02:00"
            },
            "2":{
                  ">updatedTime":"2020-03-19T02:00:00+02:00",
                  "<updatedTime":"2020-03-22T02:00:00+02:00"
            }
        }
    }
    
rpa.item.add({typeId: number, fields: ?{}) Method creates new process item with ID typeId. Parameters:
  • typeId - process ID
  • fields - item user field values. All the rest of fields will be ignored. This parameter is optional

After item is created, automation rules will be launched automatically

Method returns results similar to calling the method rpa.item.get for just created item

To upload the file, pass an array as user field value, where the first item - is file name, second item - is base64-encoded file content

rpa.item.update({typeId: number, id: number, fields: {}) Method updates item with ID id of process with ID typeId. Parameters:
  • typeId - process ID
  • id - item ID
  • fields - item user field values. Required parameter
    • fields[stageId] - stage ID
    • fields[UF_RPA_...] - user field values
Upload new file instead of old one (non-multiple field)

To replace file in a non-multiple field, just upload a new file. Old file will be deleted automatically

{
    "fields": {
        "UF_RPA_1_1585069397": [
             "myfile.pdf", "...base64_encoded_file_content..."
        ]
    }
}
Delete value of file type user field

Just pass an empty string ('') instead of value

Leave non-multiple value in the file type user field without changes

The simplest option: do not add key with this field in fields. But if you need to pass and not update, pass the a list as a value containing file identifier as the key id

{
    "fields": {
        "UF_RPA_1_1585069397": {
            "id": 433    
        }
    }
}

When a value different from the current value must be passed in id, the field value will zero out and file will be erased

Handling a file type multiple field

Multiple field value is an array. Each item of array is subordinate to the same rules as the non-multiple values.

Partial re-write of value for file type multiple field

For example, now file type multiple field stores the value [12, 255, 44]

Keep the file's 12 and 44 and upload new instead of 255

The query must look as follows:

{
    "fields": {
        "UF_RPA_1_1585069397": [
              {
                  "id": 12
              },
              {
                  "id": 44
              },
              [
                   "myNewFile.pdf", 
                   "...base64_encoded_file_content..."
              ]
        ]
    }
}
rpa.item.delete({typeId: number, id: number) Method deletes an item. Parameters:
  • typeId - process ID;
  • id - item ID.
rpa.item.getTasks({{typeId: number, id: number}) Methods returns data of current item assignments with id of process ID typeId. Parameters:
  • typeId - process ID
  • id - item ID

Example of response

{
    "tasks": [
        {
            "id": "93",
            "title": "asdf",
            "description": "",
            "userId": 1,
            "data": {
                "participantJoint": "or",
                "isMine": true,
                "controls": {
                    "BUTTONS": [
                        {
                            "TYPE": "submit",
                            "TARGET_USER_STATUS": 3,
                            "NAME": "complete",
                            "VALUE": "Y",
                            "TEXT": "Save",
                            "COLOR": "3bc8f5"
                        }
                    ]
                },
                "type": "RpaRequestActivity",
                "url": "/rpa/task/id/93/",
                "fieldsToShow": null,
                "fieldsToSet": [
                    "Name"
                ],
                "users": [
                    {
                        "id": 1,
                        "status": 0
                    }
                ]
            },
            "itemClassName": "BX.Rpa.Timeline.Assignment",
            "users": {
                "1": {
                    "id": "1",
                    "name": "Anton",
                    "secondName": "",
                    "lastName": "Gorbylev",
                    "title": null,
                    "workPosition": "",
                    "fullName": "John Smith",
                    "link": "/company/personal/user/1/"
                }
            }    
        }
    ]
}
© «Bitrix24», 2001-2024
Up