Skip to main content

IDEAScripting Tips and Hints

Description

Post for tips and hints on how to use IDEAScript.

How to disable warning messages

If you have ever created a script by copying code from the history or project overview you will know that if you run it and you haven't deleted your files you will get a warning asking you if you want to overwrite your file, so the code will stop each time and give you the warning.  If you want to disable these warnings you can add this line to the top of your code:

IgnoreWarning(True)

Now using this will overwrite any files with the same name so use with caution. 

 

 

Field.Types

IDEA has 14 different field types.  To access it in the script you would use the field.type function which would return an integer indicating which field type it is.  I noticed something interesting about the field types, 4 of the types are for editable fields, so when you are creating the field you would use the editable field type but once they are created and you use IDEA to see what type of field it is IDEA views them as normal IDEA field types.  Something to remember if you are using any editable types in your script.

Here is a breakdown of the field types.

Using the open database in your script

Sometimes you might want to use a script on an open IDEA file, the scripting language has a function to get the name of the current database, namely Client.CurrentDatabase(), the one problem with this is if there is no IDEA database open then the script will give you an error and stop. The way to get around this is to use the On Error Resume Next. So you try getting the current database, if the err.number is 0 then that means there was no error and a database is open, if you do get an error then you know that there is no open database and your filename is blank.

How to use MS outlook in an IDEAScript

I recently gave an IDEAScripting course and one of the participants had a need to be able to send emails based on a IDEA database using IDEAScript.  So I searched around the net and came up with the following that has worked on my home and work computers.  I have read that in some instances outlook might be set-up to reject requests from other software to send emails, if that is the case then this script would be blocked.  So in this example, I have five fields in an IDEA database, one of them is the email address and the others are information to insert into the message.&nbs

User Types

I was recently reviewing the IDEAScript training material for a class I am giving in a few weeks and came across the user type "variable".  This is something I don't usually use but probably should.  What it does is allow you to group different variable types into one grouping.  Also within the grouping the variable types are not limited to the same type, so you can mix them up.  I good example would be obtaining information from a database, you create a type that contains the different fields and define the variables so that it matches up with the information

Normalize Field Name

I just posted a snippet that will take a variable and change it into the format of an IDEA field name.  As IDEA will automatically change a fieldname to uppercase and replace spaces and special characters with an underscore you need to do this in your script so that you have access to the proper field name, this snippet should help you out.

http://ideascripting.com/snippet/normalize-field-name