<?xml version="1.0" encoding="utf-8"?>
<ManualTopic ID="/baanerp/da/onlinemanual/000303" xml:lang="en">
	<Header>
		<Title xmlns:HTML="http://www.w3.org/TR/REC-html40">To configure an attached action script</Title>
		<Keyword ContextSensitive="No"><Level1>Triggering</Level1>
		</Keyword>
		<Keyword ContextSensitive="No"><Level1>i-Flow</Level1>
		</Keyword>
		<Keyword ContextSensitive="No"><Level1>Action Script</Level1>
		</Keyword>
	</Header>
	<GeneralSection><ProcedureList><ListIntro>To create an action script for a trigger:</ListIntro>
			<ListItem>Start the <Link href="/baanerp/da/trg/datrg1100m000" role="session">Triggers (datrg1100m000)</Link> session and change the trigger's <Link href="/baanerp/da/trg/datrg1100m000#datrg100.actt" role="formfield">Action Template</Link> to 'Attached Script'.</ListItem>
			<ListItem>Run the <GUIRef href="" role="manual">Configure Action</GUIRef> command. The text editor is started.</ListItem>
			<ListItem>Enter the required Baan C code.</ListItem>
		</ProcedureList>
		<Paragraph class="Default">When you leave the text editor and return to the <GUIRef href="/baanerp/da/trg/datrg1100m000" role="session">Triggers (datrg1100m000)</GUIRef> session, the trigger program is regenerated automatically, if the text was changed.</Paragraph>
		<Paragraph class="Default">When you change the <GUIRef href="/baanerp/da/trg/datrg1100m000#datrg100.actt" role="manual">Action Template</GUIRef> from 'Attached Script' to another setting, the text content is not deleted. So when you switch back to the 'Attached Script'<GUIRef href="/baanerp/da/trg/datrg1100m000#datrg100.actt" role="manual">Action Template</GUIRef>, the existing text is used.</Paragraph>
		<Paragraph class="Default">The first time you run the <GUIRef href="" role="manual">Configure Action</GUIRef> command, for a trigger with <GUIRef href="/baanerp/da/trg/datrg1100m000#datrg100.actt" role="manual">Action Template</GUIRef> = 'Attached Script', the system generates a default template with the following content:</Paragraph>
		<CodeBlock space-and-orientation="indented-estimated">function extern long process.event(ref long io.event)
| IMPORTANT: do not change the interface (function name, parameter, 
| and return value)
{
DLLUSAGE
Desc            This function processes a trigger event.
Input           io.event: event
Output          return value: 0 (OK) or &lt; 0 (an error value)
                io.event: the event may (but need not) be updated 
                within this function
Precondition:   io.event contains an event that is formatted according 
                to library datrgevent and must be read using that       
                library.
ENDDLLUSAGE


        | &lt; Add implementation here &gt; |


        return(0) | OK
}


</CodeBlock>
	</GeneralSection>
	<GeneralSection><SectionTitle>TO CUSTOMIZE A GENERATED PROGRAM</SectionTitle>
		<Paragraph class="Default">Instead of writing an action function from scratch, you can customize a generated script. This is useful if you want to define actions that are not supported by the <GUIRef href="/baanerp/da/trg/datrg1100m000" role="session">Triggers (datrg1100m000)</GUIRef> session.</Paragraph>
		<List><ListIntro>Currently this session supports the following standard action templates:</ListIntro>
			<ListItem>Attached Script</ListItem>
			<ListItem>Fan Out</ListItem>
			<ListItem>Create XML File</ListItem>
		</List>
		<Paragraph class="Default">You can use a customized program if you want to take another type of action, such as invoking a ERP LN program, an operating system script or a Java method.</Paragraph>
		<Paragraph class="Default">Assume you configured an XML File Action for a trigger. In that case a generated program is available in the <Link href="/baanerp/da/trg/datrg1100m000#datrg100.path" role="formfield">Path for Program</Link> that is specified for the trigger; the file name is &lt;path&gt;/&lt;trigger&gt;.src.</Paragraph>
		<ProcedureList><ListIntro>Take the following steps to copy code from the generated script to a new action script:</ListIntro>
			<ListItem>Open the generated script and copy the process.event() function from that source to the Windows clipboard.</ListItem>
			<ListItem>Start the <GUIRef href="/baanerp/da/trg/datrg1100m000" role="session">Triggers (datrg1100m000)</GUIRef> session, change the trigger's <GUIRef href="/baanerp/da/trg/datrg1100m000#datrg100.actt" role="manual">Action Template</GUIRef> to 'Attached Script', and run The <GUIRef href="" role="manual">Configure Action</GUIRef> command. The Text Editor is started.</ListItem>
			<ListItem>Paste the copied contents from the clipboard into the standard action template that is displayed in the Text Editor.</ListItem>
			<ListItem>Adapt the script until it meets your requirements.</ListItem>
		</ProcedureList>
		<Note><SectionTitle>
                                 Note
                              </SectionTitle>
			<Paragraph class="Default">The system does not perform an automatic merge of the attached action script and a configured 'Fan Out' or 'Create XML File' action.</Paragraph>
			<Paragraph class="Default">For example, you change the <GUIRef href="/baanerp/da/trg/datrg1100m000#datrg100.actt" role="manual">Action Template</GUIRef> to 'Create XML File'. Subsequently you update the action in the <Link href="/baanerp/da/trg/datrg1225m000" role="session">Configure XML File Action (datrg1225m000)</Link> session, and finally you switch back to 'Attached Script' mode. The attached script is NOT updated automatically.</Paragraph>
		</Note>
	</GeneralSection>
</ManualTopic>
