Automatic Links
The Automatic Links page allows you to use Quable PIM's powerful rule engine to specify conditions for automatically linking uploaded assets to your existing documents or variants.
The page displays a list of your existing automatic link rules (if any) and action buttons to add, edit, or delete rules.
Coding skills may be required to create automatic link rules since the process includes creating a regular expression (regex) and two JSON (JavaScript Object Notation) statements.
Rules
Automatic links are based on rules that dynamically creates association between your documents/variants and assets based on part of the uploaded asset's name (a regular expression defined when creating the rule for the link). All assets that should be linked via a specific automatic link rule must be named according to the pattern defined in the rule.
When an asset is uploaded, Quable PIM interprets the regular expression defined in the rule, and searches for a document or variant that corresponds to the rule's conditions. If a match is found, the association is made.
Each automatic link rule is limited a single document type. You must create distinct rules for each document type that you want automatically linked with uploaded assets.
Naming Convention
Automatic link rules depend on regular expressions to interpret the name of uploaded assets and know which document type to associate them with. This requires that the names of your assets follow a specific pattern.
There are no limitations on your overall pattern, however, a document identifier must be included in the asset name. A document identifier is a string of alphanumeric characters that identify a document (document's code or attribute value). This enables Quable PIM to identify the document type to be linked.
There is no specific format required, but it's highly recommended to keep your naming convention as simple as possible. Your Quable PIM Product Manager can provide you a template to help you create your own naming convention.
Example 1
You want to automatically link assets to your product document type with the product_main_pictures link type. Your Quable PIM administrator has created an automatic rule to look for this naming convention:
random string_document code _1 .file extension |
The rule looks for:
- segments with specific data types,
- separated by underscores ( _ ), and
- a file extension.
The following table provides a breakdown of the segments in this example.
Segment | Data Type | Description |
---|---|---|
random string | alphanumeric characters | This can be any text. The rule only checks that there is some kind of alphanumeric content here. |
document code | alphanumeric characters | This identifies the document to link the asset to. In this case, the target document must be of the document type defined in the Rule If statement ("target_document_type ). |
1 | number | (optional) This indicates the asset's sequence. |
file extension | alphanumeric characters | This can be any file extion. The rule only checks that there is some kind of extension is here (e.g., .jpg, .png, .svg). |
To comply with this rule for an automatic link, your assets could be named:
picture_bluejean_1.jpg | |
abc123_bluejean_1.png | |
random_bluejean_1.svg |
As long as the name of the assets are in the correct format and include the document type code and the number 1, the assets will automatically be linked to the correct documents.
Example 2
You want to automatically link assets to to your product document type with the product_pictures link type. Your Quable PIM administrator has created an automatic rule to look for this naming convention:
(random string)document code -8 .file extension |
The rule looks for:
- segments with specific data types,
- separated by parenthesis ( ( ) ) and a hyphen (- ), and
- a file extension.
The following table provides a breakdown of the segments in this example.
Segment | Data Type | Description |
---|---|---|
random string | alphanumber characters | This can be any text. The rule only checks that there is some kind of alphanumeric content here. |
document code | alphanumber characters | This identifies the document to link the asset to. In this case, the target document must be of the document type defined in the Rule If statement ("target_document_type ). |
8 | number | (optional) This indicates the asset's sequence. |
file extension | alphanumber characters | This can be any file extion. The rule only checks that there is some kind of extension is here (e.g., jpg, png, svg). |
To comply with this rule for an automatic link, your assets could be named:
[picture]bluejean-8.jpg | |
[abc123]bluejean-8.png | |
[random]bluejean-8.svg |
Create Rules
To create an automatic link rule, click the New Rule button. A form is displayed to define the automatic link rule.
The form requires the following pieces of information:
- Slug - identifies the rule
- Event - indicates the action that triggers the rule
- Rule if - defines the conditions to meet
- Rule then - defines the action to take
This information is combined to create a JSON statement that Quable PIM interprets to make the automatic link. Each piece of information is described in the following sections.
Slug
The Slug is a human-readable identifier for the automatic link rule. This is typically a name which should be as descriptive as possible.
Information | Description |
---|---|
Slug | Enter text (alphanumeric characters) to identify your automatic link rule. |
Event
Importing an asset into Quable PIM is a distinct Event. This is what triggers the automatic link rule to take effect.
Information | Description |
---|---|
Event | Enter mediaupload to indicate the event the rule is triggerd by.Note: This must be entered exactly as shown. |
Rule if
The Rule if section defines a JSON statement with the conditions that must be met for the rule to apply:
Information | JSON Code | Description |
---|---|---|
Rule if | The conditions that must be met for the rule to be applied. It must be written in the format shown in the example (below). These conditions identify:
| |
target_document_type | The unique code of the document that should be linked. | |
target_value_type=”code” OR target_value_type=”eav” | ||
target_value=”” | If
| |
rule=”equal” | This indicates that the isolated part of the asset name must exactly match the document type or attribute code. | |
from_value_regex | A regular expression (regex) enabling the isolation of the assets name segments (in parenthesis, also known as capturing groups). The characters needing to be escaped must be escaped twice with a back slash (i.e., \\. for a point instead of .) By default, the first capturing group is looked at unless from_value_regex_group is used to specify a group.If you're new to regular expressions, you can refer to this site. | |
from_value_regex_group | (optional) An integer (number) indicating the capture group to be used for the document search (1 = first group, 2 = second group, etc.). | |
from_value_type="originalfilename” | This must be entered exactly as shown. | |
from_value=”” | This must be entered exactly as shown. |
Rule then
The Rule then section defines a JSON statement with the action to take if the conditions defined in the Rule if statement are met:
Information | JSON Code | Description |
---|---|---|
Rule then | The actions to take when the conditions for the rule are met. It must be written in the format shown in the example below. | |
action=createXObject | This must be used exactly as written. It tells Quable to create a link between the asset and the document/variant. | |
document_type | The unique code of the doc_type > asset link to use. The default link type is article_images_media. See Link Types to learn more about creating additional link types. | |
sequence_regex | (optional) A regular expression (regex) defining the order of the asset. Note: the sequence number must be included in the asset's originalfilename . | |
target_property="originalfilename" | (optional) Specifies that sequence_regex is in the asset's name. | |
side_entity=”target” | This must be used exactly as written. It makes the asset a child entity of the document it’s linked to. |
Example
You have a product document type with an attribute whose code is color. The attribute has two possible values (red, blue). To link the blue.jpg asset to all documents of the product type with blue as the value for the color attribute, your rule would look like:
Rule if statement:
{
"target_document_type": "product",
"target_value_type": "eav",
"target_value": "color",
"rule": "equal",
"from_value_regex": "\/^([a-zA-Z0-9]*)\\.[jpg|png]\/",
"from_value_type": "originalfilename",
"from_value": ""
}
Rule if logic: | ||
"target_document_type": "product" | The asset should link to a product document type. | |
"target_value_type": "eav" | The link should be based on an attribute. | |
"target_value": "color" | Use this specific attribute code. | |
"rule": "equal" | The asset name must be an exact match to an attribute value. | |
"from_value_regex": "\/^([a-zA-Z0-9]*)\\.[jpg|png]\/" | The name of the asset must be like this:
|
|
Rule then statement:
{
"action": "createXObject",
"document_type": "article_images_media",
"side_entity": "target"
}
Rule then logic: | ||
"action": "createXObject" | Create a connection object. | |
"document_type": "article_images_media" | Use the article_images_media link type. | |
"side_entity": "target" | Use the "target" in the Rule if statement. |
Edit Rules
You can modify an automatic link rule by selecting one from the list and clicking the Edit button. The information form is displayed.
When you've finished making modifications, click the Apply button to save your changes or the Back button link to return to the Automatic Links page without saving the changes.
Delete Rules
To delete an automatic link rule, select one from the list and click the Remove button. A dialog is displayed to cancel or confirm the deletion.
Click Yes to delete the rule or No to cancel the deletion.
Attention
This action is irreversible. Once an automatic link rule has been deleted, it can't be recovered.
Updated about 2 years ago