Question

Groovy/Javascript query

  • 3 November 2022
  • 1 reply
  • 32 views

Hi Team

I need to discard records which have even one field null and other records should pass. This should happen in loop. If I use pre-condition/stream selector, even if 1 record fails conditions, rest pass, even then entire flow gets discarded.

 

records are comming as below in javascript

records[i].value.A[0][‘x1]

records[i].value.A[0][‘x2’]

records[i].value.A[1][‘x1’]

records[i].value.A[1][‘x2’]

If records[i].value.A[0][‘x1’] is null/records[i].value.A[0][‘x2] is null, only A[0] should be discarded. and A[1] should flow this way I need

 

 

In this case can anyone help me how to achieve this in groovy? javascript?


1 reply

Userlevel 5
Badge +1

@Priyanka Mynepally 

can you please try your data in for loop like below code snippet.

If i can get the input details then i can provide the complete code for your requirements.

 

e.g

code snippet to discard rows having null values

for (i=0; i < 3; i++) {

      if (A[i]  == null ) {

          continue

          }

     sdc.output.write(i)

}

Reply