The purpose of this Action example is to illustrate how to use the logic from an Action on a user-selected range of Items (in this case Products) by invoking the Action from the Report menu.
This example is provided as inspiration only. It must be adapted to your Perfion environment to work. Perfion Support does not assist with such adaptations. Please contact your Perfion Partner or your Perfion consultant if you need assistance.
The concept needs both a Report (view.xml file) and the Action to call.
In the superquery the reference to the ID of the Action needs to be written in the <SuperQuery> node. In this case the actionID is "2942", but this must be changed to the ID from your Action.
The <OutputParameters> section is optional, but it illustrates the way to make interaction between the User and the Action. The parameter "ExportPath" is set in the Report dialogue and is available as a variable in the Action.
Report SuperQuery
<SuperQuery actionID='2942' > |
|---|
Action Map
- All lines containing a Command are created as virtuals. This is a recommended best practice
Sample data for building Action Map
Data must be adapted to your Perfion environment to work
| Action Map - From | To | Command | Script | Note |
| Row | tblFixed | SELECT | The input DataTable from the Report must be called "Row" | |
| i__ID | ID | |||
| i__Name | CleanItemNumber | string inputString = Trim( Value ); string cleanString = System.Text.RegularExpressions.Regex.Replace(inputString, @"[^a-zA-Z0-9\-]", ""); Value = cleanString; | This C# script removes any illegal characters from the Name. | |
| i_Image | Image | |||
| tblFixed | tblFiles | SELECT | ||
| ID | ID | |||
| {CleanItemNumber}-{ID}-productimage | Filename | Note the curly bracket syntax in the From column. This notification form combines different variables and makes one value | ||
| Image | Image | |||
| tblFiles | SELECT | |||
| ID | ||||
| Filename | FileName | |||
| Image | Image | if( !HasValue ) return; string ExportPath = ""; var lookupParam = Sources.SelectFirst( "Parameters", "" ); string id = Path.GetFileNameWithoutExtension( ""+Value ); var info = Perfion.WriteFile( Value = info.OutFileName; | This C# script writes the Product Images to physical files.
The script also writes the images from the feature called "Image" from the selected products. It uses the Perfion script method "WriteFile" with customized parameters. Please refer to the documentation for details on using this method.
The written filename are set to the output Value for reference if needed later even though the value is not actually used in this example. |
Comments
0 comments
Please sign in to leave a comment.