Below is the example of using the GetWbkMd operation to save a calculated series as a modeling problem. The request contains an instance of opened workbook and a pattern for saving the modeling problem. The response contains description of the created problem.
IMPORTANT. Before saving a calculated series as a modeling problem, determine values of all the mandatory attributes for this series.
{
"GetWbkMd" :
{
"tWbk" :
{
"id" : "S1!M!S!W7"
},
"tArg" :
{
"pattern" :
{
"obInst" : "true",
"useGridAutoAdjust" : "true",
"action" :
{
"saveAsProblem" :
{
"createInfo" :
{
"name" : "Modeling problem",
"id" : "",
"permanent" : "true"
},
"series" : ""
}
}
}
}
}
}
{
"GetWbkMdResult" :
{
"id" :
{
"id" : "S1!M!S!W7"
},
"meta" :
{
"obInst" :
{
"obDesc" :
{
"@ds" : "",
"@isShortcut" : "0",
"@isLink" : "0",
"@ver" : "2",
"@hf" : "0",
"i" : "WBK_CALC",
"n" : "Calculated series",
"k" : "5541",
"c" : "2827",
"p" : "5471",
"h" : "0",
"hasPrv" : "0",
"ic" : "0",
"trackElementDependents" : "0",
"isPermanent" : "1",
"isTemp" : "0"
}
},
"dirty" : "1",
"windowsPosition" : "Vertical",
"hasPivot" : "0",
"hasLaner" : "1",
"series" :
{
"@count" : "4",
"its" : ""
},
"action" :
{
"saveAsProblem" :
{
"object" :
{
"@ds" : "",
"@isShortcut" : "0",
"@isLink" : "0",
"@ver" : "1",
"@hf" : "0",
"i" : "OBJ219714",
"n" : "Modeling problem",
"k" : "219714",
"c" : "5123",
"p" : "5474",
"h" : "0",
"hasPrv" : "0",
"ic" : "0",
"trackElementDependents" : "0",
"obId" :
{
"id" : ""
}
}
}
}
}
}
}
public static WbkSaveAsProblemResult GetWbkSaveAsProblem(WbkId wbk, ItKey[] series)
{// Set operation execution parameters
var tOp = new GetWbkMd
{
tWbk = wbk,
tArg = new GetWbkMdArg
{// Set pattern for getting data
pattern = new WbkMdPattern
{
action = new WbkActionArg()
{
saveAsProblem = new WbkSaveAsProblemArg()
{
createInfo = new ObjectCreateBaseInfo()
{
id = "",
name = "Modeling problem",
permanent = true
},
series = series
}
}
}
}
};
// Create a proxy object for operation execution
var somClient = new SomPortTypeClient();
// Execute operation
var gRes = somClient.GetWbkMd(tOp);
WbkActionResult actRes = gRes.meta.action;
WbkSaveAsProblemResult saveProblRes = actRes.saveAsProblem;
Console.WriteLine("Identifier of created problem: " + saveProblRes.@object.i);
return saveProblRes;
}
See also: