lazhen
2025-01-09 8afe90b633046db39042aada36b88193062f8cff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
Quintiq file version 2.0
#parent: #root
Method InstantiateAndSelectKB (
  Scenario scenario
) as internal[KBFullID] id:Method_ScenarioManager_DialogCreateEditMPScenario_InstantiateAndSelectKB
{
  #keys: '[11660.0.806122670]'
  Body:
  [*
    //Instantiate knowledge
    Domain.PublishKnowledge();
    editor := CKBEditor::Create();
    kbfullid := maxselect ( DataHolderKB.Data(), Elements.KBFullID, k, k.Name().ToUpper() = ScenarioManager.CompanyKBName().ToUpper(), k.ChangeNr() );
    ids := editor.GetKBs();
    mid := selectobject (ids, Elements, e, e.Domain() = kbfullid.Domain() and e.Name() = kbfullid.Name(), true)
    modelkb := editor.GetModelKB( mid );
    
    //get a copy so we could edit
    saveid := modelkb.CKB().ID();
    saveid.Version( "1.0.0.0" );
    saveid.Branch( EditorBranch.Text() );
    
    //Perform the actual saveAs action
    editor.SaveKBAs( modelkb, modelkb.CKB().ID(), '');
    saveid.ChangeNr( 1 );
    
    //Select the new KB for the MDS
    ApplicationLibMacroPlanner.SelectKB( scenario, saveid );
    
    return saveid;
  *]
}