Plugin cookbook
The reference and a set of recipes for people who write plugins. New to this? Do the tutorial first (it builds a complete plugin step by step), then come here to look things up: where a plugin can show up, which right opens which data, what the answers look like, and how to do the usual things.
How it fits together
- A plugin is a folder of static files (
.html,.js,.css, images) and onercplugin.json. It is packed as a.zipor.tar.gzand uploaded by an RC Admin (or installed from the catalog). - The platform shows a page of the plugin in a frame (a sandbox). The frame has no cookies and cannot touch the page around it. Everything goes through the object
rcof the SDK, which the page loads with<script src="_rc/sdk.js">. rc.apicalls the REST API as the person who looks at the page. The rule is: what the person may do ∩ what the administrator granted. A plugin therefore never sees more than the person; two colleagues using the same plugin see different data.- The plugin has no database. It keeps small JSON documents with
rc.storage; they are removed with the plugin. - No code of a plugin ever runs on the Resourcecloud server. For logic that must run on a server, use a remote plugin: a page of your server shown in the app.
Where a plugin can show up
A plugin lists its places in slots. It can use several. Every place is a page of the plugin (its entry) shown in a frame.
| Place | What it is | Good for | ctx.object | Example |
|---|---|---|---|---|
menu.page | A page of its own An entry in the menu section Plugins (which appears as soon as a plugin has one) opens /plugin?id=…: the page fills the content area under the app's top bar and menu. Several menu pages per plugin are allowed. | Tools, dashboards of your own, directories, whiteboards. | null | teams.html (Slots tour), radar.html (Task Radar) |
task.card | A card on every task A card in the task editor, one per plugin, titled with the slot's label (or the plugin name). The card is as high as its content (rc.ui.autoResize()). ctx.object is the task. | Context for a task: related records from your systems, checklists, quick actions. | {type:"task", id} | task.html (Slots tour), card.html (Task Radar) |
project.tab | A tab on every project A tab in the project page next to Description, Communication, Attachments ... The tab is named by the label; its content fills the tab. ctx.object is the project. | Project facts, risks, budgets from your finance system, a project wiki. | {type:"project", id} | project.html (Slots tour) |
dashboard.card | A card on the worker dashboard A card at the bottom of the personal worker dashboard (Dashboards → Worker), one per plugin. The card is as high as its content. No object. | Numbers and lists the person wants at a glance: my open tasks, a status of your systems. | null | dashboard.html (Slots tour) |
settings.page | A settings page for the administrator Not in the menu: the plugin's row in Settings → Plugins gets a Settings button that opens the page ( /plugin?id=…&slot=settings.page), for RC Admins only. The plugin acts as that administrator. Store what you configure in shared storage (storage:shared). | Configuration of the plugin: thresholds, which teams, which server. | null | settings.html (Slots tour) |
Can a plugin add its own menu items?
Yes, in one place: menu.page adds an entry to the menu section "Plugins", sorted by plugin name, with the label you give (in several languages if you wish). The section appears when a plugin has such a slot. A plugin cannot put an entry into another menu section (Work, Projects, Admin ...), cannot reorder the menu and cannot add entries to the top bar or a context menu. If you need more places in the menu, make several menu.page slots; if you need a place that does not exist, tell us: a new place is a small, deliberate change on our side, so that every place is reviewed for what it may expose.
The manifest, field by field
{
"id": "com.mycompany.example", // required: lower case, dots/hyphens; never changes
"name": { "en": "Example", "de": "Beispiel" }, // required: text, or one text per language (max 150 characters)
"description": { "en": "...", "de": "..." }, // optional, up to 1000 characters; shown in the lists and the consent dialog
"version": "1.2.0", // required: three numbers; every upload must be higher
"type": "ui", // "ui" (files in the package, default) or "remote" (a page of your own server)
"author": { "name": "My Company", "url": "https://mycompany.example" }, // optional
"rc_min": 282, // optional: the lowest database version of the platform this plugin works with
"permissions": ["tasks:read", "storage:user"], // what the plugin needs; the administrator agrees to it at install
"optional_permissions": ["tasks:comment"], // nice to have; the administrator may decline each one
"network": ["https://api.mycompany.example"], // servers the plugin may contact (max 10, https origins)
"events": ["task.updated"], // events the page tells the plugin about
"requires_modules": ["projects"], // modules that must be on (the plugin is hidden while one is off)
"slots": [
{ "slot": "menu.page", "entry": "index.html", "label": { "en": "Example", "de": "Beispiel" } },
{ "slot": "task.card", "entry": "card.html" }
]
}JSON has no comments: remove the // remarks above before you use this as a manifest. A label is required for menu.page, project.tab and settings.page (they show up in a menu or as a tab); a card may have one (its title). A type: "remote" plugin has "remote": { "url": "https://..." } and no entry; see the guide.
Rights: what each one opens
The administrator sees the list in the consent dialog, in plain words and with a risk class, and can decline optional ones. The plugin gets exactly these: a call to something not covered answers 403 plugin_permission.
| Right | Risk | What it lets the plugin do | API routes |
|---|---|---|---|
user:profile | low | Who is looking: the person's name, language, user id. | GET / |
users:read | medium | The user list and single users. | GET /users, /users/{id}, /users/{id}/teams |
teams:read | low | Teams and their members. | GET /teams, /teams/{id}, /teams/{id}/members |
tasks:read | medium | Tasks (as the person may see them), comments, subtasks, dependencies, stories, epics, sprints, releases, task types, custom field definitions, solutions, services, incidents, SLAs and problems. | GET /tasks, /tasks/{id}, /comments, /stories, /epics, /sprints, /releases, /types, /custom-fields, /solutions, /services, /incidents, /slas, /sla-violations, /problems |
tasks:write | high | Create, change, finish and delete tasks and the planning around them (stories, epics, sprints, releases, subtasks, dependencies). | POST/PUT/DELETE /tasks..., /stories..., /epics, /sprints, /releases |
tasks:comment | medium | Write, change and delete comments. They carry the person's name and the mark "via plugin". | POST/PUT/DELETE /comments |
projects:read | medium | Projects, their plan, baselines and project templates. | GET /projects, /projects/{id}, /projects/{id}/plan, /projects/{id}/baselines, /baselines/{id}, /project-templates |
projects:write | high | Create, change and delete projects, schedule, freeze baselines, save templates. | POST/PUT/DELETE /projects..., /baselines/{id} |
files:read | medium | Documents: lists, details, versions, the text of text files. | GET /files, /files/{id}, /files/{id}/versions, /files/{id}/text |
files:write | high | Change documents, check out, upload versions, move to trash. | POST/PUT/DELETE /files... |
notes:read | medium | Notes, spaces and pages the person may read. | GET /notes, /notes/{id}, /spaces, /spaces/{id}/pages |
notes:write | high | Create, change, move and delete notes and pages. | POST/PUT/DELETE /notes..., /spaces..., /space-folders... |
calendar:read | medium | The person's agenda, meetings (read-only) and absences. | GET /meetings, /meetings/agenda, /meetings/{id}, /absences |
storage:user | low | The plugin's own documents, one set per person. | rc.storage scope user |
storage:shared | low | The plugin's own documents, one set for everybody who uses it. | rc.storage scope shared |
storage:object | low | The plugin's own documents on a task or project. | rc.storage scope object |
Write rights are high risk on purpose: tasks:write, projects:write, files:write and notes:write let the plugin change data under the person's name. Ask for them only if you need them, and put them in optional_permissions when the plugin is useful without them.
Never open to plugins
Customers and companies, billing and invoices, time entries and the timer, leave and vacation requests, reservations, capacity, chats and mentions, the person's own profile settings and devices (/me), the audit log, workflows, AI assistants, alert intake, webhooks, access requests, meeting planning (people search, rooms, minutes, recordings) and the app's own updates. A call to these answers 403 plugin_blocked, whatever the administrator grants. These are the areas where a plugin acting as a person would be too much: money, time, privacy, the audit trail and the platform's own administration. If you need something from one of them, build a remote plugin: your server can use its own, separately issued API access.
Data sources and their fields
All of this is the REST API, which is also documented in htdocs/api/openapi.yaml. What comes back is what the person may see. The fields below were checked against real answers.
A task
{
"ID": 18251, "work_desc": "Project MSCL2 Jourfix", "comment": "Short update on the topics",
"type": "Meeting", "done": 0, "due": "2026-12-15", "deadline": null,
"assigned_worker": "squaker357", "created_by": 1, "date": "2026-11-25 18:08:38",
"time_begin": "14:00:00.0", "time_end": "15:00:00.0",
"est_workhours": 1, "est_workminutes": 0, "hours_used": 0, "minutes_used": 0,
"team": 3, "prj_id": 1, "solution_id": 1, "service_id": 0, "customer_id": 1,
"prio": 0, "importance": 1, "stage": 0, "storypoints": 0, "master_id": 18242, "subtaskof": 0,
"plan_start": null, "plan_end": null, "classification": 0, "custom_fields": []
}ID | the task's number (capital letters!) |
work_desc | the title |
comment | the short description under the title (a "subheader") |
type | the task type (Meeting, Incident, ...) |
done | 0 / 1 |
due | due date YYYY-MM-DD or null |
deadline | hard deadline or null |
assigned_worker | the user name of the assignee |
created_by | user id of the creator |
date | when it was created, YYYY-MM-DD HH:MM:SS |
time_begin / time_end | the booked time of day (14:00:00.0) or null |
est_workhours / est_workminutes | the estimate |
hours_used / minutes_used | the time booked so far |
team | id of the task's team |
prj_id | id of its project (0 = none) |
solution_id / service_id / customer_id | ids of solution, service and customer (0 = none) |
prio / importance | priority and importance |
stage | the column on the Kanban board |
storypoints | story points |
master_id | the task this is a copy or child of |
subtaskof | the parent of a subtask (0 = none) |
plan_start / plan_end | planned dates (classic projects) |
classification | the confidentiality level 0 to 4 |
custom_fields | an object {key: value} of the team's extra fields |
Watch the spelling. The full task uses ID and work_desc; the short task forms (subtasks, dependencies, incidents, a story's tasks) use id and title. Dates are text: YYYY-MM-DD. A date field is null when empty. Text fields that people wrote (comments, descriptions) are HTML: never put them into innerHTML.
Tasks
GET /tasks?team_id=&type=&done=&assigned_worker=&cf[key]=&limit=&offset=
A list of full tasks (fields above). done=0 open, done=1 finished; assigned_worker is a user name; cf[key]=value filters by a custom field. GET /tasks/{id} is one task.
Subtasks, dependencies
GET /tasks/{id}/subtasks, /tasks/{id}/dependencies
Short task form {id, title, team_id, assigned_worker, done, prio, storypoints, stage, est_workhours, est_workminutes, due, subtaskof}; dependencies {task_id, depends_on: [{id, title, done, due}], blocks: [...]}.
Comments
GET /comments?work_id=&prj_id=
{ID, comment (HTML), date, worker (user name), intern (1 internal, 2 external), sys_message (1 = the app's own log line), minutes_used, via ("plugin" for a plugin's comment)}. Oldest first.
Projects
GET /projects, /projects/{id}
{id, name, prjcode, state (number), project_manager, owner, description (HTML), tecdesc, begin_date, end_date, type (agile or classic), customer_id, program_id, ...}. The list shows only projects that are visible and readable for the person; /projects/{id} opens any project the person may read. Money fields (planned cost) are left out for people who may not see them.
Teams, users
GET /teams, /teams/{id}/members, /users, /users/{id}
Teams {ID, teamname, realname, description, teamlead, vertreter (deputy), is_team, ...}; members {ID, username, vorname, nachname, mail, jobtitle, active}; users add abteilung, bereich, hours_per_week, vacation_days, ....
Planning
GET /stories, /epics, /sprints, /releases, /types, /solutions, /services
Stories (a milestone is a story without a team), epics (?project_id=), sprints {id, name, team_id, active, done, start, finish}, task types {ID, type, visible, ...}, solutions and services {ID, name, description, ...}.
Incidents
GET /incidents?team_id=&solution_id=&done=&assigned_worker=
{id, title, description, created, team_id, assigned_worker, done, prio, solution_id, customer_id, state_name, impact, sla_violations, ...}.
Notes
GET /notes?q=&scope=&space_id=&limit=&offset=, /notes/{id}, /spaces, /spaces/{id}/pages
List {id, title, rev, visibility, space_id, parent_id, owner, updated}; one note adds content (Markdown), tags, can_edit, review_due. /spaces lists the wiki spaces {id, key, name, type, pages}.
Files
GET /files?task_id=&project_id=&team_id=&q=, /files/{id}, /files/{id}/text
{id, title, filename, extension, mime, size_bytes, version, scope, uploader_id, time_added, task_id, project_id, ...}; /text answers {id, version, filename, text} for text files.
Calendar
GET /meetings/agenda?from=&to=, /meetings, /absences?from=&to=&scope=&team_id=
Agenda {from, to, window, meetings: [{id, title, start, end, starts_in, running, location, organizer, my_status, join_url, ...}]}; absences {kind, id, user_id, type, begin, end, state, comment}.
Your own data: plugin storage
rc.storage keeps documents of your plugin (see the SDK). Three scopes: user (one set per person), shared (one set for everybody), object (on a task or project; readable only by people who may open it). Use it for settings, drafts, small lists - not for large data. Plan for a person opening the page on two devices: documents are on the server, not in the browser.
Data of other systems
A plugin can load data from servers of your company: name them in network (see the recipe). For anything that needs a secret or a server-to-server connection, use a remote plugin.
The SDK
| Call | What it does |
|---|---|
rc.ready | A promise; resolves with the context { plugin: {key, version}, user: {id, username, name, lang, theme}, slot, object, events }. rc.context() returns it later without waiting. |
rc.api.get(path)post(path, body) put(...) delete(path) | Calls the REST API as the person. Paths start with /, without /api/v1. The body is any JSON (at most 1 MB). Answers are JSON. A failure rejects with {status, code, message, permission}. |
rc.storage.get(scope, key, [opts]) | Reads a document; null when there is none. Scope user, shared or object; opts.object = {type, id} names the object when you are not in a card. |
rc.storage.set(scope, key, value) | Writes a document (any JSON, at most 1 MB; all documents of the plugin together 100 MB). Keys: letters, digits, - _ . :, up to 120 characters. |
rc.storage.remove(scope, key) | Deletes; resolves true when something was removed. |
rc.storage.list(scope, [{prefix, object}]) | Lists the keys [{key, size, updated_at}], optionally only those starting with a prefix. |
rc.ui.toast(text, kind) | A short message in the app; kind is info, success or error. Plain text. |
rc.ui.confirm(text) | Asks the person; resolves true for OK. |
rc.ui.navigate(path) | Takes the person to a page of the app, e.g. /edit_workflow?workid=5 or /project_detail?id=7. Only app paths. |
rc.ui.autoResize() / rc.ui.resize(px) | Cards and tabs: keep the frame as high as the page, or set a height. |
rc.events.on(name, fn) / off | Hear the events the manifest asked for. See the recipe. |
TypeScript types for editor autocompletion are in plugin-sdk/index.d.ts. The pack tool (plugin-sdk/bin/rc-plugin.js check|pack) validates a plugin folder before you upload it.
Errors
Every call returns a promise that can reject. The rejected value has status, code, message and, for a missing right, permission.
Status / code | Meaning | What to do |
|---|---|---|
403 plugin_permission | the plugin lacks the right in err.permission | add it to the manifest (or optional_permissions and handle a refusal), raise the version, upload, allow |
403 plugin_blocked | this part of the API is never open to plugins | nothing; see "Never open to plugins" |
| 403 (other) | the person may not do it | show the message; do not retry |
| 404 | does not exist, or the person may not see it | say "not found or no access" |
| 400 / 409 / 422 | the input is wrong or a rule stops it (required field, finished task, ...) | show err.message: it says what is wrong |
413 plugin_too_big, plugin_quota | one document over 1 MB, or the plugin over 100 MB | store less, or in pieces |
| 429 | more than 120 calls in a minute | wait; ask for lists, not for every row |
token | the plugin could not get its access token (the plugin is switched off or removed) | reload the page |
Recipes
Each recipe is a complete piece you can paste into a page of a plugin that has already loaded the SDK. They assume the structure of the tutorial: rc.ready.then(function (ctx) { ... }). The comments say what the answers contain.
Load more than one page of a list
Lists answer at most 500 entries per call (default 100). Ask page by page with limit and offset until a page comes back shorter than the limit. Do not ask for the next page while the person has not asked for it: a plugin may make 120 calls a minute.
Needs: tasks:read
// all open tasks of the person, page by page
function loadAll(username) {
var all = [], size = 200;
function next(offset) {
var url = '/tasks?done=0&assigned_worker=' + encodeURIComponent(username) + '&limit=' + size + '&offset=' + offset;
return rc.api.get(url).then(function (page) {
all = all.concat(page);
return page.length < size ? all : next(offset + size); // a short page is the last one
});
}
return next(0);
}
rc.ready.then(function (ctx) {
loadAll(ctx.user.username).then(function (tasks) { console.log(tasks.length + ' open tasks'); });
});
Create a task from a form
A new task needs a name and a team_id. The form below offers the teams (teams:read) and posts the task (tasks:write). The answer is the new task; its ID is what you link to. assign_to_me: true puts it on the person.
Needs: tasks:write, teams:read
rc.ready.then(function (ctx) {
var root = document.getElementById('root');
var name = document.createElement('input');
var team = document.createElement('select');
var due = document.createElement('input'); due.type = 'date';
var go = document.createElement('button'); go.textContent = 'Create';
var msg = document.createElement('p');
[name, team, due, go, msg].forEach(function (x) { root.appendChild(x); });
rc.api.get('/teams').then(function (teams) {
teams.filter(function (t) { return t.is_team; }).forEach(function (t) {
var o = document.createElement('option'); o.value = t.ID; o.textContent = t.realname || t.teamname; team.appendChild(o);
});
});
go.addEventListener('click', function () {
var body = { name: name.value, team_id: parseInt(team.value, 10), assign_to_me: true };
if (due.value) { body.duedate = due.value; } // YYYY-MM-DD
rc.api.post('/tasks', body).then(function (task) {
msg.textContent = 'Created #' + task.ID;
name.value = '';
}, function (err) { msg.textContent = err.code === 'plugin_permission' ? 'Not allowed: ' + err.permission : err.message; });
});
});
Finish a task or move its due date
PUT /tasks/{id} changes the fields you send and leaves the rest. done: 1 finishes it with the same checks as the Done button: a task with an empty required custom field answers 400 and names the field, so show err.message. Always ask the person first for anything that cannot be undone: rc.ui.confirm.
Needs: tasks:write
function finish(taskId) {
return rc.ui.confirm('Finish this task?').then(function (yes) {
if (!yes) { return; }
return rc.api.put('/tasks/' + taskId, { done: 1 }).then(function () {
rc.ui.toast('Done', 'success');
}, function (err) { rc.ui.toast(err.message, 'error'); });
});
}
function moveDue(taskId, date) { // date: 'YYYY-MM-DD'
return rc.api.put('/tasks/' + taskId, { due: date });
}
Read the comments of a task
Comments are HTML written by people, plus the app's own log lines (sys_message: 1). Filter the log lines out for a readable list, and show the text as text: plain() below turns HTML into plain text without ever running it.
Needs: tasks:read
function plain(html) { // HTML -> text; nothing in it is executed
return new DOMParser().parseFromString(String(html || ''), 'text/html').body.textContent.trim();
}
rc.ready.then(function (ctx) {
rc.api.get('/comments?work_id=' + ctx.object.id).then(function (list) {
list.filter(function (c) { return !c.sys_message; }).forEach(function (c) {
var p = document.createElement('p');
p.textContent = c.date.slice(0, 16) + ' ' + c.worker + ': ' + plain(c.comment); // worker is a user name
document.getElementById('root').appendChild(p);
});
});
});
Subtasks and what a task waits for
Both lists use the short task form {id, title, done, due, ...} (lower-case id and title, unlike the full task with ID and work_desc). Tasks the person may not see are left out of depends_on and blocks.
Needs: tasks:read
Promise.all([rc.api.get('/tasks/' + id + '/subtasks'), rc.api.get('/tasks/' + id + '/dependencies')]).then(function (r) {
var subtasks = r[0]; // [{id, title, assigned_worker, done, due, est_workhours, ...}]
var deps = r[1]; // {task_id, depends_on: [{id, title, done, due}], blocks: [...]}
var open = subtasks.filter(function (s) { return !s.done; }).length;
console.log(open + ' of ' + subtasks.length + ' subtasks open; waits for ' + deps.depends_on.length + ' tasks');
});
Search notes and show one
Notes are Markdown. GET /notes?q= searches titles and text; one note carries its content. Show the Markdown as text (a <pre>), or bring a Markdown library in your package and render it - then keep the result away from innerHTML unless the library sanitises. Writing needs notes:write; the note belongs to the person.
Needs: notes:read (+ notes:write)
function searchNotes(q) {
return rc.api.get('/notes?q=' + encodeURIComponent(q) + '&limit=20'); // [{id, title, rev, owner, updated, ...}]
}
function showNote(id, into) {
return rc.api.get('/notes/' + id).then(function (note) {
// note.content is Markdown, note.can_edit says whether the person may change it
var pre = document.createElement('pre');
pre.textContent = note.title + '\n\n' + note.content;
into.appendChild(pre);
});
}
function createNote(title, markdown) { // needs notes:write
return rc.api.post('/notes', { title: title, content: markdown });
}
List the documents of a task and read a text file
Documents are listed with filters (task_id, project_id, team_id, folder_id, q). /files/{id}/text answers the text of a text document (txt, md, csv, json ... up to about a megabyte). Binary downloads (PDF, images) do not go through rc.api, which only carries JSON: link to the document in the app instead. Reading a text counts as a download of that version (it matters for the checkout rules).
Needs: files:read
rc.api.get('/files?task_id=' + id).then(function (files) {
// [{id, title, filename, extension, mime, size_bytes, version, uploader_id, time_added, ...}]
files.filter(function (f) { return f.extension === 'csv' || f.extension === 'txt' || f.extension === 'md'; }).forEach(function (f) {
rc.api.get('/files/' + f.id + '/text').then(function (doc) {
console.log(doc.filename, doc.text.length + ' characters'); // doc = {id, version, filename, text}
}, function (err) { console.log(f.filename, err.status === 415 ? 'not a text file' : err.message); });
});
});
The calendar: agenda and absences
calendar:read opens three read-only things: the agenda (the person's meetings in a range, with start, end, location and join link), the list of the person's meetings and absences (vacation, home office, sickness of the person and, with scope, of the team). Planning meetings, rooms, minutes and recordings are not open to plugins.
Needs: calendar:read
// the next 30 days of the person's calendar (no parameters = from now on)
rc.api.get('/meetings/agenda').then(function (a) {
// a = {from, to, window, meetings: [{id, title, start, end, running, left, my_status, location, join_url, ...}]}
a.meetings.forEach(function (m) { console.log(m.start, m.title, m.join_url); });
});
// a given range
rc.api.get('/meetings/agenda?from=2026-12-01&to=2026-12-31');
// absences of a period: [{kind, id, user_id, type, begin, end, state, comment}]
rc.api.get('/absences?from=2026-12-01&to=2026-12-31').then(function (list) {
list.forEach(function (x) { console.log(x.type, x.begin, '-', x.end); });
});
Teams, members and colleagues
teams:read gives the teams and their members (user name, first and last name, mail, job title, active). users:read gives the user list with more (department, hours per week ...). Both are the lists the person could see in the app. A team in the list has is_team: 1; departments and areas are in the same list with other flags.
Needs: teams:read, users:read
rc.api.get('/teams').then(function (teams) {
var mine = teams.filter(function (t) { return t.is_team; });
mine.forEach(function (t) { console.log(t.ID, t.realname || t.teamname, 'lead:', t.teamlead); });
return rc.api.get('/teams/' + mine[0].ID + '/members');
}).then(function (members) {
members.filter(function (m) { return m.active; }).forEach(function (m) { console.log(m.vorname, m.nachname, m.jobtitle || ''); });
});
Something everybody can write: a quick poll
The shared storage is one space for everybody who uses the plugin. Two people writing the same document at the same time overwrite each other (last write wins). So give every person a document of their own - vote-<username> - and count by listing the keys.
Needs: storage:shared
function vote(ctx, choice) {
return rc.storage.set('shared', 'vote-' + ctx.user.username, { choice: choice, at: new Date().toISOString() });
}
function tally() {
return rc.storage.list('shared', { prefix: 'vote-' }).then(function (items) { // [{key, size, updated_at}]
return Promise.all(items.map(function (i) { return rc.storage.get('shared', i.key); }));
}).then(function (votes) {
var counts = {};
votes.forEach(function (v) { if (v) { counts[v.choice] = (counts[v.choice] || 0) + 1; } });
return counts; // {yes: 5, no: 2}
});
}
Keep data on a task or a project
In a task card or project tab, object storage belongs to the task or project the card sits on: only people who may open it can read or write it, and it is gone when the plugin is uninstalled. Outside a card pass the object yourself: { object: { type: 'task', id: 5 } }.
Needs: storage:object
// in a card: the object is the one the card sits on
rc.storage.set('object', 'checklist', { items: [{ text: 'Call the customer', done: false }] });
rc.storage.get('object', 'checklist').then(function (doc) { console.log(doc ? doc.items.length : 0, 'items'); });
// from a menu page, for a task of your choosing
rc.storage.get('object', 'checklist', { object: { type: 'task', id: 18251 } });
React when something changes
Name the events you want in the manifest ("events": ["task.updated", "comment.created"]): task.created, task.updated, task.done, comment.created, project.status_changed. While your plugin is open, the page tells it with a small message, e.g. { id: 123 } for a task - then ask the API for what you need. Events about private or classified things are never delivered. A page that is not open hears nothing: events are for refreshing a view, not for background work.
Needs: none (manifest: events)
rc.events.on('task.updated', function (data) {
if (data.id === rc.context().object.id) { reload(); } // the card's own task changed in the editor
});
rc.events.on('comment.created', function () { reload(); });
Talk to a server of your company
A plugin may only contact servers named in network of the manifest (shown to the administrator at install). Your server must answer the browser's CORS check: the frame has no origin of its own, so the server must send Access-Control-Allow-Origin: * (and answer OPTIONS). Never put a secret in a plugin: the files go to every viewer. If the call needs a secret, use a remote plugin (see the guide) and make the call from your server.
Needs: none (manifest: network)
// manifest: "network": ["https://api.mycompany.example"]
fetch('https://api.mycompany.example/stock?sku=' + encodeURIComponent(sku))
.then(function (r) { if (!r.ok) { throw new Error('HTTP ' + r.status); } return r.json(); })
.then(function (data) { console.log(data); })
.catch(function (err) { rc.ui.toast('Could not reach the stock service: ' + err.message, 'error'); });
Handle every error the same way
Every SDK call can fail. Put the explanation in one function, and use it everywhere. The fields: err.status (HTTP status), err.code, err.permission (with plugin_permission), err.message.
Needs: -
function explain(err) {
if (err.code === 'plugin_permission') { return 'This plugin is not allowed to do that (' + err.permission + ').'; }
if (err.code === 'plugin_blocked') { return 'That part of Resourcecloud is not open to plugins.'; }
if (err.status === 404) { return 'Not found, or you may not see it.'; }
if (err.status === 429) { return 'Too many requests. Wait a moment.'; }
if (err.status === 400) { return err.message; } // the API says what is wrong with the input
return 'Something went wrong: ' + (err.message || err);
}
rc.api.get('/tasks/5').then(show, function (err) { rc.ui.toast(explain(err), 'error'); });
A search box that does not flood the API
A call per keystroke hits the limit (120 a minute) quickly. Wait until the person stopped typing for a moment.
Needs: -
var timer = null;
input.addEventListener('input', function () {
clearTimeout(timer);
timer = setTimeout(function () {
rc.api.get('/notes?q=' + encodeURIComponent(input.value) + '&limit=10').then(drawResults);
}, 300); // 300 ms after the last keystroke
});
The Slots tour
examples/plugins/slots-tour is one plugin that uses every place - the best next thing to read after the tutorial. Install it on a test instance and open each place:
| Place | Files | It teaches |
|---|---|---|
menu.page Team directory | teams.html, teams.js | a master/detail page: /teams and /teams/{id}/members, live search in the browser |
task.card Task details | task.html, task.js | several calls at once, one failing without stopping the others; subtasks, dependencies, comments; an optional tasks:comment with a clear message when declined; reloading on the task.updated event |
project.tab Project facts | project.html, project.js | facts of the project; HTML descriptions shown as text; a note kept in object storage |
dashboard.card My open tasks | dashboard.html, dashboard.js | filter and sort, overdue marking, links into the app (rc.ui.navigate), the calendar agenda, settings read from shared storage |
settings.page | settings.html, settings.js | a configuration page whose values the dashboard card uses (shared storage) |
common.js holds the helpers all pages share (the safe element maker, HTML-to-text, error messages, dark theme and language handling): copy it into your own plugins.
The other examples: Task Radar (task-radar, the tutorial plugin), Hello plugin (hello, the smallest useful one, in the catalog), Whiteboard (whiteboard, drawing and saving, in the catalog), Remote demo (remote-demo, a plugin that is a page of your own server).
Limits at a glance
| What | Limit |
|---|---|
| Package | 50 MB packed, 200 MB unpacked, 30 MB per file, 2000 files |
| API calls | 120 per minute and plugin; at most 500 entries per list call |
| A stored document | 1 MB; all documents of a plugin together 100 MB |
| A request body | 1 MB |
| Access token lifetime | 15 minutes; the SDK renews it by itself |
| Servers a plugin may contact | 10 origins in network |
| File types in a package | html, js, mjs, css, json, svg, png, jpg, gif, webp, ico, fonts, wasm, txt, md |