Product Documentation

Configuring Macro Substitution for Uploading Files

Dec 21, 2015

If you want to upload files and Mortscript script files, select the Macro must be replaced box. When you select this check box, it indicates that the script file must be checked before deployment to substitute macros with dynamic values that depend on the user and device.

An example of a macro in a Mortscriptscript is as follows:

result = Question( "Hello world, mail = %{ user.mail? | protect('"', '"') | encode('UTF-8') }%!", "It’s a start!", "YesNo")

The macro is located between the %{...}% tags. The server does not detect in advance the file format or its encoding. Instead, the files are analyzed in binary format. The “%”, “{“, ... are checked in ASCII format. Those are compatible with most characters encoding (but not UTF-16).

The macros are made of several parts separated by the pipe character: xxx | yyy | zzz:

  • The first element indicates a property: for a user property, or for a device property. You can use the ? character to indicate to use an empty string if the property is not defined.
  • The next elements are filters used to encode, transform and mostly protect the string so that it can enter the file context.

In this example, the elements are: user.mail? | protect('"', '"') | encode('UTF-8')

  • user.mail? : insert the “mail” property of the user. Use an empty string if it is empty or not defined.
  • protect(‘”’, ‘”’): protect the quote character by adding another quote before it. This protection is specific to Mortscript that requires to double that character when one wants to define one. For instance: “This is a quote “” in Mortscript”.
  • encode('UTF-8'): encode the string in UTF-8.

The last part is important since only a binary element can be inserted by Device Manager:

  • user.mail? : give a character string.
  • protect('"', '"'): takes a string in input and ouputs a string.
  • encode('UTF-8'): takes a string in input and outputs a binary array.
Note: Use other encodings if necessary, like CP1252 in France if you want to use accentuated characters.

This other available functions are:

  • S64Encode: [binary => text] encodes a binary in S64.
  • S64Decode: [text => binary] decodes a S64 string to binary.
  • B64Encode: [binary => text] encodes a binary in Base64.
  • B64Decode: [text => binary] decodes a Base64 string to binary.
  • encode(encoding): [text => binary] encodes a string with a specific encoding.
  • decode(encoding): [binary => text] decodes a binary array to a string.
  • protect(searched_character, protection_character): [text => text] insert the protection_character before the searched_character.
  • transform(searched_string, replacement_string): [text => text] replace searched_string by replacement_string.

You can use the following user properties in the scripts:

  • cn
  • company
  • companyname
  • property_country
  • department
  • description
  • displayname
  • distinguishedname
  • facsimiletelephonenumber
  • givenname
  • homecity
  • homecountry
  • homefax
  • homephone
  • homestate
  • homestreetaddress
  • homezip
  • ipphone
  • mail
  • middleinitial
  • mobile
  • officestreetaddress
  • pager
  • physicaldeliveryofficename
  • postalcode
  • postofficebox
  • telephonenumber
  • samaccountname
  • sn
  • st
  • streetaddress
  • title
  • userprincipalname
  • domainname

When users connect to an LDAP directory, most these properties are completed automatically. You can also manually enter the properties in the user properties dialog.

You can use the following device properties:

  • ew_version
  • ew_revision
  • cpu_clock_speed
  • sim_id
  • memory
  • freedisk
  • tel_number
  • system_oem
  • system_platform
  • cpu_type
  • system_os_version
  • system_os_build
  • memory_available
  • total_disk_space
  • system_language
  • user_language
  • screen_width
  • screen_height
  • screen_nb_colors
  • main_battery_percent
  • backup_battery_percent
  • battery_charging
  • external_storage1_name
  • external_storage1_total_space
  • external_storage1_free_space
  • external_storage2_name
  • external_storage2_total_space
  • external_storage2_free_space
  • user_defined_1
  • user_defined_2
  • user_defined_3

You can also use any custom property defined for the device or user.