Question
· Dec 1, 2023

Function Wizard ReplaceStr()

I am trying to replace OBX.2 value of ED to PDF

Here is what I have in the funcion wizard

..ReplaceStr(source.{OBRgrp().OBXgrp().OBX():ValueType},"ED","PDF")

Inbound Message

OBX|5|ED|PDFReport^PDFReport||PDF^Image^PDF^Base64^JVBERi0xLjMNCjEgMCBvYmoNCjw8DQovVHlwZSAvQ2F0YWxvZw0KL1BhZ2VzIDQgMCBSDQovT3V0bGluZXMgMiAwIFI

Desired Outbound Message

OBX|5|PDF|PDFReport^PDFReport||PDF^Image^PDF^Base64^JVBERi0xLjMNCjEgMCBvYmoNCjw8DQovVHlwZSAvQ2F0YWxvZw0KL1BhZ2VzIDQgMCBSDQovT3V0bGluZXMgMiAwIFI

Product version: IRIS 2022.3
Discussion (1)2
Log in or sign up to continue

I'm afraid you cannot use the syntax shortcut () within a StrReplace function.
You can use the () syntax to assign a constant string to ALL the repeating fields, like:

<assign value='"PDF"' property='target.{PIDgrpgrp().ORCgrp().OBXgrp().OBX:ValueType}' action='set' />

In your case you need to iterate in each of the 3 repeating segments using foreach actions, like:

<foreach property='source.{PIDgrpgrp()}' key='k1' >
    <foreach property='source.{PIDgrpgrp(k1).ORCgrp()}' key='k2' >
        <foreach property='source.{PIDgrpgrp(k1).ORCgrp(k2).OBXgrp()}' key='k3' >
            <assign value='..ReplaceStr(source.{PIDgrpgrp(k1).ORCgrp(k2).OBXgrp(k3).OBX:ValueType},"ED","PDF")' property='target.{PIDgrpgrp(k1).ORCgrp(k2).OBXgrp(k3).OBX:ValueType}' action='set' />
        </foreach>
    </foreach>
</foreach>

Enrico