Power Tools

59.4.10.2 Process settings

Set here the following parameters to define how the action will be performed.

Functions available here allow to quickly compile PowerShell scripts and SQL statements by inserting preset layouts (i.e. common scripts, ideas and configurations) into related sections.
[Insert PowerShell Snippet] - Quickly insert common scripts into the PowerShell script editor by choosing a snippet. Available common scripts are described in the Common Scripts chapter.
[Insert T-SQL snippet] - Quickly insert common statements into the SQL statement editor by choosing a snippet. Available common scripts are described in the Common Statements chapter.
[Known Test Configuration] - Select a predefined configuration to reset all parameters and set them with predefined values. Available configuration templates include:

Copy a single file to the destination
Job variables
Configuration predefined value
: None

PowerShell script
Configuration predefined value:
Write-Output "`$EtereSrcFile0          = `"$EtereSrcFile0`""
Write-Output "`$EtereDstPath0          = `"$EtereDstPath0`""
$DestFilename = ([io.fileinfo]$EtereSrcFile0).Name
Copy-Item $EtereSrcFile0 $EtereDstPath0
$Log = "Operation performed by poweshell: Copy-Item $EtereSrcFile0 to $EtereDstPath0"
Write-Output "`$DestFilename=$DestFilename"
Write-Output "`$Log=$Log"

Execution timeout
Configuration predefined value
: 0

Output filename
Configuration predefined value
: $DestFilename

Output variables
Configuration predefined value
: $DestFilename (<param type="nobinding" />)

As final step execute...
Configuration predefined value
: Enabled

SQL statement
Configuration predefined value
: Update filmati set NOTE_A = 'Copied file @DestFilename' where ID_FILMATI = @EtereAssetId

Copy SMPTE metadata into the asset field
Job variables
Configuration predefined value
: MyValue (<param type="smpte">0F.02.01.00.00.00.00.00</param>)

PowerShell script
Configuration predefined value
: Write-Output "`$MyValue          = `"$MyValue`""

Execution timeout
Configuration predefined value
: 0

Output filename
Configuration predefined value
: ---

Output variables
Configuration predefined value
: MyValue (<param type="filmati"> NOTE_A</>)

As final step execute...
Configuration predefined value
: Disabled

SQL statement
Configuration predefined value
: ---

NB: Users can freely define scripts according to their needs without using them. Insertion and configuration functions are merely intended to facilitate the creation of PowerShell scripts and SQL statements.


Editor
Job variables - The [Edit] button allows using the Rules Editor to define custom variables to be used in both the PowerShell script as $variable (e.g. $DestFilename) and the T-SQL statement as @variable (e.g. @DestFilename).
For instance, adding a variable named "MyVar" and associated to a Flexi-metadata (e.g. <param type="smpte"> 0F.FF.FF.FF.FF.FF.01.01</param>) will allow calling it from within the script ($MyVar) to directly use the related associated metadata.
Detailed information on how to create custom variables can be found in the Rules Editor chapter.

PowerShell Script - Implement here the script to be executed on PowerShell. PowerShell scripts can be implemented using standard variables (available by default) and job variables (defined by the user).
For examples of useful scripts, please refer to the Common Scripts chapter.

Execution timeout (msec) - Specify the maximum time (ms) to wait for the script to complete; if this time is exceeded, the script will be automatically terminated. Leave this to zero (0) to not use a timeout, allowing the script to complete it.

Output filename - Leave this parameter blank to add the target metafile to the asset's Media Library ("technical data" tab), specifying only the destination codec and destination device (file path and name will be empty).
Compile this parameter to add the target metafile specifying besides the destination codec and destination device also the filename set here. All previously defined Job variables (and output variables) can be used prefixed with either the $ symbol (e.g. $destFile) or the @ symbol (e.g. @destFile). For instance:
$EtereAssetId_@EtereUniqueName.MXF
NB: If the "Never update DB files" is enabled in the Basic Settings, no file will be set even if an output filename is configured.

Output variables - The [Edit] button allows selecting the variables returned by the action as results. To do this, press the [Add] button and enter an output variable specifying how to use its returned value:
Flexi-metadata - The selected Flexi-metadata (e.g. <param type="smpte">0F.16.07.00.00.00.00.00</param>) will be automatically updated with the value of entered variable (e.g. DestFilename) after the script execution.
Asset - The selected asset field (e.g. <param type="filmati">FILELQ</param>) will be automatically updated with the value of entered variable (e.g. DestFilename) after the script execution.
No binding - The entered variable (e.g. DestFilename) won't be used for updating database data. Instead, it will be only made available for use from within the T-SQL statement (@DestFilename).
NB: Output variables must be defined as Job variables or within the PowerShell script. Otherwise, they will return no value.
Variables directly defined within PowerShell scripts must be added here to be available for the T-SQL statement and Output filename.
As the final step, execute the following T-SQL statement - Optionally, implement a SQL query to be executed after the PowerShell script. Here all job variables (and output variables) can be used with the @ symbol (e.g. @destFile); notice that the $ prefix is not supported here.
For instance, the T-SQL statement can be used to update the asset according to the script results:

sample #1
--Write the filename into an asset field (note_a)
update filmati set note_a = 'Copied file @destFilename' where ID_FILMATI = @EtereAssetId

sample #2
--Set Flexi-metadata to "yes" or "no" depending on whether assets have files or not
declare @a bit =0
SET @a = (select count(*) from FS_XFILEFILM where id_filmati=@EtereAssetID)
IF @a >= 1
BEGIN
  exec [dbo].[smpte_SetValue] @EtereAssetId, '0F.05.00.00.00.00.00.00', 'Yes'
END
ELSE --IF @a < 1
BEGIN
  exec [dbo].[smpte_SetValue] @EtereAssetId, '0F.05.00.00.00.00.00.00', 'No'
END

sample #3
--Set MD5 filehash into flexi-metadata depending on current metafile
declare @idi int = (select id_instance from wf_job where id_job = @EtereJobId)
declare @mfid int = [dbo].[wf_api_getInstanceMetafile] (@idi)
declare @md5 varchar(32)
select @md5 = FILE_HASH from fs_file ff
join FS_DIRECTORY d with(nolock)on d.ID_METAFILE =ff.id_metafile
where HASH_TYPE ='md5' and d.ID_METAFILE = @mfid
exec [dbo].[smpte_SetValue] @EtereAssetId, '0F.05.00.00.00.00.00.00', @md5


Action outputs
Depending on the success of the operation, the action will return one of the following results:
IDLE - The action execution was not yet started.       (this output is exclusive for internal use, it must not be used in any way)
RUNNING - The action execution is already in progress.    (this output is exclusive for internal use, it must not be used in any way)
DONE - The action execution was completed.
ERROR - The action execution failed. Common causes may be:
▪ The file wasn't found ("The path is not of a legal form")
▪ The configuration is invalid ("Access violation at address")
▪ A custom exception was thrown (See Errors handling)
ABORTED - The action execution was cancelled (e.g. due to a T-workflow abortion).