Quintiq file version 2.0
#parent: #root
Method EditKBBranch (
  String kbname,
  String branchname
) id:Method_ApplicationLibMacroPlanner_EditKBBranch_1
{
  #keys: '[11660.0.1765215333]'
  Body:
  [*
    //Edit a kb branch without active dataset
    editor := CKBEditor::Create();
    kbidset := editor.GetKBs();
    kbid := select( kbidset, Elements, e, true, e.Name() = kbname );
    
    kbfullidset := editor.GetKBStructure( kbid );
    kbfullid := maxselect( kbfullidset, Elements.KBFullID, e, e.Branch() = branchname, e.ChangeNr() );
    
    ckb := editor.LoadKB( kbfullid );
    dlg := construct( dlgKnowledgeBaseEditorNoMDS );
    dlg.EditKnowledgeBase( ckb, this );
    
    // BUG: Edit KB -> Scenario manager -> make changes -> Save & close -> Cancel
    // The above will leave the user stuck with a locked KB
    // Issue traced to standard Quintiq dialog dlgKnowledgeBaseEditorNoMDS, method ApplyData
    // Workaround while R&D fixes this
    editor.ForceUnlockKB( kbfullid );
  *]
}
