Forum Discussion
SmartBear_Suppo
Alumni
15 years agoHi!
I would do it like this:
1. DataSource
2. Groovy Script
3. DataSource Loop
4. DataSink
Content of Groovy Script:
Then you can do whatever needed with finalOutputNeeded (store it to a Property, use it in a DataSink or Request, etc.).
Hope this helps
Henrik
SmartBear Stockholm
I would do it like this:
1. DataSource
2. Groovy Script
3. DataSource Loop
4. DataSink
Content of Groovy Script:
def itemNum= context.expand( '${DataSource#itemNum}' )
def rowNum= context.expand( '${DataSource#rowNum}' )
def endDate= context.expand( '${DataSource#endDate}' )
def newJsonElement= """{
"itemNum":${itemNum},
"rowNum":${rowNum},
"endDate":${endDate}
}"""
if( context.allJsonElemens != null )
{
context.allJsonElemens.add( newJsonElement )
}
else
{
context.allJsonElemens = [ newJsonElement ]
}
def finalOutputNeeded = '{' + context.allJsonElemens.join(',') + '}'
Then you can do whatever needed with finalOutputNeeded (store it to a Property, use it in a DataSink or Request, etc.).
Hope this helps
Henrik
SmartBear Stockholm