apply_hierarchy_changes
Changes data
Edit a product's hierarchy: the only way to add, rename, describe, move, merge or delete its categories and features. Send an ordered list of steps, each an object with op and that kind's fields; a single edit is a list of one step:
create_category:title, optionaldescription,parentId(a category holding no features, or null for the top level) and optionalid.create_feature: a feature with no documentation page:title, optionaldescription,categoryId(a category holding no subcategories) and optionalid.update_category:categoryIdand either new text (title,description; empty clears it) or a new place (parentId), not both. Moving into a category that holds features moves those features, in order, into a new subcategory "Other" after it, whose idotherIdoptionally sets.update_feature:featureIdand either new text (title,description) or a new place (categoryId, holding no subcategories), not both. A moved feature keeps its name.merge_category:categoryIdintointoId, which keeps its title and gets its subcategories and features at its end. Not into itself, a category above or below it, nor when subcategories and features would mix.merge_feature:featureIdintointoId, which keeps its title, description and source; the feature's feedback moves tointoId.delete_category:categoryId, with its subcategories and every feature below it; their feedback moves to New opportunity.delete_feature:featureId; a later knowledge base read doesn't add it back, and its feedback moves to New opportunity. Each step runs on the tree as the earlier steps left it, under its rules: a category holds either subcategories or features, never both, and never goes under itself; sibling order can't be set. A step that would change nothing is skipped, not refused: the same text, a move to where the item already is, an add already made with the same values. To restructure, create the new categories, move into them, then merge or delete what is left. Work in two calls. Find ids withsearchor a compactget_hierarchy, then send the steps withdryRun: trueand that read'sversionasexpectedVersion: nothing is saved, and the answer lists each step'schanges(edited fields with their valuebefore),skippedsteps,problems(each step that would be refused, with the rule and the ids of allowed places), how many linked insights each delete or feature merge would move (moving: to New opportunity, or to the feature merged into; a category merge moves none) and the resultingtreearound the named items. Show the person the outcome, and ask before deletes and merges. Then send the same steps withoutdryRun: all are saved or none. The first refused step stops the call and saves nothing: its refusal is the answer, the message starting "Step <n>: " anddetails.stepnaming it. A save answers the hierarchy change it stored and the newversion; when every step was skipped nothing is stored andchangeis null. Oneundo_changewith areahierarchyreverses it all; undoing that undo does it all again. At most 50 steps and 64 KB per call.expectedVersionrefuses the call (conflict) when the hierarchy changed since your read: read again, check the plan, send the new version. A retry is safe: the same save again answers the first result while it is the product's newest change, yours and not undone. Product Owners and Admins only; Viewers are refused, also for a preview.
Inputs
- Who can use it
- Admins and the product's Owners
- Hints
- Changes dataCan remove dataSafe to repeat
- Runs
apply_hierarchy_changes- Inputs
productIdstring, requiredFrom
read_productwith actionlistorget_me.bodyobject, requiredAn ordered list of hierarchy changes, previewed with
dryRunor saved as one change.stepsarray of objects, requiredThe changes to make, in order, 1 to 50. Each is one object:
opnames the kind of change and the other fields are its inputs. Later steps may name ids earlier steps chose.One of:op:create_categoryidstringOptional: a new uuid you choose for what this step adds, so later steps can name it and a retry is safe: a repeat with the same id and values is skipped.
titlestring, requiredThe category's title, 1 to 100 characters on one line.
descriptionstring or nullWhat the category covers; empty or null for none.
parentIdstring or null, requiredThe parent category, from
searchorget_hierarchy(or an earlier step'sid); null for the top level.
op:create_featureidstringOptional: a new uuid you choose for what this step adds, so later steps can name it and a retry is safe: a repeat with the same id and values is skipped.
titlestring, requiredThe feature's title, 1 to 80 characters on one line.
descriptionstring or nullWhat the feature does, starting with a verb; empty or null for none.
categoryIdstring, requiredFrom
searchorget_hierarchy, or anidan earlier step chose.
op:update_categorytitlestringThe category's title, 1 to 100 characters on one line.
descriptionstring or nullWhat the category covers; empty or null for none.
parentIdstring or nullThe parent category, from
searchorget_hierarchy(or an earlier step'sid); null for the top level.otherIdstringOptional: a new uuid you choose for the subcategory Other that a move into a category holding features makes; refused when another item has it. A repeated move is skipped.
categoryIdstring, requiredFrom
searchorget_hierarchy, or anidan earlier step chose.
op:update_featuretitlestringThe feature's title, 1 to 80 characters on one line.
descriptionstring or nullWhat the feature does, starting with a verb; empty or null for none.
categoryIdstringFrom
searchorget_hierarchy, or anidan earlier step chose.featureIdstring, requiredFrom
searchorget_hierarchy, or anidan earlier step chose.
op:merge_categorycategoryIdstring, requiredFrom
searchorget_hierarchy, or anidan earlier step chose.intoIdstring, requiredThe id of the item to merge into, from
searchorget_hierarchy, or anidan earlier step chose.
op:merge_featurefeatureIdstring, requiredFrom
searchorget_hierarchy, or anidan earlier step chose.intoIdstring, requiredThe id of the item to merge into, from
searchorget_hierarchy, or anidan earlier step chose.
op:delete_categorycategoryIdstring, requiredFrom
searchorget_hierarchy, or anidan earlier step chose.
op:delete_featurefeatureIdstring, requiredFrom
searchorget_hierarchy, or anidan earlier step chose.
dryRunbooleantrue: save nothing and answer the outcome (changes, skipped and refused steps, the resulting tree).
expectedVersionstringThe
versionfromget_hierarchy(or a dry run) you planned from; refused when the hierarchy changed since.