Zoho Creator: How to Include Attachments when Using Send Mail

The official send mail documentation mentions attachments but provides no syntax examples for how to include them in your Deluge script.

The following example for sending a single attachment is from a forum post by Anbu:

sendmail
[
    To       :  zoho.adminuserid 
    From     :  zoho.adminuserid 
    Subject  :  "Test for file upload field!!" 
    Message  :  input.File_upload + "Your message" 
    Attachments : file:input.File_upload
]

If you want to include multiple attachments, just separate them using commas. The helpful example given by MeeraS in this forum post shows a variety of ways to specify the desired file or template:

sendmail
[
 from :zoho.loginuserid
 to : 
 subject :"Message"
 message :"Received"
 content type :HTML
 Attachments :template:test as inline,template:test as pdf,file:input.Resume,file:input.Experience_Certificate
] 

I have a form that allows for uploading multiple files via a subform. My current goal is to figure out how to attach them all. There’s got to be a way, right?

How to Build and Iterate Through a Collection with Key-Value Pairs

Zoho Creator now has collection variables that can function either as a list of indexed items or as a map with key-value pairs. Creating the collection and filling it up is straight-forward:

message_data = Collection();
message_data.insert("Description" : input.Description);
message_data.insert("Price" : input.Price.toString());
message_data.insert("Weight" : input.Weight + " lbs.");

The step of iterating through each key-value pair is where things get a bit trickier. I found some errors in the documentation as I was trying to work this out. Hopefully they can be corrected, but in the meantime, here’s how to do it:

k = ""; 
for each k in message_data.keys() 
{
      message_string = message_string + k + ": " + message_data.get(k); 
}

message_data.keys() returns a list of all the keys in the collection. According to the documentation, the way to iterate through all the elements in a list is for each element but when I included the word “element” I got an error message.

The help page also claims that you can specify any variable (I used ‘k’) without having to declare it first but again, I got an error until I added the declaration: k = "";

How to Preserve Line-Breaks when Adding a Multi-Line Field to an Email

Say you are putting data from a Zoho Creator form into an email using Deluge script. You have a multi-line field called Notes where users can enter a bunch of notes.

If you want to include this Notes field in your email, you might be disappointed to find that the line breaks disappear, leaving you with one giant unreadable paragraph:

Fortunately, there’s an easy fix for this! The following code will replace all instances of the existing “\n” escape sequence with the email friendly “<br>” tag.

input.Notes.replaceall("\n","<br>") 

Ah, much better:

New Category: Zoho Creator

Now that I am no longer using Revit professionally, I haven’t had anything to post on the blog.

I’ve decided to expand into other technical applications that I use. As I encounter and solve problems in my work, I will blog about them here in hopes of helping other people with the same issues! At the very least, I’ll be able to look back at my old posts when I come across the same problem six months later and forget how I solved it.

Lately I’ve been developing a database application using Zoho Creator. I’ve created a new category on the blog to post my Zoho Creator solutions. Stay tuned!

How to Get Your Materials Right

Every material in Revit has an appearance asset that controls how it looks in the realistic visual style and in renderings.  These assets come in different types and each type has a different set of properties.  For instance, you can give a generic asset an image texture, but a paint asset can only get a solid color.

Appearance Asset

It’s a really good idea to spend some time exploring the asset browser to familiarize yourself with all the pre-made appearance assets at your disposal.  You might find that an appearance you thought you’d need to create from scratch already exists!  Or you might find something similar that you can tweak until it’s just right.

Open the asset browser and set your view to show the largest possible thumbnails, so you can get a sense of what all the appearances are really like.  Then scroll through all the categories to see what’s in there!

When you create a new material from scratch, it will have a generic appearance aspect.  You can’t change the type of an existing asset.

Create New MaterialDefault Generic Type

If you want to make a new metal material, for instance, you can’t just create a new material.  You could duplicate and rename an existing material that has a metal appearance, but you might have to override a lot of properties afterward to get it how you want it.

Duplicate MaterialMetal

Alternatively, you can create a new material and then replace its appearance asset.  Open the asset browser and find the list of default appearances.  Choose the one you want and click the button to replace the current asset.

 

There are a lot of asset types.  Sometimes it’s obvious which one is the best fit, but sometimes it’s hard to know which one to choose!  You can look at the help files to get a detailed list of the properties that go with each type, but here’s a quick list of the options:

  • Ceramic
  • Concrete
  • Generic Material
  • Glass
  • Glazing
  • Masonry/CMU
  • Metal
  • Metallic Paint
  • Mirror
  • Paint (color only – no image option)
  • Plastic/Vinyl
  • Stone
  • Water
  • Wood

If you have a material you want to use in other projects, you can save it to favorites by dragging the image icon into the favorites window.  If you want more organization, you can create material libraries to hold different sets of materials.

Drag Into Favorites.png

How to Make Temporary Dimensions Easier to Click

Do you have a frustrating time trying to select temporary dimensions so you can type in a new value?  When the distance is short, it’s hard to select the number.  You have to be very careful to avoid clicking the little blue dot that makes the witness line jump around.  Zooming in makes it easier but still slows you down.

Tiny Temp Dimension
So hard to read, let alone click!

Oops
Oops!  Come back here, witness line!

The best solution to this hassle is to change the size of the temporary dimension text.  You only have to make the change once, and it will apply whenever you open Revit, no matter which project you’re in.

Open up the Options window from the corner Revit menu.

On the Graphics page, you’ll find a place to select the size the temporary dimension text.  The default is 8, which is pretty tiny.  Bump it up to something like 16, and it will become much easier to select the text rather than the witness line.  You can experiment with different sizes to figure out which one you like the best.

While you’re in the Options window, consider changing the Pre-selection color from the default blue to a contrasting color.  As the picture below shows, it makes it really easy to tell what you’re about to select.  And the large text makes such a big difference!

Large Temp Dimension