<?xml version="1.0" encoding="utf-8"?>
<ManualTopic ID="/baanerp/tg/onlinemanual/000007" xml:lang="en">
   <Header>
      <Title>Initialize workflow</Title>
   </Header>
   <GeneralSection>
      <Paragraph>You can use a <Link href="/baanerp/tg/glossary/glossary#000087" role="glossary">query</Link> to set the value of a
		workflow attribute.</Paragraph>
      <Paragraph>A query is used if the
		value cannot directly be retrieved from an ERP table field.</Paragraph>
      <List>
         <ListIntro>For example you can:</ListIntro>
         <ListItem>You can calculate the total amount of an order</ListItem>
         <ListItem>You can retrieve information from another table based on the
		  value in an ERP table field.</ListItem>
      </List>
      <List>
         <ListItem> 
            <Link href="#A" role="internal">General</Link>
         </ListItem>
         <ListItem> 
            <Link href="#B" role="internal">To create a query</Link>
         </ListItem>
         <ListItem> 
            <Link href="#C" role="internal">Where you can use a query</Link>
         </ListItem>
      </List>
      <GeneralSection ID="A">
         <SectionTitle>General</SectionTitle>
         <Paragraph>The query can
		  retrieve:</Paragraph>
         <List>
            <ListItem>A specific value of an ERP table field (ENtgwms.sqlf.value)</ListItem>
            <ListItem>The lowest value of an ERP table field (ENtgwms.sqlf.minimum)</ListItem>
            <ListItem>The highest value of an ERP table field
			 (ENtgwms.sqlf.maximum)</ListItem>
            <ListItem>The sum of an ERP table field (ENtgwms.sqlf.sum)</ListItem>
            <ListItem>The average of an ERP table (ENtgwms.sqlf.average)</ListItem>
            <ListItem>The number of occurrences of an ERP table field
			 (ENtgwms.sqlf.count)</ListItem>
         </List>
         <Note>
            <SectionTitle>Note</SectionTitle>
            <Paragraph>The text in
			 parenthesis is the Query Function you must use to accomplish the task
			 mentioned.</Paragraph>
            <Paragraph>Based on the query
			 field conditions, the range of records is determined that the query will work
			 upon.</Paragraph>
         </Note>
      </GeneralSection>
      <GeneralSection ID="B">
         <SectionTitle>To create a query</SectionTitle>
         <Paragraph>To create a new query,
		  you need to start the Queries (tgwms1560m000) session.</Paragraph>
         <List>
            <ListItem>Click New.</ListItem>
         </List>
         <Paragraph>Specify a query name
		  and give a short description of its function.</Paragraph>
         <Paragraph>Double-click this
		  query and specify the Query Function and the ERP table field name whose value
		  will be used to fill the workflow attribute at run time.</Paragraph>
         <Paragraph>Next, specify the
		  query conditions by selecting the Query Field Conditions command on the <Link href="/baanerp/tc/glossary/glossary#specific" role="glossary">appropriate</Link> menu. The total
		  condition (WHERE clause) can consist of individual conditions and are connected
		  by a logical AND.</Paragraph>
         <Paragraph>Choose the Check Query
		  Syntax command on the <Link href="/baanerp/tc/glossary/glossary#specific" role="glossary">appropriate</Link> menu to check the syntax of the
		  query. A dialog box shows the error messages.</Paragraph>
         <Paragraph>Choose the Evaluate
		  Query command on the <Link href="/baanerp/tc/glossary/glossary#specific" role="glossary">appropriate</Link> menu to test the query (which only
		  works if the Query Syntax is correct). As a result, the query is displayed in a
		  SELECT, FROM, and WHERE format, together with the outcome of the evaluation.</Paragraph>
         <Paragraph>If the evaluation is
		  ok you can use the query to set a workflow attribute's value.</Paragraph>
      </GeneralSection>
      <GeneralSection ID="C">
         <SectionTitle>Where you can use a query</SectionTitle>
         <Paragraph>A query can be linked
		  to a workflow attribute (binding).</Paragraph>
         <Paragraph>To bind a query to a
		  workflow attribute:</Paragraph>
         <List>
            <ListItem>Start the <Link href="/baanerp/tg/brg/tgbrg5500m000" role="session">Business Processes (tgbrg5500m000)</Link> session,
			 select a business process, and start the <Link href="/baanerp/tg/glossary/glossary#000307" role="glossary">Enterprise Modeler Editor</Link>.</ListItem>
            <ListItem>Right-click an <Link href="/baanerp/tg/glossary/glossary#000023" role="glossary">activity</Link> and select Insert
			 from the short cut menu and then select Attribute Bindings.</ListItem>
            <ListItem>Use the Attribute Bindings session to insert new bindings to <Link href="/baanerp/tg/glossary/glossary#000010" role="glossary">workflow attributes</Link> you have
			 defined for the current business process.</ListItem>
         </List>
      </GeneralSection>
   </GeneralSection>
</ManualTopic>