<?xml version="1.0" encoding="utf-8"?>
<ManualTopic ID="/baanerp/da/onlinemanual/000302" xml:lang="en">
	<Header>
		<Title xmlns:HTML="http://www.w3.org/TR/REC-html40">To configure an attached condition script</Title>
		<Keyword ContextSensitive="No"><Level1>Triggering</Level1>
		</Keyword>
		<Keyword ContextSensitive="No"><Level1>i-Flow</Level1>
		</Keyword>
		<Keyword ContextSensitive="No"><Level1>Condition Script</Level1>
		</Keyword>
	</Header>
	<GeneralSection><ProcedureList><ListIntro>To create a condition 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.cont" role="formfield">Condition Template</Link> to 'Attached Script'.</ListItem>
			<ListItem>Run the <GUIRef href="" role="manual">Configure Conditions</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.cont" role="manual">Condition 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.cont" role="manual">Condition Template</GUIRef>, the existing text is used.</Paragraph>
		<Paragraph class="Default">The first time you run the <GUIRef href="" role="manual">Configure Conditions</GUIRef> command, for a trigger with <GUIRef href="/baanerp/da/trg/datrg1100m000#datrg100.cont" role="manual">Condition Template</GUIRef> = 'Attached Script', the system generates a default template with the following content:</Paragraph>
		<CodeBlock space-and-orientation="indented-estimated">
function extern long check.conditions(long i.event, ref boolean         
                                        o.condition.is.met)
| IMPORTANT: do not change the interface (function name, parameters, 
| and  return value)
{
DLLUSAGE
Desc            This function checks whether a trigger event meets the  
                specified conditions.
Input           i.event: event
Output          return value: 0 (OK) or &lt; 0 (an error value)
                o.condition.is.met: whether the event matches the       
                specified condition(s)
Precondition:   i.event contains an event that is formatted according 
                to library datrgevent and must be read using that 
                library.
ENDDLLUSAGE


        | &lt; Add implementation here &gt; |


        o.condition.is.met = true
        return(0) | OK
}

</CodeBlock>
	</GeneralSection>
	<GeneralSection><SectionTitle>TO CUSTOMIZE A GENERATED PROGRAM</SectionTitle>
		<Paragraph class="Default">Instead of writing a condition function from scratch, you can customize a generated script. This is useful if you want to create conditions that are too complicated to be defined in the <Link href="/baanerp/da/trg/datrg1110m000" role="session">Configure Trigger Conditions (datrg1110m000)</Link> session.</Paragraph>
		<List><ListIntro>Two examples where the user interface functionality of this session falls short:</ListIntro>
			<ListItem>In a condition you cannot specify that a trigger must be executed if the ordered quantity for an item increases.</ListItem>
			<ListItem>In a condition you cannot specify that a trigger must be executed if the Inventory Allocated exceeds the Inventory on Hand (because both are attributes).</ListItem>
		</List>
		<Paragraph class="Default">In these cases it is advisable to first use the <GUIRef href="/baanerp/da/trg/datrg1110m000" role="session">Configure Trigger Conditions (datrg1110m000)</GUIRef> session to define conditions that as much as possible resemble your needs. For example, if you want to specify that a trigger must be executed if a quantity increases, you can initially use the <GUIRef href="/baanerp/da/trg/datrg1110m000" role="session">Configure Trigger Conditions (datrg1110m000)</GUIRef> session to define a condition that specifies that a trigger must be executed if the quantity is changed.</Paragraph>
		<Paragraph class="Default">Assume you configured Trigger Conditions, through the <GUIRef href="/baanerp/da/trg/datrg1110m000" role="session">Configure Trigger Conditions (datrg1110m000)</GUIRef> session, 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 the code from the generated script to a new condition script:</ListIntro>
			<ListItem>Open the generated script and copy the check.conditions() 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.cont" role="manual">Condition Template</GUIRef> to 'Attached Script', and run The <GUIRef href="" role="manual">Configure Conditions</GUIRef> command. The Text Editor is started.</ListItem>
			<ListItem>Paste the copied contents from the clipboard into the standard condition 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 condition script and the condition defined in the <GUIRef href="/baanerp/da/trg/datrg1110m000" role="session">Configure Trigger Conditions (datrg1110m000)</GUIRef> session.</Paragraph>
			<Paragraph class="Default">For example, you change the <GUIRef href="/baanerp/da/trg/datrg1100m000#datrg100.cont" role="manual">Condition Template</GUIRef> to 'Configure via Dialog'. Subsequently you update the condition in the <GUIRef href="/baanerp/da/trg/datrg1110m000" role="session">Configure Trigger Conditions (datrg1110m000)</GUIRef> session, and finally you switch back to 'Attached Script' mode. The attached script is NOT updated automatically.</Paragraph>
		</Note>
	</GeneralSection>
</ManualTopic>
