JsonProject.preview#
Applies a change set to a copy of the solved baseline of a JsonProject and schedules the copy. The project isn't modified. Use it to show what an edit would do before committing it with apply. Needs a solved project with no edits applied since the last solve or level.
Signature#
changes_json: string, options_json: string: string
Synchronous and read-only. Bad input comes back as an error envelope. The call doesn't throw.
Request#
| Argument | Payload | Required | Description |
|---|---|---|---|
changes_json |
SchedulingChanges |
yes | The edits to try. "{}" previews no change |
options_json |
PreviewOptions |
yes | "{}" for defaults |
PreviewOptions#
The options object for preview. Every field can be omitted. Unknown fields, such as includeUnchanged, are rejected with a parse error.
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
subtree |
Subtree |
no | absent (whole project) | Previews only one branch. Same shape as subtree in SolveOptions |
analytics |
AnalyticsOptions |
no | none requested | Adds analytics for the previewed state. Same shape as analytics in SolveOptions |
reasons |
boolean | no | false |
Adds a reason to each update |
baselineId |
string | no | absent (not checked) | Must name the current baseline, or the call fails with stale-baseline |
profile |
ProfileQuery |
no | absent | Adds profile, the resource load of the previewed dates. Takes the fields of LoadProfileOptions except baselineId, which is an unknown field here |
null on any field reads as its default.
Behavior#
updatesare relative to the baseline. An empty change set gives emptyupdates.- The result's
baselineIdis the baseline the preview read, so a followingpreviewaccepts it. - The change set isn't partially accepted. One rejected operation fails the whole call.
options.baselineIdandchanges.baselineIdare checked separately. An absent token skips its check.- The result stays sparse: there's no option to report unchanged tasks.
Response#
The success envelope carries a ScheduleResult for the previewed state. profile is present only when options.profile is set. Envelope shape: Wire format.
Errors#
| Kind | Code | When |
|---|---|---|
project |
no-baseline |
The project has never been solved, or apply ran since the last solve |
project |
stale-baseline |
options.baselineId or changes.baselineId doesn't name the current baseline |
validation |
null |
An operation in changes_json is rejected (the error reports the first one, with its path, e.g. tasks.update[0]), or the profile query is invalid (e.g. to not after from, at to) |
parse |
null |
Malformed JSON, or an unknown field in the change set or the options |
A start date that falls on non-working time is kept unsnapped when the task has no predecessor. The end is computed forward from it on the working calendar.
Example#
Preview a resize of task a on a solved project, with reasons, guarded by the baseline token.
const = ;
const = ;
const = new;
changes_json:
options_json (the token comes from the solve result):
Response:
The project keeps its solved dates: project.preview("{}", "{}") still returns empty updates.
Related#
SchedulingChanges- the change set to tryScheduleResult- the previewed resultJsonProject.apply- commit the change set once it looks right- Previewing Changes - previews, clones and baseline tokens
- Reading results - reading updates, reasons and conflicts