What is the Function or Method to be used in Macro to apply the Template for the models .
We have used Designer.applyTemplate() function and passed the Guid of the template but it did not work.
What is the Function or Method to be used in Macro to apply the Template for the models .
We have used Designer.applyTemplate() function and passed the Guid of the template but it did not work.
Wow Great Its working. Thanks !!!
I have ended with another problem while creating a macro - I want to get a Group path of a model.
I dont find any functions to get it in the macro but i have used Group().Path() function in report for the same purpose.
Use:
var oModels = Context.getSelectedModels();
for(i=0;i<oModels.length;i++) {
var oGroup = Designer.getParentGroup(oModels[i]);
var sPath = Explorer.getGroupPath(oGroup);
}
Hello Bala & Edwin,
I am also facing a similar issue for applying a template to a model.
I tried EDWIN's solion, but it says Context.getLoginInfo() not availbale..
Please help me with some inputs...
Regards,
Linda.
Hello Edwin,
My requiremnt is to create Datatypemodels dynamically.I have a report that create the DATA_Type, but the name is not getting disaplyed on DATA_TYPE element in the model viewer.
My code is as beow
var objdef = oGroup.GetOrCreateObjDef( g_datatype_type,2,g_objdef_name,g_nLoc);
var attr1def = oGroup.GetOrCreateObjDef( g_attribute_type,2,g_attrdef_name,g_nLoc);
var oModel = arCreateModel(g_mt_datatype_model,oGroup,gdt,g_nLoc );
if( (oModel != null) && (oModel.IsValid()) )
{ //APply template
var template = "_SAP: Data Type Model";
Designer.applyTemplate(oModel,template); }
But Here i am getting an error like 'Designer is not defined'.
So i tried ur code suggestion as below...
var objdef = oGroup.GetOrCreateObjDef( g_datatype_type,2,g_objdef_name,g_nLoc);
var attr1def = oGroup.GetOrCreateObjDef( g_attribute_type,2,g_attrdef_name,g_nLoc);
var oModel = arCreateModel(g_mt_datatype_model,oGroup,gdt,g_nLoc );
if( (oModel != null) && (oModel.IsValid()) )
{ //APply template
var oDB = Context.getLoginInfo( Context.getSelectedDatabases()[0] ).getServerName();
var oTempls = Designer.getAvailableTemplates(oDB);
Here again i am gettin error like Cannot find function getLoginInfo in object COntext@4563bba4
Regards,
Linda
Hi Linda,
You are building a script for a report and not for a macro. The solution i described was for the macro object model. In the report object model you should use:
var bTemplateAssigned = oModel.setTemplate("7ca16360-6684-11dc-2b8d-000f20fcb6a9") ;If bTemplateAssigned is true, then the template is assigned correctly.
Succes,
Edwin
Hello Edwin,
I tried SetTemplate and it retunred true. But still then the newly created model is not displaying any label(placed attributes) using the template...
Regards,
Linda.
Hi Linda,
Forgot one small thing. The second parm in method setTemplate(String guidTemplate, boolean bApplyTemplate ) needs to be set to true. sorry for that.
var bTemplateAssigned = oModel.setTemplate("7ca16360-6684-11dc-2b8d-000f20fcb6a9", true) ;
Best regards,
Edwin
Hello Edwin,
So sorry to tell u back that, this also didnt work...
It says like
"cant find method com.idsscheer.aris.cscommon.webreport base.reportobjects.Imodel.setTemplate(string,boolean)"
do we have any other solutions.
Linda
Hi Linda,
I created a little script to apply the template. It looks like below, and it works fine for me.
var nLocale = Context.getSelectedLanguage();
main();
function main() {
var oModels = ArisData.getSelectedModels();
for (var i=0;i<oModels.length;i++) {
var bTemplateAssigned = oModels[i].setTemplate("fedac4a0-2f64-11e0-46d1-0022fbbb78d0", true)
}
}Best regards,
Edwin
I want to set template to an object occurence and not whole model. can I do this with script ?
Edwin Verstraeten on
Hi,
You must use the construction below.
Succes,
Edwin
================================================
var oModels = Context.getSelectedModels();
var oDB = Context.getLoginInfo(oModels[0]).getDatabase();
var oTempls = Designer.getAvailableTemplates(oDB);
for(i=0;i<oTempls.length;i++) {
if (oTempls[i].getGUID()=="f94133b0-3300-11de-34a6-0015587d97aa") {
var oTempl = oTempls[i];
break;
}
}
if(oTempl!=null){
for(i=0;i<oModels.length;i++) {
Designer.applyTemplate(oModels[i], oTempl);
}
}