//Script for UPDM 2019 Data Models
//Script to decode and populate the MANUFACTUREMODEL value from the BARCODE value

var barcode = $feature.BARCODE;
if (barcode == null)   // Preserve original MANUFACTURECOMPONENT value if BARCODE is null
  return $feature.MANUFACTURECOMPONENT;
  
var componentRaw = mid(barcode,10,2);

//values from domain:  UDPM_ASTMPipeType
if (text(componentRaw) == '10') return 'Other Pipe';
if (text(componentRaw) == '11') return 'Straight Pipe';
if (text(componentRaw) == '12') return 'Coiled Pipe';
if (text(componentRaw) == '13') return 'Casing Pipe';
if (text(componentRaw) == '1A') return 'Seamless Line Pipe API 5L PSL1 Single Coat';
if (text(componentRaw) == '1B') return 'Seamless Line Pipe API 5L PSL1 Dual Coat';
if (text(componentRaw) == '1C') return 'Seamless Line Pipe API 5L PSL2 Single Coat';
if (text(componentRaw) == '1D') return 'Seamless Line Pipe API 5L PSL2 Dual Coat';
if (text(componentRaw) == '1E') return 'Electric Resistance Weld Pipe API 5L PSL1 Single Coat';
if (text(componentRaw) == '1F') return 'Electric Resistance Weld Pipe API 5L PSL1 Dual Coat';
if (text(componentRaw) == '1G') return 'Electric Resistance Weld Pipe API 5L PSL2 Single Coat';
if (text(componentRaw) == '1H') return 'Electric Resistance Weld Pipe API 5L PSL2 Dual Coat';
if (text(componentRaw) == '1J') return 'Seamless and Welded Pipe ASTM A53/A53M';
if (text(componentRaw) == '1K') return 'Seamless Carbon Steel Pipe A106/A106M';
if (text(componentRaw) == '20') return 'Other Coupling';
if (text(componentRaw) == '21') return 'Socket Fusion Coupling';
if (text(componentRaw) == '22') return 'Socket Fusion Coupling with EFV';
if (text(componentRaw) == '23') return 'Electrofusion Coupling';
if (text(componentRaw) == '24') return 'Electrofusion Coupling with EFV';
if (text(componentRaw) == '25') return 'Mechanical compression coupling or nut follower';
if (text(componentRaw) == '26') return 'Mechanical compression coupling or nut follower with EFV';
if (text(componentRaw) == '27') return 'Mechanical stab coupling';
if (text(componentRaw) == '28') return 'Mechanical stab coupling with EFV';
if (text(componentRaw) == '29') return 'Mechanical interference fit coupling';
if (text(componentRaw) == '2A') return 'Mechanical interference fit coupling with EFV';
if (text(componentRaw) == '2B') return 'Welded Coupling';
if (text(componentRaw) == '2C') return 'Threaded Coupling';
if (text(componentRaw) == '2D') return 'Flanged Coupling';
if (text(componentRaw) == '30') return 'Other Adapter Coupling';
if (text(componentRaw) == '31') return 'Compression Adapter Coupling by mape pipe thread';
if (text(componentRaw) == '32') return 'Compression Adapter Coupling by female pipe thread';
if (text(componentRaw) == '33') return 'Compression Adapter Coupling by butt fusion';
if (text(componentRaw) == '34') return 'Compression Adapter Coupling by butt welded';
if (text(componentRaw) == '35') return 'Compression Adapter Coupling by solvent welded';
if (text(componentRaw) == '36') return 'Stab Adapter Coupling by male pipe thread';
if (text(componentRaw) == '37') return 'Stab Adapter Coupling by female pipe thread';
if (text(componentRaw) == '38') return 'Stab Adapter Coupling by Solvent welded';
if (text(componentRaw) == '39') return 'Compression Adapter Coupling by stab';
if (text(componentRaw) == '40') return 'Other End Cap';
if (text(componentRaw) == '41') return 'Butt fusion End Cap';
if (text(componentRaw) == '42') return 'Socket fusion End Cap';
if (text(componentRaw) == '43') return 'Electrofusion End Cap';
if (text(componentRaw) == '44') return 'Mechanical compression or nut follower End Cap';
if (text(componentRaw) == '45') return 'Mechanical stab End Cap';
if (text(componentRaw) == '46') return 'Mechanical interference fit End Cap';
if (text(componentRaw) == '47') return 'Welded End Cap';
if (text(componentRaw) == '48') return 'Threaded End Cap';
if (text(componentRaw) == '49') return 'Fabricated End Cap';
if (text(componentRaw) == '50') return 'Other Elbow';
if (text(componentRaw) == '51') return 'Butt fusion 90 Elbow';
if (text(componentRaw) == '52') return 'Socket fusion 90 Elbow';
if (text(componentRaw) == '53') return 'Electrofusion 90 Elbow';
if (text(componentRaw) == '54') return 'Mechanical compression or nut follower 90 Elbow';
if (text(componentRaw) == '55') return 'Mechanical stab 90 Elbow';
if (text(componentRaw) == '56') return 'Mecanical interference fit 90 Elbow';
if (text(componentRaw) == '57') return 'Welded 90 Elbow';
if (text(componentRaw) == '58') return 'Threaded 90 Elbow';
if (text(componentRaw) == '59') return 'Fabricated 90 Elbow';
if (text(componentRaw) == '5A') return 'Butt fusion 45 Elbow';
if (text(componentRaw) == '5B') return 'Socket fusion 45 Elbow';
if (text(componentRaw) == '5C') return 'Electrofusion 45 Elbow';
if (text(componentRaw) == '5D') return 'Mechanical compression or nut follower 45 Elbow';
if (text(componentRaw) == '5E') return 'Mechanical stab 45 Elbow';
if (text(componentRaw) == '5F') return 'Mechanical interference fit 45 Elbow';
if (text(componentRaw) == '5G') return 'Welded 45 Elbow';
if (text(componentRaw) == '5H') return 'Threaded 45 Elbow';
if (text(componentRaw) == '5J') return 'Fabricated 45 Elbow';
if (text(componentRaw) == '60') return 'Other 3-Way Tee';
if (text(componentRaw) == '61') return 'Butt fusion 3-Way Tee';
if (text(componentRaw) == '62') return 'Socket fusion 3-Way Tee';
if (text(componentRaw) == '63') return 'Electrofusion 3-Way Tee';
if (text(componentRaw) == '64') return 'Mechanical compression or nut follower 3-Way Tee';
if (text(componentRaw) == '65') return 'Mechanical stab 3-Way Tee';
if (text(componentRaw) == '66') return 'Mechanical interference fit 3-Way Tee';
if (text(componentRaw) == '67') return 'Welded 3-Way Tee';
if (text(componentRaw) == '68') return 'Threaded 3-Way Tee';
if (text(componentRaw) == '69') return 'Fabricated 3-Way Tee';
if (text(componentRaw) == '70') return 'Other Reducer';
if (text(componentRaw) == '71') return 'Butt fusion Reducer';
if (text(componentRaw) == '72') return 'Socket fusion Reducer';
if (text(componentRaw) == '73') return 'Electrofusion Reducer';
if (text(componentRaw) == '74') return 'Mechanical compression or nut follower Reducer';
if (text(componentRaw) == '75') return 'Mechanical stab Reducer';
if (text(componentRaw) == '76') return 'Mechanical interference fit Reducer';
if (text(componentRaw) == '77') return 'Welded Reducer';
if (text(componentRaw) == '78') return 'Threaded Reducer';
if (text(componentRaw) == '79') return 'Fabricated Reducer';
if (text(componentRaw) == '80') return 'Other Tapping Tee';
if (text(componentRaw) == '81') return 'Saddle heat fusion by butt fusion outlet tapping tee';
if (text(componentRaw) == '82') return 'Saddle heat fusion by butt fusion outlet with EFV tapping tee';
if (text(componentRaw) == '83') return 'Saddle heat fusion by socket outlet tapping tee';
if (text(componentRaw) == '84') return 'Saddle heat fusion by socket outlet with EFV tapping tee';
if (text(componentRaw) == '85') return 'Saddle heat fusion by mechanical compression outlet tapping tee';
if (text(componentRaw) == '86') return 'Saddle heat fusion by mechanical compression outlet with EFV tapping tee';
if (text(componentRaw) == '87') return 'Saddle heat fusion by stab outlet tapping tee';
if (text(componentRaw) == '88') return 'Saddle heat fusion by stab outlet with EFV tapping tee';
if (text(componentRaw) == '89') return 'Electrofusion by butt fusion outlet tapping tee';
if (text(componentRaw) == '8A') return 'Electrofusion by butt fusion outlet with EFV tapping tee';
if (text(componentRaw) == '8B') return 'Electrofusion by socket outlet tapping tee';
if (text(componentRaw) == '8C') return 'Electrofusion by socket outlet with EFV tapping tee';
if (text(componentRaw) == '8D') return 'Electrofusion by mechanical compression outlet tapping tee';
if (text(componentRaw) == '8E') return 'Electrofusion by mechanical compression outlet with EFV tapping tee';
if (text(componentRaw) == '8F') return 'Electrofusion by stab outlet tapping tee';
if (text(componentRaw) == '8G') return 'Electrofusion by stab outlet with EFV tapping tee';
if (text(componentRaw) == '8H') return 'Mechanical by butt fusion outlet tapping tee';
if (text(componentRaw) == '8J') return 'Mechanical by butt fusion outlet with EFV tapping tee';
if (text(componentRaw) == '8K') return 'Mechanical by socket outlet tapping tee';
if (text(componentRaw) == '8L') return 'Mechanical by butt fusion outlet with EFV tapping tee';
if (text(componentRaw) == '8M') return 'Mechanical by mechanical compression outlet tapping tee';
if (text(componentRaw) == '8N') return 'Mechanical by mechanical compression outlet with EFV tapping tee';
if (text(componentRaw) == '8P') return 'Mechanical by stab outlet tapping tee';
if (text(componentRaw) == '8Q') return 'Mechanical by stab outlet with EFV tapping tee';
if (text(componentRaw) == '8R') return 'Mechanical by mechanical interference fit tapping tee';
if (text(componentRaw) == '8S') return 'Mechanical by mechanical interference fit with EFV tapping tee';
if (text(componentRaw) == '90') return 'Other High Volume Tapping Tee';
if (text(componentRaw) == '91') return 'Electrofusion by butt fusion High Volume Tapping Tee';
if (text(componentRaw) == '92') return 'Saddle heat fusion by butt fusion High Volume Tapping Tee';
if (text(componentRaw) == '93') return 'Mechanical by compression outlet High Volume Tapping Tee';
if (text(componentRaw) == '94') return 'Electrofusion by socket outlet High Volume Tapping Tee';
if (text(componentRaw) == '95') return 'Saddle heat fusion by socket outlet High Volume Tapping Tee';
if (text(componentRaw) == '96') return 'Mechanical by stab outlet High Volume Tapping Tee';
if (text(componentRaw) == '97') return 'Mechanical by mechanical interference fit High Volume Tapping Tee';
if (text(componentRaw) == 'A0') return 'Other Anode';
if (text(componentRaw) == 'A1') return 'Cast Iron Anode';
if (text(componentRaw) == 'A2') return 'Graphite Anode';
if (text(componentRaw) == 'A3') return 'Magnesium Anode';
if (text(componentRaw) == 'A4') return 'Zinc Anode';
if (text(componentRaw) == 'B0') return 'Other Branch Saddle';
if (text(componentRaw) == 'B1') return 'Electrofusion Branch Saddle';
if (text(componentRaw) == 'B2') return 'Saddle heat fusion Branch Saddle';
if (text(componentRaw) == 'B3') return 'Mechanical Branch Saddle';
if (text(componentRaw) == 'C0') return 'Other Repair Clamp';
if (text(componentRaw) == 'C1') return 'Repair Clamps';
if (text(componentRaw) == 'D0') return 'Other Service Tee';
if (text(componentRaw) == 'D1') return 'Welded by welded Service Tee';
if (text(componentRaw) == 'D2') return 'Welded by butt fusion Service Tee';
if (text(componentRaw) == 'D3') return 'Welded by Thread Service Tee';
if (text(componentRaw) == 'D4') return 'Welded by compression or nut follower Service Tee';
if (text(componentRaw) == 'D5') return 'Welded by mechanical interference fit Service Tee';
if (text(componentRaw) == 'DD') return 'Welded by stab Service Tee';
if (text(componentRaw) == 'D6') return 'Thread by welded Service Tee';
if (text(componentRaw) == 'D7') return 'Thread by compression or nut follower Service Tee';
if (text(componentRaw) == 'DE') return 'Thread by mechanical interference fit Service Tee';
if (text(componentRaw) == 'DF') return 'Thread by stab Service Tee';
if (text(componentRaw) == 'DG') return 'Thread by thread Service Tee';
if (text(componentRaw) == 'DH') return 'Thread by butt fusion Service Tee';
if (text(componentRaw) == 'D8') return 'Mechanical saddle by welded Service Tee';
if (text(componentRaw) == 'D9') return 'Mechanical saddle by Butt fusion Service Tee';
if (text(componentRaw) == 'DA') return 'Mechanical saddle by thread Service Tee';
if (text(componentRaw) == 'DB') return 'Mechanical saddle by compression or nut follower Service Tee';
if (text(componentRaw) == 'DC') return 'Mechanical saddle by mechanical interference fit Service Tee';
if (text(componentRaw) == 'DJ') return 'Mechanical saddle by stab Service Tee';
if (text(componentRaw) == 'E0') return 'Other Service Saddle';
if (text(componentRaw) == 'E1') return 'Single strap Service Saddle';
if (text(componentRaw) == 'E2') return 'Double strap Service Saddle';
if (text(componentRaw) == 'EF') return 'Excess Flow Valve';
if (text(componentRaw) == 'F0') return 'Other Filter';
if (text(componentRaw) == 'F1') return 'Pilot Filter';
if (text(componentRaw) == 'F2') return 'Service and Mains Filter';
if (text(componentRaw) == 'F3') return 'Strainer Filter';
if (text(componentRaw) == 'M0') return 'Other Meter Component';
if (text(componentRaw) == 'M1') return 'Diaphragm Meter';
if (text(componentRaw) == 'M2') return 'Rotary Meter';
if (text(componentRaw) == 'M3') return 'Meter Set Assembly';
if (text(componentRaw) == 'M4') return 'Meter bar';
if (text(componentRaw) == 'M5') return 'Meter Swivel';
if (text(componentRaw) == 'M6') return 'Meter nut';
if (text(componentRaw) == 'M7') return 'Ultrasonic Meter';
if (text(componentRaw) == 'M8') return 'Turbine Meter';
if (text(componentRaw) == 'M9') return 'Remote shut off Meter';
if (text(componentRaw) == 'P0') return 'Other Pressure Control Fitting';
if (text(componentRaw) == 'P1') return 'Split Repair Pressure Control Fitting';
if (text(componentRaw) == 'P2') return 'Bottom out Pressure Control Fitting';
if (text(componentRaw) == 'P3') return 'Top tap Pressure Control Fitting';
if (text(componentRaw) == 'R0') return 'Other Riser';
if (text(componentRaw) == 'R1') return 'Factory Assembled Anodeless Riser';
if (text(componentRaw) == 'R2') return 'Factory Assembled Anodeless Flexible Riser';
if (text(componentRaw) == 'R3') return 'Factory Assembled Non-Anodeless Riser';
if (text(componentRaw) == 'R4') return 'Field Assembled Anodeless Riser';
if (text(componentRaw) == 'R5') return 'Field Assembled Anodeless Flexible Riser';
if (text(componentRaw) == 'R6') return 'Field Assembled Non-Anodeless Riser';
if (text(componentRaw) == 'RX') return 'Other Regulator';
if (text(componentRaw) == 'RP') return 'Pilot Regulator';
if (text(componentRaw) == 'RS') return 'Service Regulator';
if (text(componentRaw) == 'RR') return 'Relief Regulator';
if (text(componentRaw) == 'S1') return 'No outlet Mechanical Saddle';
if (text(componentRaw) == 'T0') return 'Other Transition Fitting';
if (text(componentRaw) == 'T1') return 'Welded end Transition Fitting';
if (text(componentRaw) == 'T2') return 'Thread end Transition Fitting';
if (text(componentRaw) == 'T3') return 'Flanged End Transition Fitting';
if (text(componentRaw) == 'U0') return 'Other Union';
if (text(componentRaw) == 'U1') return 'Non-insulated Union';
if (text(componentRaw) == 'UX') return 'Insulated Union';
if (text(componentRaw) == 'V0') return 'Other Valve';
if (text(componentRaw) == 'V1') return 'Ball Valve';
if (text(componentRaw) == 'V2') return 'Butterfly Valve';
if (text(componentRaw) == 'V3') return 'Check Valve';
if (text(componentRaw) == 'V4') return 'Relief Valve';
if (text(componentRaw) == 'V5') return 'Gate Valve';
if (text(componentRaw) == 'V6') return 'Needle Valve';
if (text(componentRaw) == 'V7') return 'Plug Valve';

return "No domain value for: " + componentRaw;