[SOLVED] Generic Interface - Mapping for incoming request data of a dynamic field

Moderator: crythias

Post Reply
Giulio Soleni
Znuny wizard
Posts: 392
Joined: 30 Dec 2010, 14:35
Znuny Version: 6.0.x and 5.0.x
Real Name: Giulio Soleni
Company: IKS srl

[SOLVED] Generic Interface - Mapping for incoming request data of a dynamic field

Post by Giulio Soleni »

Hello,
I have a dropdown dynamic field named AskConfirmation configured with a list of possible key-value pairs
key 00 value Yes
key 01 value No
key 02 value Postponed
key 03 value Delayed

A third-party tool uses the GenericInterface of OTRS as a Provider and calls the TicketCreate method to create a ticket providing the selection for that dyn field, along with the other required info.
So far (OTRS 3.3 is used) the TicketCreate operation is performed using a call like the following example:

Code: Select all

<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
      <env:Header/>
      <env:Body>
         <TicketCreate>
            <UserLogin>myUser</UserLogin>
            <Password>myPass</Password>
                  <Ticket>
                     <Title>test</Title>
                     <CustomerUser>myCustomer</CustomerUser>
                     <Queue>myQueue</Queue>
                     <StateID>12</StateID>
                     <ServiceID>42</ServiceID>
                     <Priority>3 normal</Priority>
                     <Responsible>myResponsible</Responsible>
                  </Ticket>
                  <Article>
                     <Subject>test</Subject>
                     <Body>this is a test</Body>
                     <ContentType>text/plain; charset=utf8</ContentType>
                     <SenderTypeID>3</SenderTypeID>
                  </Article>
                  <DynamicField>
                     <Name>AskConfirmation</Name>
                     <Value>Yes</Value>
                  </DynamicField>
         </TicketCreate>
      </env:Body>
</env:Envelope>
And it works, but I remark that dynamic field value (e.g. Yes) is actually directly passed instead of the key (e.g. 00) for that value.

Updating OTRS to the last available version (at the present moment 6.0.19) the same operation would keep working only if I change the way I set the dynamicField:

Code: Select all

...
                  <DynamicField>
                     <Name>AskConfirmation</Name>
                     <Value>00</Value>
                  </DynamicField>
...
But unfortunately I presently do not have a way to touch the code on the third-party, and I cannot modify the xml SOAP call.
Therefore I thought I might use a map to adjust the received value of for that dyn field when the call is received by OTRS.

I tried the following using Mapping Simple:
map.png
However the call keeps failing... :(

Do you have please a hint on how should I manage the mapping of a dynamic field like that, to adapt the incoming call to what OTRS expects?

Thank you very much in advance
Giulio

EDIT:

I solved using the XSLT mapping with the following filter:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<xsl:transform version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:date="http://exslt.org/dates-and-times"
    extension-element-prefixes="date">
    <xsl:output method="xml" encoding="utf-8" indent="yes"/>
	<!-- Copy the original content -->
    <xsl:template match="node()|@*">
        <xsl:copy>
            <xsl:apply-templates  select="node()|@*"/>
        </xsl:copy>
    </xsl:template>
	<!-- Replace the DynamicField Value of AskConfirmation -->
    <xsl:template match="DynamicField[Name='AskConfirmation']">
        <DynamicField>
                <Name><xsl:value-of select="Name"/></Name>
                <Value><xsl:choose>
                    <xsl:when test="Value = 'Yes'">00</xsl:when>
                    <xsl:when test="Value = 'No'">01</xsl:when>
                    <xsl:when test="Value = 'Postponed'">02</xsl:when>
                    <xsl:when test="Value = 'Delayed'">03</xsl:when>
                    <xsl:otherwise></xsl:otherwise>
                </xsl:choose></Value>
        </DynamicField>
    </xsl:template>
</xsl:transform>
You do not have the required permissions to view the files attached to this post.
OTRS 6.0.x on CentOS 7.x with MariaDB 10.2.x database connected to an Active Directory for Agents and Customers.
ITSM and FAQ modules installed.
Post Reply