Archi Forum

Archi Plug-ins => jArchi => Topic started by: JoCriSem on October 28, 2020, 14:51:18 PM

Title: Can't run Change Type scripts anymore (Premium)
Post by: JoCriSem on October 28, 2020, 14:51:18 PM
When running a change type script I am getting this error message:  Script Error: com.archimatetool.script.ArchiScriptException: Could not create element of type: business role
Anyone any idea of what could be wrong?
The 'examples' scripts just run fine.

I am using v4.7.1 on MacOS and the plugin version is com.archimatetool.script_0.8.0.202006231201.archiplugin

Thanks.
Title: Re: Can't run Change Type scripts anymore (Premium)
Post by: Phil Beauvoir on October 28, 2020, 14:54:05 PM
What script is it that you are running?

Can you post part of the script.

Note that it should be "business-role".
Title: Re: Can't run Change Type scripts anymore (Premium)
Post by: JoCriSem on October 29, 2020, 07:26:32 AM
Phil, this error was the result of running the Change Type - Business Role script (see attachement).
This has worked just fine, till now.
This is the entire script:

load(__DIR__+"/../ConvertConcept.lib.js");

convert(selection, getTypeFromFilename());

function getTypeFromFilename() {
  return __FILE__.replace(/^.*\//, '').replace(/\.ajs$/, '').replace(/%20/, '-').toLowerCase();
}



Title: Re: Can't run Change Type scripts anymore (Premium)
Post by: Phil Beauvoir on October 29, 2020, 09:11:56 AM
Try and debug it and see what values are returned from the function calls.
Title: Re: Can't run Change Type scripts anymore (Premium)
Post by: bigyin on October 29, 2020, 10:06:43 AM
Phil, issues seems more fundamental.. all scripts are not running now. However if I try on another Archi instance (in VM) no issue. Wonder if good ol MS have patched something and broken the stack.
Title: Re: Can't run Change Type scripts anymore (Premium)
Post by: Phil Beauvoir on October 29, 2020, 10:46:36 AM
@JoCriSem - I had to do some detective work to figure out what was going on. Please, next time, could you provide more information to make this easier? A link to the source script would have helped. Thanks.

The script in question came from here:

https://gist.github.com/jbsarrodie/45a312cff559d23cf55ed102422e8af7

It seems that Mac uses " " and Windows uses "%20" characters in file paths.

See this comment for a fix:

https://gist.github.com/jbsarrodie/45a312cff559d23cf55ed102422e8af7#gistcomment-3508647
Title: Re: Can't run Change Type scripts anymore (Premium)
Post by: Phil Beauvoir on October 29, 2020, 10:47:38 AM
Quote from: bigyin on October 29, 2020, 10:06:43 AM
Phil, issues seems more fundamental.. all scripts are not running now. However if I try on another Archi instance (in VM) no issue. Wonder if good ol MS have patched something and broken the stack.

Tested on Windows (and Mac) and all my test scripts are running.
Title: Re: Can't run Change Type scripts anymore (Premium)
Post by: JoCriSem on October 29, 2020, 13:30:43 PM
@Phil, apologies.  Didn't know what you needed as info when reporting the issue.

Thanks for the answer.  It seems to work now.  Still doesn't explain why it has worked on my Mac before.

I'll update all scripts accordingly.

Thanks again.