KB

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.

by Edwin Verstraeten
Posted on Tue, 01/18/2011 - 10:31

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);

    }

}

0
by karthikeyan balasubramanian Author
Posted on Wed, 01/19/2011 - 11:33

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.

0
by Edwin Verstraeten
Posted on Thu, 01/20/2011 - 08:51

Use:

var oModels = Context.getSelectedModels();

for(i=0;i<oModels.length;i++) {

    var oGroup = Designer.getParentGroup(oModels[i]);

    var sPath = Explorer.getGroupPath(oGroup);

}

 

0
by karthikeyan balasubramanian Author
Posted on Thu, 01/20/2011 - 13:28

Excellent !!! Its works fine.Many thanks.

 

0
by Linda Thomas
Posted on Wed, 02/02/2011 - 07:15

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.

0
by Edwin Verstraeten
Posted on Wed, 02/02/2011 - 07:47

In reply to by Lana

Hi Linda,

Are you trying to apply the template in macro or report?

Note that Context.getLoginInfo needs a baseobject as input thus:

Context.getLoginInfo(model)

Context.getLoginInfo(object)

etc.

Best regards,

Edwin

0
by Linda Thomas
Posted on Wed, 02/02/2011 - 08:53

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); 


for(i=0;i<oTempls.length;i++) {     if (oTempls[i].getGUID()=="7ca16360-6684-11dc-2b8d-000f20fcb6a9")    {     var oTempl = oTempls[i];         break;     } } if(oTempl!=null){       Designer.applyTemplate(oModel, oTempl);   }


Here again  i am gettin error like Cannot find function getLoginInfo in object COntext@4563bba4

Regards,

Linda

 

 

0
by Edwin Verstraeten
Posted on Wed, 02/02/2011 - 15:14

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

 

0
by Linda Thomas
Posted on Wed, 02/02/2011 - 19:58

In reply to by sstein

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.

 

0
by Edwin Verstraeten
Posted on Wed, 02/02/2011 - 20:33

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

0
by Linda Thomas
Posted on Thu, 02/03/2011 - 06:11

In reply to by sjletellier

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

0
by Edwin Verstraeten
Posted on Thu, 02/03/2011 - 08:16

In reply to by samw

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

0
by Misha Akopov
Posted on Wed, 05/30/2012 - 13:57

Hi  Mr. Edwin Verstraeten

I want to set template to an object occurence and not whole model. can I do this with script ?

0

Featured achievement

Rookie
Say hello to the ARIS Community! Personalize your community experience by following forums or tags, liking a post or uploading a profile picture.
Recent Unlocks

Leaderboard

|
icon-arrow-down icon-arrow-cerulean-left icon-arrow-cerulean-right icon-arrow-down icon-arrow-left icon-arrow-right icon-arrow icon-back icon-close icon-comments icon-correct-answer icon-tick icon-download icon-facebook icon-flag icon-google-plus icon-hamburger icon-in icon-info icon-instagram icon-login-true icon-login icon-mail-notification icon-mail icon-mortarboard icon-newsletter icon-notification icon-pinterest icon-plus icon-rss icon-search icon-share icon-shield icon-snapchat icon-star icon-tutorials icon-twitter icon-universities icon-videos icon-views icon-whatsapp icon-xing icon-youtube icon-jobs icon-heart icon-heart2 aris-express bpm-glossary help-intro help-design Process_Mining_Icon help-publishing help-administration help-dashboarding help-archive help-risk icon-knowledge icon-question icon-events icon-message icon-more icon-pencil forum-icon icon-lock