Export template - Dos and Don'ts
There are several things which you should keep in mind when creating an export format template because a wrong usage can lead to performance problems. In this chapter we were taking a look at the design of several export format templates, hence this page will always be incomplete.
Export format template
Calling a submodule with functions
Please take care that you are not calling a submodule twice or more if it's not needed.
Example
Wrong: {?Compare {$MySubModule} , "", "", {$MySubModule} }
This is not only calling the submodule twice, it’s even useless because if something is empty then there would also be no output.
Correct: {$MySubModule}
Hint: You can also see the double call in the performance analysis:
Indication if a submodule got called
Take a variable to indicate if submodule has been called. Just write a value like “x” in a specific variable in the submodule and check this variable in the module.
Example
Wrong:
{$MySubmodule}
{?CreateXMLTagWithContent {?IfEmptyThen {$MySubmodule},
"<PARENT>"
},
"?"
}
{?CreateXMLTagWithContent {?IfEmptyThen {$MySubmodule},
"<CHILD />"
},
"?"
}
{?CreateXMLTagWithContent {?IfEmptyThen {$MySubmodule},
"</PARENT>"
},
"?"
}
Correct (Solution-Snippet):
Before calling submodule: {?ValueSet "containsChild", "" }
In the submodule: {?ValueSet "containsChild", "x" }
In the main module surround the tags by using the content of the function, e.g.: {? IfEmptyThen {?ValueGet "containsContributor" } , "<PARENT> <CHILD/> </PARENT>" }
After calling reset the variable: {?ValueSet "containsContributor", "" }
Execution of export functions
Each export function is executed during an export. The only exception is a function call within a comment "{!...}". The innermost function is exceuted first.
Example:
Wrong:
All of the following export functions will always be executed. This means the number "MyNumber" will always set to 0.
{?Compare {&MyModule.MyField}
,
"SomeValue"
,
""
,{?NumberSet
"MyNumber"
,
0
}
}
Correct:
All export function will be executed but the number "MyNumber" will contain the correct number.
{?NumberSet
"MyNumber"
,{?Compare {&MyModule.MyField}
,
"SomeValue"
,{?NumberGet
"MyNumber"
}
,
0
}
}
Nested export functions
If you have many nested functions of the same type or a huge nested export function as shown in the examples below, then it is recommended to implement your own export function. You can find some examples how to implement an export function in the SDK.
Example
Example for a functionality which could be used many times in one export format template
{?Replace
{?Replace {&MyModule.MyField}
,
","
,
""
}
,
"*"
,
""
}
Example for a deeply nested export function
{?IfNotEmptyThen {&Referenced products.Referenced object number(
4
)},
{?Compare {?EnumerationKey
"Enum.ArticleReferenceType"
, {&Referenced products.Reference type}},
"1"
,
"ABC"
, {?Compare {?EnumerationKey {&Referenced products.Reference type}},
"2"
,
"A"
,
, {?Compare {?EnumerationKey {&Referenced products.Reference type}},
"3"
,
"B"
, {?Compare {?EnumerationKey {&Referenced products.Reference type}},
"4"
,
"C"
, {?Compare {?EnumerationKey {&Referenced products.Reference type}},
"5"
,
"D"
, {?Compare {?EnumerationKey {&Referenced products.Reference type}},
"6"
,
"E"
, {?Compare {?EnumerationKey {&Referenced products.Reference type}},
"7"
,
"F"
, {?Compare {?EnumerationKey {&Referenced products.Reference type}},
"8"
,
"G"
, {?Compare {?EnumerationKey {&Referenced products.Reference type}},
"9"
,
"H"
, {?Compare {?EnumerationKey {&Referenced products.Reference type}},
"10"
,
"I"
, {?Compare {?EnumerationKey {&Referenced products.Reference type}},
"16"
,
"K"
,
""
}
}
}
}
}
}
}
}
}
}
}
}
Use export functions only if you need it
Sometimes you lead to just using a function instead of checking if this could really happen (see example A) or a function is getting used but is not doing anything (see example B).
Example A
Wrong:
{?Substring {&Product.Short description (English)}
,
"1"
,
"254"
}
Correct:
Check repository first and don't use the substring-export function.
Example B
Wrong: {?CreateXMLTagWithValue {?IfEmptyThen {&MyModule.myField} , "" } , "" }
Correct: {?CreateXMLTagWithValue {&MyModule.myField} ,"" }
Usage of concat export function
Please use the concat function as described with comma separators and “” for each parameter. It might work without, but there's no guarantee for it.
Example
Wrong: {?Concat {& MyModule.MyField } | {&MyModule.MyField2} ||, "test" }
Correct: {?Concat {&MyModule.MyField} , "|", {&MyModule.MyField2} , "||", "test" }
Usage of CompareBooleanValue function
Always use the CompareBooleanValue-Export function if you want to compare boolean values.
Example
Wrong: {?Compare {&MyModule.MyBooleanField} , "Yes", "Y", "N" }
Correct: {?CompareBooleanValue {&MyModule.MyBooleanField} , "Y", "N", "" }
Troubleshooting
Additional " in the output file
If you have additional "-signs in your output file of the export then this is always a sign of using the export wrong. Please check your template for correct syntax when you get this.
Examle
Wrong:
Export format template: {?CreateXMLTagWithValue "First text" {?SplitKeywords "Test1;Test2;Test3 } , "<PRODUCT>?</PRODUCT>" }
Generated output:
<PRODUCT>
First text" "Test1
Test2
Test3
</PRODUCT>
Correct: {?CreateXMLTagWithValue {?Concat "First text", {?SplitKeywords "Test1;Test2;Test3" }} , "<PRODUCT>?</PRODUCT>" }
Performance problems with media assets
If you have to export many unc paths of media assets and you use a Media Portal asset provider then you should activate the unc path cache. You can do this by adjust the plugin_customization.ini file, set the value for com.heiler.ppm.export.core/use_unc_path_cache parameter to true. Please use the MimeGetUNCPath export function only in the main module once you have activated it. Find more information about this at the "Export - UNC path cache" chapter.