0

I have an input schema that contains a list of phone numbers with a phone number type which looks as follows:

<phoneNumbers>
    <phoneNumber type="work">...</phoneNumber>
    <phoneNumber type="home">...</phoneNumber>
</phoneNumbers>

I only want to map a specific type of number, let's say 'work'. If a 'work' type phone number isn't available I need to fill in a default value.

This is what I start with:

BizTalk mapping

The problem I run into is that I can't get the default value to appear in the output if there is no 'work' phone number present.

Chrono
  • 1,433
  • 1
  • 16
  • 33

5 Answers5

3

How about using scripting functoid with this.

public string setphonenumber(string work_number)
{
  string default = "123456789";
  if(work_number ="")
      return default;
  else return work_number;

}

xyz
  • 531
  • 1
  • 10
  • 31
  • I've had a solution similar to this. I still needed a cumulative concatenate for it to fully function the way I wanted it. – Chrono Feb 10 '15 at 11:41
3

You can use an inline XSLT Scripting Functiod.

Suppose the source and destination structures look like this:

Example map

Inline XSLT would be something like this:

<workNumber xmlns:p="http://PhoneNumberMap.SourceSchema">
  <xsl:variable name="var:v1" select="/p:Root/phoneNumbers/phoneNumber[@type='work']" />
  <xsl:choose>
    <xsl:when test="$var:v1!=''">
      <xsl:value-of select="$var:v1" />
    </xsl:when>
    <xsl:otherwise>
      <xsl:value-of select="'some default'" />
    </xsl:otherwise>
  </xsl:choose>
</workNumber>
Gruff
  • 555
  • 1
  • 9
  • 14
  • I haven't been working with BizTalk for that long. Being a programmer, I should learn to not try to solve everything using Inline C# Scriptoids. :) – Chrono Feb 10 '15 at 11:40
0

If the phone# have fixed length, you can string concatenate the default value in right side then feed to a string Left.

Zee
  • 830
  • 1
  • 9
  • 22
0

I advice you to use a Not equal functoid to set your default value if it's different to "Work", and if it's equal to "work", you will have the source value in output

Hichamveo
  • 475
  • 3
  • 16
0

Try to make map entire in xlst instead of using BizTalk map functoids. In the begin you will struggle with xslt, but after some time, you will love it!

I will not post the entire solution here, but I found a nice Youtube post that explains everything. It get's interesting at 3:00.

flashbeir
  • 45
  • 5