IKScannerDevicePanel.SetTrigger
-------------------------------

Sets the trigger to notify when new picture arrives.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [ImageCapture](component_ImageCapture.md) | [6.5](newinversion65.md) | ✅ Yes | ❌ No | ❌ No | ❌ No | ❌ No |

MBS( "IKScannerDevicePanel.SetTrigger"; FileName; ScriptName ) 

**MBS**( **"IKScannerDevicePanel.SetTrigger";** /\* Sets the trigger to notify when new picture arrives. \*/  
**$FileName**; /\* The name of the FileMaker File that contains the script.e.g. "test.fmp12" \*/   
**$ScriptName**) /\* The name of the script to run.e.g. "MyScript" \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| FileName | The name of the FileMaker File that contains the script. | "test.fmp12" |
| ScriptName | The name of the script to run. | "MyScript" |

### Result

Returns OK or error.

### Description

Sets the trigger to notify when new picture arrives.  
You get a call for each picture as user may import several.  
The parameter to your script is the native file path to the image file.   
If scan is to PDF and we use document feeder, be aware that you may get a trigger with same file path again if a new page is added.  
  
Either you use the trigger and process each image there or you can call later [IKScannerDevicePanel.ImageCount](IKScannerDevicePanelImageCount.md) and [IKScannerDevicePanel.NextImage](IKScannerDevicePanelNextImage.md) to get the images.  
  
This function requires a native path. Use [Path.FileMakerPathToNativePath](PathFileMakerPathToNativePath.md) to convert a FileMaker path to a native path if required. If you like to have the user choose the path, you can use [FileDialog](component_FileDialog.md) functions.  
### Examples

Set trigger script:

 Set Variable \[$r ; Value:MBS ( "IKScannerDevicePanel.SetTrigger"; Get(FileName); "Scanner Dialog Trigger" )\]  
Import image in triggered script:

 Set Variable \[$Path ; Value:Get(ScriptParameter)\]  
Set Variable \[$Image ; Value:MBS ("[Container.ReadFile](ContainerReadFile.md)"; $path )\]  
If \[MBS ("ISError") = 0\]  
 New Record/Request  
 Set Field \[ImageCapture Dialogs::Image ; $Image \]  
 Commit Records/Requests \[No dialog\]  
End If  
Clear trigger script:

 Set Variable \[$r ; Value:MBS ( "IKScannerDevicePanel.SetTrigger"; ""; "" )\]  
### See also

- [Container.ReadFile](ContainerReadFile.md)
- [IKScannerDevicePanel.GetHeight](IKScannerDevicePanelGetHeight.md)
- [IKScannerDevicePanel.GetWidth](IKScannerDevicePanelGetWidth.md)
- [IKScannerDevicePanel.ImageCount](IKScannerDevicePanelImageCount.md)
- [IKScannerDevicePanel.NextImage](IKScannerDevicePanelNextImage.md)
- [IKScannerDevicePanel.SetCloseTrigger](IKScannerDevicePanelSetCloseTrigger.md)
- [IKScannerDevicePanel.SetCombine](IKScannerDevicePanelSetCombine.md)
- [IKScannerDevicePanel.SetWidth](IKScannerDevicePanelSetWidth.md)
- [IKScannerDevicePanel.Show](IKScannerDevicePanelShow.md)
- [IKScannerDevicePanel.Visible](IKScannerDevicePanelVisible.md)

### Example Databases

- [Mac only/ImageCapture/ImageCapture Dialogs](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Mac%20only/ImageCapture/ImageCapture%20Dialogs.shtml#2ScriptAnchor_)

This function is free to use.

Created 7th November 2016 , last changed 22nd December 2019

  
[IKScannerDevicePanel.SetScannerDeviceName](IKScannerDevicePanelSetScannerDeviceName.md) - [IKScannerDevicePanel.SetWidth](IKScannerDevicePanelSetWidth.md)

[HTML Version](IKScannerDevicePanelSetTrigger.shtml)