Book a Demo

Author Topic: Getting started with workflow scripts  (Read 10531 times)

Filip Hendrickx

  • EA Novice
  • *
  • Posts: 13
  • Karma: +0/-0
    • View Profile
Getting started with workflow scripts
« on: January 20, 2012, 06:00:24 pm »
Hi there.

I'm new at making and using scripts in EA (9.2). So far, I managed to create and run project and diagram scripts. However, I can't seem to find how to make EA run a workflow script. If I understand correctly, these scripts should run automatically so that I e.g. can check whether the current user is allowed to perform the action he currently performs (like an object creation).

Creating a new workflow script in a workflow script group doesn't seem to do the trick.

Any help is greatly appreciated!

Filip.

OpenIT Solutions

  • EA User
  • **
  • Posts: 555
  • Karma: +9/-1
    • View Profile
Re: Getting started with workflow scripts
« Reply #1 on: January 23, 2012, 11:11:26 pm »
Hi,

It should work - can you post your code - it could be that you don't have the correct (or any) event handlers in your code...There is a good template on the community site that extends the default workflow template as well...

Regards,

Jon.

Filip Hendrickx

  • EA Novice
  • *
  • Posts: 13
  • Karma: +0/-0
    • View Profile
Re: Getting started with workflow scripts
« Reply #2 on: January 24, 2012, 03:53:49 am »
Hi Jon.

Thanks for your reply. I just took the standard workflow script and slightly modified the first (OnPreNewElement) and one but last (AllowVersionUpdate) function so that they disallow the change and give some feedback. Doesn't seem to work regardless of having the output (tried that to ensure these lines didn't have syntax errors).

Below you can find the modified parts of the script (full script is too large to include).

Regards,

Filip.

-----

Code: [Select]
public function OnPreNewElement( ElementType, ElementStereotype )

      MsgBox "OnPreNewElement speaking!"

      ' Obtain a reference to the current user
      dim currentUser
      set currentUser = WorkflowUser

      SetLastError "A validation error occured " & ElementType & " " & ElementStereoType, ERROR_OUTPUT
      
      OnPreNewElement = false
      
end function



public function AllowVersionUpdate( OldValue, NewValue )

      ' Obtain a reference to the current user and selected item
      dim currentUser, currentItem
      set currentUser = WorkflowUser
      set currentItem = WorkflowContext

    SetLastError "A validation error occured " & OldValue & " " & NewValue, ERROR_OUTPUT
      
      AllowVersionUpdate = false
      
end function

OpenIT Solutions

  • EA User
  • **
  • Posts: 555
  • Karma: +9/-1
    • View Profile
Re: Getting started with workflow scripts
« Reply #3 on: January 27, 2012, 04:09:28 am »
Hi,

I'm afraid i can't see what the problem is - by understanding we should get a msgbox when you add an element...not sure why its not...

Apologies,

Jon.

Filip Hendrickx

  • EA Novice
  • *
  • Posts: 13
  • Karma: +0/-0
    • View Profile
Re: Getting started with workflow scripts
« Reply #4 on: January 31, 2012, 08:21:37 am »
Hello all.

A colleague of mine found the problem: I had overlooked that security must be enabled for workflow scripts to work.

I also noted that it only works for scripts created after security has been enabled.

Thanks for looking into it, Jon!

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Getting started with workflow scripts
« Reply #5 on: January 31, 2012, 12:13:30 pm »
Quote
Hello all.

A colleague of mine found the problem: I had overlooked that security must be enabled for workflow scripts to work.

I also noted that it only works for scripts created after security has been enabled.

Thanks for looking into it, Jon!
Hi Filip,

Where does it say that Security MUST be enabled for Workflow scripts?  I'd only seen references to: IF security is enabled.

Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

OpenIT Solutions

  • EA User
  • **
  • Posts: 555
  • Karma: +9/-1
    • View Profile
Re: Getting started with workflow scripts
« Reply #6 on: February 01, 2012, 02:30:42 am »
Hi Filip,

Thanks for feeding back the solution.

Regards,

Jon.

RoyC

  • EA Administrator
  • EA Practitioner
  • *****
  • Posts: 1297
  • Karma: +21/-4
  • Read The Help!
    • View Profile
Re: Getting started with workflow scripts
« Reply #7 on: February 01, 2012, 04:39:13 pm »
Paolo

It is strongly suggested in the Help that User Security is a prerequisite for Workflow Scripting, but not categorically stated.

I have now updated the Help to include (amongst other things) the statement:

Workflow Scripting is an extension of User Security, and requires security to be enabled in order to function

Best Regards, Roy

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Getting started with workflow scripts
« Reply #8 on: February 01, 2012, 09:41:58 pm »
Roy,
you're doing an excellent job. EA's help is, compared to most (almost all) other software, really helpful.

q.

RoyC

  • EA Administrator
  • EA Practitioner
  • *****
  • Posts: 1297
  • Karma: +21/-4
  • Read The Help!
    • View Profile
Re: Getting started with workflow scripts
« Reply #9 on: February 02, 2012, 08:50:45 am »
Thank you. I'll pass your comment on to my Sparx colleagues, who all work hard to make the Help as accurate and useful as possible.
Best Regards, Roy

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Getting started with workflow scripts
« Reply #10 on: February 02, 2012, 11:00:08 am »
Quote
Paolo

It is strongly suggested in the Help that User Security is a prerequisite for Workflow Scripting, but not categorically stated.

I have now updated the Help to include (amongst other things) the statement:

Workflow Scripting is an extension of User Security, and requires security to be enabled in order to function

Thanks Roy,

As you know I've previously echoed qwerty's thoughts on the great work you (an the other support guys) are doing.

Paolo

« Last Edit: February 02, 2012, 11:02:49 am by PaoloFCantoni »
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!