Built In Method Example

These been some discussion about Build-In vs In-line methods,  here is a quick example of a Built-In method that sends email from instance attributes that is quite commonly done as a In-Line method when it does not need to be In-Line.

Start by creating a Class called Email

Screen Shot 2013-10-23 at 11.45.07

Set your schema as follows;

Screen Shot 2013-10-23 at 11.44.55

In your new class create a new method, but this time change the method type to Build-In, and add the following detail. Notice I have set  parameters also to the method.

Screen Shot 2013-10-23 at 11.44.34

Set the values to you instance in the new email class to the following, notice how I have also used variables in my strings to grab dynamic data.

Screen Shot 2013-10-23 at 11.44.26

The output in the automate log should look something like;

Screen Shot 2013-10-23 at 11.44.01

And when you test the BuiltIn Method, you will get and email just like the below

Screen Shot 2013-10-23 at 11.43.45

So how do we use this?

Every time you want to send an email, you simply link to an instance in the email class as a relationship. Example;

You have a state machine with many steps, somewhere you wish to send an email, add to your state machine a relationship to the email class and create an instance within the email class to send the email, with the body, subject set the way you wish. As shown here, the last line in the state machine is a replica of the one before, except I am using a builtIN method vs the one before is a IN-Line.

Screen Shot 2013-10-23 at 11.59.12

My email instance is set as follows,

Screen Shot 2013-10-23 at 12.00.23

The last thing to cover of is WHY???

Simply put an InLine Method will spawn a new environment space, where as BuiltIN is exactly that. Therefore BuiltIN is faster and lighter that InLine Methods.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s