Macro tags for Cargo

Macro summary list
%, FILE_DIMENSION_W I NR
%% FILE_EXISTS I_F PDF_FORMAT
ACTION_PARAMETER_IN FILE_ID I_F_SERVER PF
APP FILE_IS_DIRTY I_FILE_DOWNLOAD_LINK PROFILE
BASE64 FILE_IS_USED I_FILE_ID REPLACE_ALL
BASE64_FROM_FILE FILE_META I_FILE_SIZE RSET
BUCKET FILE_PARENT_PATH I_FILE_PATH SFN
BUCKET_LIST FILE_PATH ICON STRIP
BUCKET_LIST_REMOVE_DUPLICATES FILE_PREVIEW_PATH INDEX_OF SUBSTRING
CASE FILE_STATUS_ID JOB_ID SXML
CHAR FILE_STATUS_NAME JOB_META TRIM
CONNECT_ID FILE_THUMBNAIL_PATH JOB_STATUS_ID UPPER
CONNECT_PDF_FILE_ID FILE_UPLOAD_INDEX JOB_STATUS_NAME USER_EMAIL
CONNECT_PDF_PATH FILE_USAGE_COUNT LAST_INDEX_OF USER_LOGIN
D FOR_EACH_CURRENT_JOB LENGTH USER_NAME
E FOR_EACH_FILE LOWER USER_PASSWORD
F FOR_EACH_JOB_IN_SEARCH MATH UUID
FILE_CONTENT FOR_EACH_JOB_GROUP_IN_SEARCH META XPATH
FILE_DIMENSION FORMAT_DATE MOD XPATHLIST
FILE_DIMENSION_H HTML_ENCODE MOD_TIME  

Macro details

%,

Special macro that will return a single comma character ','.

%%

Special macro that will return a single percent character '%'.

%ACTION_PARAMETER_IN[key]%

This macro is available in actions and action sets in the Cargo admin setup. The data that is passed to the action consists of zero, one or more name-value pairs and the key parameter refers to the name of such a pair.

If the action is called from a Cargo form the keys will be the input field ID's.

External call setup

Please note that if an action is called from an external source the parameters to the call is structured in name-value pairs (e.g. using the URL query). The name in such a pair is the key that is references in the parameter in this macro. However the name must be preceeded with the text meta_ to be taken as an actual parameter that may be used in this macro.

If you for example have used the macro %ACTION_PARAMETER_IN[date]% in your setup the action that is called must have the following name-value pair: meta_date=2009-03-02 (the actual date could of course be other than 2009-03-02).

%APP[key]%

This is a special macro very rarely used.

In the container of the running application, servlet or applet there are some internal parameters which may be called with this macro. The parameter key differs for each container.

%BASE64[text, optional encoding]%

This will take a text and make a base64 encoded text from it. The optional encoding may be used if the source text is in a specific format.

BASE64_FROM_FILE[path]%

This will take a file and put create a Base64 encoded string from the content. The path argument is the full path to the file to encode.

%BUCKET[key]%

A macro very rarely used directly in the Cargo environment.

The bucket is a container of name-value pairs. These name-value pairs differs in different macro situations. The key parameter refers to the name in such a name-value pair.

If the value of the key is in a list form the result will be all the lsit values merged with comma and space between them.

%BUCKET_LIST[key,delimiter]%

This macro is like the BUCKET macro but this will assume that the value is a list of values. The result will be all the individual values merged together with the delimiter between them.

Note! If you want a comma as delimiter, the delimiter value must be %, since comma has a special meaning inside the macro.

%BUCKET_LIST_REMOVE_DUPLICATES[key]%

This is a special macro with no output. The macro will only modify a bucket value which is a list of values. All duplicate values will be removed from the list value.

%CASE[exp,t,f]%

This macro is evaluating a condition and will return different values depending on the condition result.

The paramater exp which is evaluated must be a valid expression, see below.

If the expression is evaluated to true, the t text (which may contain other macros) is parsed and returned. If the expression is false the f text is parsed and returned.

The expression exp must contain one (the first occurance is taken) of the following mathematical expression

Expression Meaning Description
< less than This expression is only valid if the left and right component are numbers.
<= less than or equals This expression is only valid if the left and right component are numbers.
> bigger than This expression is only valid if the left and right component are numbers.
>= bigger than or equals This expression is only valid if the left and right component are numbers.
== equals Checks if the left and right components are equal.
<> not equals Checks if the left and right components differ.
%CHAR[no]%

Will return the character that has the unicode decimal number no.

%CONNECT_ID%

This will return the unique Cargo Connect ID for the job in the current scope of execution.

%CONNECT_PDF_FILE_ID%

This will return the unique file ID for the Cargo Connect production PDF file of the job in the current scope of execution.

%CONNECT_PDF_PATH%

This will return the full path to the Cargo Connect production PDF file of the job in the current scope of execution.

%D%
%D[
format]%
%D[+d,format]%
%D[-d,format]%

Simple form

In the simple form, returns the current date in the format yyyy-MM-dd.

Variant [format]

If format is specified the result will be in the specified format. The format may contain special characters such as dot (.), comma (,) (note! if a comma is to be used as separator it must be escaped with a '%' in order to be handled correctly) and hyphen (-). The characters below shows how to get a certain format. The number of each character decide the result date string, e.g. in the year 2006, yyyy would result in 2006 while yy gives 06.

Format character
y The year
M The month in year
w The week in year
W The week in month
D The day in year
d The day in month
F Day in week as number
E Day in week as text
a AM/PM
H Hour in day (0-23)
k Hour in day (1-24)
K Hour in am/pm (0-11)
h Hour in am/pm (1-12)
m Minute in hour
s Second in minute
S Millisecond

Variant[+d,format] or [-d,format]

If the first parameter starts with a plus sign or minus sign the specified d number of days will be added or withdrawn respectively from the current date before the result is calculated. The format is as described above.

%E%

Note that this macro is only useful in the context where a single file is referred.

File name suffix (dot included) if any. If the file does not have any suffix an empty string is the result.

%F%
%F[
s,e]%
%F[O,ch]%
%F[O,ch,no,l]%
%F[OI,index,no,l]%

Note that this macro is only useful in the context where a single file is referred.

Simple form
The file name stem (i.e the file name but without the file name suffix and belonging dot).

Variant [s,e]

Part of the file name stem. Start at index s (the first character has index 1) and end at index e. If s is not specified, 1 is used. If e is missing the last character index is used. Note that the comma characters must be present even if either s or e is left out.

Variant [O,ch]

The first parameter is the letter 'O'. This gives a part of the file name stem starting at the first character and take all characters before the first occurance of ch. If ch is not found in the file name the result is the same as %F%.

Variant [O,ch,no,l]

The first parameter is the letter 'O'. This gives a part of the file name stem starting at the first occurance of ch. Then move no steps (a minus sign may preceed no to go backwards). This is now the start position and l number of characters are read. If l is missing the rest of the file name stem is read. Note that the last comma must be present even if l is left out.

Variant[OI,index,no,l]

The first parameter is the letters 'O' and 'I'. This gives part of the file name stem starting at character index (first character is index 1, if the last character is wanted then use -1). Then no (number) steps will be taken (minus sign may preceed no to go backwards). This is the start and from here l number of characters are read. If l is missing the rest of the file name stem is read. Note that the last comma must be present even if l is left out.

%FILE_CONTENT[file,format,start,end]%

Reading the file with path file (the path is depending on the environment from which this macro is called) and returns the content in the file in the selected text format format.

If the format is omitted, 'UTF-8' is used as default format. Note that the comma must be present even if format is left out.

Optionally the start and end parameters may be used. These will indicate the start and end location to get a portion of the file content. The start and end parameters are the byte location. The first location in the file is zero (0).

%FILE_DIMENSION[decimals=0, pdfBox]%

This macro is only useful in contexts where a file is present.

This will get the file dimensions in mm. This macro is only available for EPS and PDF files.

The first parameter is the number of decimals to use, if this parameter is missing the default value is set to zero (0) decimals.

The second parameter is only useful when the file is a PDF file. This is then the PDF box to use when getting the dimension. If this is left out the default order will be trimBox,mediaBox,cropBox,bleedBox,artBox.

Also see macro FILE_DIMENSION_W and FILE_DIMENSION_H for more information.

%FILE_DIMENSION_H[decimals=0, pdfBox]%

This macro is similar to FILE_DIMENSION but this macro will only get the width part of the dimension.

%FILE_DIMENSION_W[decimals=0, pdfBox]%

This macro is similar to FILE_DIMENSION but this macro will only get the height part of the dimension.

FILE_EXISTS[path]%

Checks if a certain file (with the path path) exists. This will return "true" if the file exists and "false" otherwise.

%FILE_ID%

Gets the file ID of the current file being handled.

%FILE_IS_DIRTY%

Checks if the current file is 'dirty' (i.e. it has been modified but not saved in Cargo Connect production). The result is '1' if the file is dirty and '0' otherwise.

%FILE_IS_USED%

Checks if the current file is is use (i.e. it has been used in a Cargo Connect production document). The result is '1' if the file is used and '0' otherwise.

%FILE_META[id]%

This macro is only useful in contexts where a file is present.

This will get the value from the file metadata where the key is id.

%FILE_PARENT_PATH%

Note that this macro is only useful in the context where a single file is referred.

The current file's parent folder path.

%FILE_PATH%

Note that this macro is only useful in the context where a single file is referred.

The full path to the current file.

%FILE_PREVIEW_PATH%

Note that this macro is only useful in the context where a single file is referred.

The full path to the current file's preview image file.

%FILE_STATUS_ID%

Note that this macro is only useful in the context where a cargo file is referred.

This macro will return the file status ID of the cargo file.

%FILE_STATUS_NAME%

Note that this macro is only useful in the context where a cargo file is referred.

This macro will return the file status name of the cargo file.

%FILE_THUMBNAIL_PATH%

Note that this macro is only useful in the context where a single file is referred.

The full path to the current file's thumbnail image file.

%FILE_UPLOAD_INDEX%

Note that this macro is only useful in the context where an upload is taking place.

This will give the index of the file beign uploaded.

%FILE_USAGE_COUNT%

Returns the number of occasions this file is being used in a Cargo Connection Production document.

%FOR_EACH_CURRENT_JOB[inner text]%

This macro may be used inside the macro FOR_EACH_JOB_GROUP_IN_SEARCH. This macro will iterate and evaluate the inner text for each job in the current job group coming from the macro FOR_EACH_JOB_GROUP_IN_SEARCH.

%FOR_EACH_FILE[text]%

Note that this macro is only useful in a profile action in Cargo where the uploaded files are used.

This is a special iterator macro which will iterate the text (which might contain macros) for each current file. To be able to use any of the file data such as file name in the text the special iterator macros starting with I_ must be used with an iterator index (see %I%).

Example with iteration

If you want to send an email when a job has been uploaded to the server and you want the text to contain all the uploaded files original names you use the following macro text:

The uploaded files are:
%FOR_EACH_FILE[ %I_F[%I%]% %CHAR[13]%]%

The macro %CHAR[13]% will insert a return after each file name for a neater output.

%FOR_EACH_JOB_IN_SEARCH[key,iterator]%

Only relevant in the context where a job search has been performed, e.g. in an action set where one action has done a search for jobs.

The key is the reference to the job search id (see the settings for a job search action). The iterator text will be iterated for each single job in the rsult from the search.

%FOR_EACH_JOB_GROUP_IN_SEARCH[key,grouping,bucketID,iterator]%

Only relevant in the context where a job search has been performed, e.g. in an action set where one action has done a search for jobs.

The key is the reference to the job search id (see the settings for a job search action).

The result set will be grouped together based on the grouping key. The grouping key may be any of the following;

Group key Description
meta-metakey This will compare the meta data with key metakey. If the value of the meta data is the same these jobs will be grouped together.
jobID Compares the job ID's and group the jobs with the same ID together.
status Compares the job statuses and group the jobs with the same status together.
profileID Compares the job's profile ID's and group the jobs with the same ID together.
lastChanged Compares the time when the jobs were last changed and group the jobs with the same time together.

When the jobs has been grouped together, each group is iterated and the iterator text is evaluated for each group. Generally the macro FOR_EACH_CURRENT_JOB will be used in the iterator text. For each iterator the bucket will get an extra value with the key bucketID where the value is the value for the group value (e.g. if the grouping was 'status' the value will be the actual status value).

FORMAT_DATE[text,from,to]%

This macro is used to convert a text from one date format to another. For the different pattern characters, see the %D% macro.

The text is the source date specified in the from format. The result is the same date specified in the to format.

%HTML_ENCODE[text]%

Returns a HTML formated text based on the text. Entities such as &aring; will be used instead of å and so on.

%I%

Special macro used in the iterator macros starting with I_. The iterator macros need an iterator index and the %I% macro is such an index which automatically will increase for each iteration.

%I_F[i]%

Note that this macro is only useful in a profile action in Cargo where the uploaded files are used.

Special iterator macro used in a iterator macro such as FOR_EACH_FILE.

This macro returns the original file name for the file with index i. See %I% which is commonly used as the iterator index.

%I_F_SERVER[i]%

Note that this macro is only useful in a profile action in Cargo where the uploaded files are used.

Special iterator macro used in a iterator macro such as FOR_EACH_FILE.

This macro returns the server file name for the file with index i. The server file name is the name the file has on the server which might differ from the original file name. See %I% which is commonly used as the iterator index.

%I_FILE_DOWNLOAD_LINK[i]%

Note that this macro is only useful in a profile action in Cargo where the uploaded files are used.

Special iterator macro used in a iterator macro such as FOR_EACH_FILE.

This macro returns the file download ID for the file with index i. The download ID may be used for example in the email body text of a profile email action where the uploaded file will be available to download directly in the email.

Send an email notification with direct download link

If the email profile action is used the email body may contain a download link to the file(s) that has been uploaded. HTML must be used in the email body for this to work.

Below you can see an example of the email body text set in the email action. Replace the address 127.0.0.1:8080 with your server address when using the example text.

<html>
<body>
<p>The files below has been uploaded. Click on them to download the files.</p>

<p>%FOR_EACH_FILE[
<a href="http://127.0.0.1:8080/cargo/cargoServlet?
cargoRequest=directDownload&id=%I_FILE_DOWNLOAD_LINK[%I%]%">%HTML_ENCODE[%I_F[%I%]%]%</a><br />]%
</p>
</body>
</html
>

 

See %I% which is commonly used as the iterator index.

%I_FILE_ID[i]%

Note that this macro is only useful in a profile action in Cargo where the uploaded files are used.

Special iterator macro used in a iterator macro such as FOR_EACH_FILE.

This macro returns the file ID for the file with index i. See %I% which is commonly used as the iterator index.

%I_FILE_SIZE[i]%

Note that this macro is only useful in a profile action in Cargo where the uploaded files are used.

Special iterator macro used in a iterator macro such as FOR_EACH_FILE.

This macro returns the size in bytes for the file with index i. See %I% which is commonly used as the iterator index.

%I_FILE_PATH[i]%

Note that this macro is only useful in a profile action in Cargo where the uploaded files are used.

Special iterator macro used in a iterator macro such as FOR_EACH_FILE.

This macro returns the full path on the server for the file with index i. See %I% which is commonly used as the iterator index.

%ICON[type]%
%ICON[url,url]%
%ICON[
w,h,,type,r,g,b]%

Note that this macro is only in column value or column mapping in the admin profile setup and admin external database setup.

Variant [type]

This variant of the ICON macro will return one of the built-in icons in the Cargo system. The icons and their type values are seen below;


circleBlack

circleBlue

circleYellow

circleGreen

circleRed

circleGray

circleWhite

checkBlack

checkBlue

checkYellow

checkGreen

checkRed

checkGray

checkWhite

octagonBlack

octagonBlue

octagonYellow

octagonGreen

octagonRed

octagonGray

octagonWhite

squareBlack


squareBlue

squareYellow

squareGreen

squareRed

squareGray

squareWhite

starBlack

starBlue

starYellow

starGreen

starRed

starGray

starWhite

triangleBlack

triangleBlue

triangleYellow

triangleGreen

triangleRed

triangleGray

triangleWhite

xBlack

xBlue

xYellow

xGreen

xRed

xGray

xWhite

Variant [url,url]

This variant has the text 'url' as the first parameter. The second parameter is a full HTTP address from where the image is fetched. Note that the image is not scaled but is shown in 100% size.

Variant [w,h,,type,r,g,b]

This variant will create an icon on the fly with the specified parameters;

w: The width of the icon
h: The height of the icon
type: The type, any of the following values: circle, square, arrowUp, arrowDown, arrowLeft, arrowRight
r, g and b: The color components red, green and blue of the icon.

%INDEX_OF[s,t,start]%

The text s is searched and the index of the first occurance of t is returned. The index is zero based meaning that if s starts with t the returned index is '0'. If the t is not found in s -1 will be returned.

Both s and t might contain macro text themselves.

If the optional start parameter is present this is the start index in the text from which the search starts. Any occurance of t before this index is not counted. The start index is zero-based meaning that the first character in s has the index 0 (zero).

%JOB_ID%

%JOB_ID[min]%

Note that this macro is only useful where a job is referred.

Simple form

Returns the current job ID. This ID is a unique identifier for each job.

Variant [min]

Returns the current job ID with the minimum length of min. If the ID is not min length the result is preceeded with zeroes (0).
For example: If the ID is "23" and the macro %JOB_ID[4]% is used the result string is "0023".

%JOB_META[key]%

Gets the curreent job's metadata named key

%JOB_STATUS_ID%

This macro will return the job status ID of the cargo job.

%JOB_STATUS_NAME%

This macro will return the job status name of the cargo job.

%LAST_INDEX_OF[s,t,start]%

The text s is searched and the index of the last occurance of t is returned. The index is zero based meaning that if s starts with t the returned index is '0'. If the t is not found in s -1 will be returned.

Both s and t might contain macro text themselves.

If the optional start parameter is present this is the index in the text from which the search starts (seen from the end). Any occurance of t after this index is not counted. The start index is zero-based meaning that the first character in s has the index 0 (zero).

%LENGTH[text]%

Returns the length of the text. The number of characters in text is counted and returned.

This macro may be very useful used for example in an expression, see macro CASE for more information.

%LOWER[text]%

The returned value is text where each character is in lower case in the returned value.

%MATH[math command, leftExpression, rightExpression, decimals]%

This will invoke the mathematical expression math command on the leftExpression and rightExpression. The returned number will have the maximum decimal count that is expressed in the parameter decimals. The leftExpression and rightExpression may contain numbers (possibly from other macros).

The decimals parameter is optional. If decimals is left out the last comma should also be left out.

The math command may be any of the following;

Math command Description
+ Will add leftExpression with rightExpression, e.g. %MATH[+, 12, 3]% will return '15'
- Will subtract leftExpression with rightExpression, e.g. %MATH[-, 12, 3]% will return '9'
* Will multiply leftExpression and rightExpression, e.g. %MATH[*, 12, 3]% will return '36'
/ Will divide leftExpression with rightExpression, e.g. %MATH[/, 12, 3]% will return '4'
%META[id]%

This macro is only useful in contexts where profile data is present, e.g. in profile actions.

This will get a value from the data that a user entered to a profile input form. The data is taken from the profile component with ID id.

Note that in most cases the macros %FILE_META[]% and %JOB_META[]% should be used instead of just %META[]%.

%MOD%

%MOD[format]%

%MOD[+d,format]%

%MOD[-d,format]%

Note that this macro is only useful in the context where a single file is referred.

The macro will return the modification time for the current referenced file. The variants for the macro follow the D macro where more information may be found for the different parameters.

%MOD_TIME%

%MOD_TIME[path]%

Gets the modification time of a file in milliseconds.

The default version will get the modification time from the current file in scope. The alternative is to pass a file path as parameter which will get the modification time of that file.

%NR[text]%

The returned value is text where each carriage return is removed. The carriage return is replaced with a space character if there is no space preceeding the carriage return. This means that even if there are multiple carriage returns immediately following eachother in the original text, they will only be replaced by maximum one space character.

%PDF_FORMAT[box,w]%

%PDF_FORMAT[box,h]%

This macro is only available in a transfer notification situation set in the external database source. The macro will only return a valid number if the currently selected job in the Dispatch interface is a single PDF file.

The currently selected PDF file's format of the box specified is returned. If the second parameter is the letter 'w' the width is returned, if the second parameter is the letter 'h' the height is returned. The format that is returned is expressed in points. The MATH macro may be used to convert the value to other formats, e.g. mm.

The valid box names are;

Box Description
media The PDF media box
crop The PDF crop box
bleed The PDF bleed box
trim The PDF trim box
art The PDF art box
%PF%

Note that this macro is only useful in the context where a file is referred.

This macro is similar to the F macro but the name is taken from the parent folder. All variants of the macro that are applicable to the F macro are also available to this macro.

%PROFILE%

Note that this macro is only useful where a profile is referred, e..g in a profile action.

Returns the name of the profile.

%REPLACE_ALL[s,source,target]%

Returns a modified version of s where all the occurancies of source are replaced with target.

Regular expression

source is a regular expression so use this macro with care. Make sure you are
familliar with regular expressions before using this macro.

%RSET[key]%

Note, this macro is only useful in the external database source context and may be used in the result column setup and transfer setup.

The value returned is from the selected row in the external database source. The selected row has values which are set in the server data setup in the external database source. Each such server data has an ID specified. The key refers to those server data IDs.

%SFN[text]%

Safe File Name - This will return the text where all occurancies of the following characters are replaced with underscore (_);

Character Character name
? Question mark
" Double quotes
! Exclamation mark
& Ampersand
/ Forward slash
\ Backward slash
: Colon
. Dot. if the name is starting with a dot that particular dot is replaced as well
%STRIP[text]%

Special macro that will replace all characters except the ones in the list below with a underscore (_)

Characters that will remain unchanged are:

. (dot)

- (dash)

_ (underscore)

0-9 (numbers)

a-z (character a to z)

A-Z (character A to Z)

%SUBSTRING[s,start,end]%

Returns a portion of the soruce string s. The portion is taken from index start (included) and ends at index end (not included). If end is missing the rest of the string is taken from the start. If start is missing the substring will be taken from the start. The index are zero-based meaning that the first character in s is having number 0.

Note that if start and/or end is left out the commas still need to be present.

%SXML[text]%

Returns a modified version of text. The return value is specialized to fit in XML documents where characters are replaced with entities, e.g. 'Ã¥' is replaced with '&aring;'. Characters with UTF character number more than 128 are replaced with the entity '&#no;' where no represents the UTF value of the character.

The string text may contain macros.

TRIM[text]%

This macro will remove all leading and trailing spaces from the text

%UPPER[text]%

The returned value is text where each character is in upper case in the returned value.

%USER_EMAIL%

This will return the email of the user currently in the scope of execution.

%USER_LOGIN%

This will return the login name of the user currently in the scope of execution.

%USER_NAME%

This will return the name of the user currently in the scope of execution.

%USER_PASSWORD%

This will return the password of the user currently in the scope of execution.

%UUID%

This macro will return a unique ID. This ID is a so called UUID.

%XPATH[text,xpath expression,nsPrefix=nsURI,nsPrefix2=nsURI2,...]%

This macro will evaluate a XPath expression (XPath 1.0).

The text is the XML that will be searched.

The xpath expression is the XPath query to execute.

Parameter 3 and all the following are optional. If they exists they should be entered in the following form: prefix=URI where prefix is the namespace prefix and URI is the URI used for that prefix. If the XML document does not use any namespace prefixes these parameters may be omitted.

If the result is not a single value, see macro XPATHLIST.

%XPATHLIST[text,xpath expression,bucket,nsPrefix=nsURI,nsPrefix2=nsURI2,...]%

This macro will evaluate a XPath expression (XPath 1.0) and it will store the result (as a list) in the specified bucket.

The text is the XML that will be searched.

The xpath expression is the XPath query to execute.

The bucket is the key to the current bucket where the result will be stored. The value is stored as a list and special list macros may be sued, for example %BUCKET_LIST[...]%.

Parameter 4 and all the following are optional. If they exists they should be entered in the following form: prefix=URI where prefix is the namespace prefix and URI is the URI used for that prefix. If the XML document does not use any namespace prefixes these parameters may be omitted.