Scripting: How to write to datasource?

draven23draven23 Posts: 5

I'm sure it must be possible to write to a Writeable Datasource from a script. I just haven't figured out how to do it.

This is my script:

import com.parasoft.api.*

String setRequestId(ScriptingContext context) {

    String orderId = '023' + new Date().format('yyyyMMdd')
    int productId = Math.abs(new Random().nextInt() % 999999999)
    String requestId = orderId + '00' + productId

    return requestId

    }

How do I write requestId out to a data source?

Thanks!

Comments

  • benken_parasoftbenken_parasoft Posts: 462 ✭✭✭

    I'm sure it must be possible to write to a Writeable Datasource from a script. I just haven't figured out how to do it.

    There is no public API to do this. You must use a Data Bank. However, you can chain a Data Bank to an Extension Tool if you need a script to return the document needed as input to the Data Bank.

  • benken_parasoftbenken_parasoft Posts: 462 ✭✭✭
    edited October 2017

    Please also be aware that SOAtest 9.10.2 and later has a Data Generator tool. It acts very much like a Data Bank except can auto generate values (no scripting required). I think this is a better fit for what you are trying to do.

  • Shailaja_DSShailaja_DS Posts: 1

    Hello People, Im new to parasoft tool, can anyone please tell me why do we use writeable datasource in a script testing.

  • jakubiakjakubiak Posts: 306 ✭✭✭

    Writeable data sources are used when you need to capture data from one test that should be iterated over in a subsequent test.

Sign In or Register to comment.