Example: FindKeys Action [AX 2012]

Updated: June 21, 2012

Applies To: Microsoft Dynamics AX 2012 R2, Microsoft Dynamics AX 2012 Feature Pack, Microsoft Dynamics AX 2012

This topic describes sample inbound and outbound messages for the findkeys action in Application Integration Framework (AIF) document services. You can use the findkeys action to obtain the values of the key fields for all records that match your query criteria.

The outbound message contains <EntityKey> tags for the found records.

The following inbound FindKeys message specifies one <CriteriaElement> tag. The Range operator is used. Range selects all records that have a value between <Value1> and <Value2> (including those two values).

There are no XML tags that are specific to this inbound message. However, the value for <DataSourceName> is specific to this message, and it must be compatible with the service that is listed in the <Action> tag. Line breaks have been added for readability.

<?xml version="1.0" encoding="utf-8"?>
<Envelope xmlns = "http://schemas.microsoft.com/
  dynamics/2011/01/documents/Message">

 <Header>
  <MessageId>{B4BD0E9F-0312-0630-0002-47B753E77C2D}</MessageId>
  <Action>http://schemas.microsoft.com/dynamics/
    2008/01/services/CustomerService/findkeys</Action>
 </Header>

 <Body>
  <MessageParts xmlns = "http://schemas.microsoft.com/
    dynamics/2008/01/documents/Message">
   <QueryCriteria xmlns = "http://schemas.microsoft.com/
     dynamics/2006/02/documents/QueryCriteria">

    <CriteriaElement>
     <DataSourceName>CustTable</DataSourceName>
     <FieldName>Street</FieldName>
     <Operator>Range</Operator>
     <Value1>1</Value1>
     <Value2>5</Value2>
    </CriteriaElement>

   </QueryCriteria>
  </MessageParts>
 </Body>

</Envelope>

The outbound message contains <EntityKey> tags for the found records.

The following outbound message is generated from the previous inbound message.

<?xml version="1.0" encoding="utf-8"?>
<Envelope xmlns = "http://schemas.microsoft.com/dynamics/2011/01/documents/Message">
 <Header>
  <MessageId>{5116528D-C4E1-4483-81A5-7C2976E4E935}</MessageId>
  <Action>http://schemas.microsoft.com/dynamics/2008/01/services/CustomerService/findkeys</Action>
  <RequestMessageId>{B4BD0E9F-0312-0630-0002-47B753E77C2D}</RequestMessageId>
 </Header>
 <Body>
  <MessageParts xmlns = "http://schemas.microsoft.com/dynamics/2008/01/documents/Message">
   <EntityKeyList xmlns = "http://schemas.microsoft.com/dynamics/2006/02/documents/EntityKeyList">
    <EntityKey xmlns = "http://schemas.microsoft.com/dynamics/2006/02/documents/EntityKey">
     <KeyData>
      <KeyField>
       <Field>AccountNum</Field>
       <Value>4012</Value>
      </KeyField>
     </KeyData>
    </EntityKey>
    <EntityKey xmlns = "http://schemas.microsoft.com/dynamics/2006/02/documents/EntityKey">
     <KeyData>
      <KeyField>
       <Field>AccountNum</Field>
       <Value>4014</Value>
      </KeyField>
     </KeyData>
    </EntityKey>
    <EntityKey xmlns = "http://schemas.microsoft.com/dynamics/2006/02/documents/EntityKey">
     <KeyData>
      <KeyField>
       <Field>AccountNum</Field>
       <Value>4500</Value>
      </KeyField>
     </KeyData>
    </EntityKey>
    <EntityKey xmlns = "http://schemas.microsoft.com/dynamics/2006/02/documents/EntityKey">
     <KeyData>
      <KeyField>
       <Field>AccountNum</Field>
       <Value>4501</Value>
      </KeyField>
     </KeyData>
    </EntityKey>
    <EntityKey xmlns = "http://schemas.microsoft.com/dynamics/2006/02/documents/EntityKey">
     <KeyData>
      <KeyField>
       <Field>AccountNum</Field>
       <Value>4505</Value>
      </KeyField>
     </KeyData>
    </EntityKey>
    <EntityKey xmlns = "http://schemas.microsoft.com/dynamics/2006/02/documents/EntityKey">
     <KeyData>
      <KeyField>
       <Field>AccountNum</Field>
       <Value>4506</Value>
      </KeyField>
     </KeyData>
    </EntityKey>
   </EntityKeyList>
  </MessageParts>
 </Body>
</Envelope>

Community Additions

ADD
Show: