Skip to main content

Dear All,

 

I have a business logic, where i need to select value for RSN field , based on below Condition 

 

IF  TypeCode = WriteOff  then

   { 

      if  RsnCode = “1004” then 

         Rsn = “925”

      elseif RsnCode = “1006” then

         Rsn = “200”

      elseif RsnCode = “1003” then

         Rsn = “935”

    }

ElseIf TypeCode = WriteOn then

 

 { 

      if  RsnCode = “1004” then 

         Rsn = “950”

      elseif RsnCode = “1006” then

         Rsn = “250”

      elseif RsnCode = “1003” then

         Rsn = “935”

    }

 

to achieve i tried to add the arc:case within the If condition as below, 

 

<arc:if exp="'TypeCode'=='StockWriteOff'">
  <arc:select attr="RSNCode">
  <arc:case value="1006">
    <arc:set attr="Rsn" value="200"/>
  </arc:case>
  <arc:select attr="RSNCode">
  <arc:case value="1004">
    <arc:set attr="Rsn" value="925"/>
  </arc:case>
  <arc:select attr="RSNCode">
  <arc:case value="1003">
    <arc:set attr="Rsn" value="935"/>
  </arc:case>
  <arc:else>
    <arc:select attr="RSNCode">
  <arc:case value="1006">
    <arc:set attr="Rsn" value="250"/>
  </arc:case>
  <arc:select attr="RSNCode">
  <arc:case value="1004">
    <arc:set attr="Rsn" value="950"/>
  </arc:case>
  <arc:select attr="RSNCode">
  <arc:case value="1003">
    <arc:set attr="Rsn" value="935"/>
  </arc:case>
  </arc:else>
</arc:if>

<arc:set attr="result.text" value="rRsn]"></arc:set>

 

But i am getting invaild script error message, kindly help to shed some light to eliminate the error and achieve the results.  

Hi Pradeep,

As you raised the ticket for the same and that is resolved already. I am suggesting the 2 different solutions here as well.

 

In your script, there is repetition of the select element for each case. To optimize this, you can use a single select statement for the if block and another for the else block.

 

Additionally, note that <arc:select> works on the value, so you should use <arc:select value> instead of <arc:select attr>

 

When referencing elements from the source file, ensure to utilize the xpath() instead of directly passing element names as strings within double quotes. Here is an example:

 <arc:select value="vxpath(/Items/Data/RSNCode)]">

This ensures proper xpath() usage to reference the source file elements.

 

Achieving this can be done through two methods. The first one involves using Arc script with the Arc select and case keywords.

 

Below is the corrected version of the script:

<arc:if exp="cxpath(/Items/Data/TypeCode) | equals('StockWriteOff')]">
    <arc:select value="lxpath(/Items/Data/RSNCode)]">
        <arc:case value="1006">
            <arc:set attr="Rsn" value="200"/>
        </arc:case>
        <arc:case value="1004">
            <arc:set attr="Rsn" value="925"/>
        </arc:case>
        <arc:case value="1003">
            <arc:set attr="Rsn" value="935"/>
        </arc:case>
    </arc:select>
        <arc:else>
          <arc:select value="�xpath(/Items/Data/RSNCode)]">
            <arc:case value="1006">
                <arc:set attr="Rsn" value="250"/>
            </arc:case>
            <arc:case value="1004">
                <arc:set attr="Rsn" value="950"/>
            </arc:case>
            <arc:case value="1003">
                <arc:set attr="Rsn" value="935"/>
            </arc:case>
          </arc:select>
        </arc:else>
</arc:if>

<arc:set attr="result.text" value="�Rsn]" />

 

------------------------------------------Alternative Approach-------------------------------------------------

 

Another approach to achieve this use case is by using the IF-Else condition on your Rsn element. Within each condition, you can include multiple IF conditions to handle various edge cases, as demonstrated below:

 

IF :

 

Else:

 

Please find the attached connector Arc flow(2nd approach) for your reference.

 


Hi Rohit,

 

Thanks for the response with alternative approach. 

I have posted here few hours ago before raising ticket, since i need to complete the change i raised the ticket to get fast response. 

 

Thanks for kind understanding and supportive. 


Reply