Forum Discussion

stenofski's avatar
stenofski
Occasional Contributor
10 years ago

Calculate within the request before sending - Property Expansion, Dynamic Properties, Request

Hey,   i would like to calculate a value within the request based on another property. The current issue i have is that he calculates the value but the soap request isnt correct or he dont calculat...
  • rupert_anderson's avatar
    10 years ago

    Hi Sten,

     

    Have you seen the Groovy 'padLeft' command? Maybe this can do what you need?

     

    Consider the example:

     

    for ( i in 0..10 ) {
        log.info i.toString().padLeft(2,'0')
    }

     

    This prints:

     

    • Thu Sep 17 17:55:15 BST 2015:INFO:00
    • Thu Sep 17 17:55:15 BST 2015:INFO:01
    • Thu Sep 17 17:55:15 BST 2015:INFO:02
    • Thu Sep 17 17:55:15 BST 2015:INFO:03
    • Thu Sep 17 17:55:15 BST 2015:INFO:04
    • Thu Sep 17 17:55:15 BST 2015:INFO:05
    • Thu Sep 17 17:55:15 BST 2015:INFO:06
    • Thu Sep 17 17:55:15 BST 2015:INFO:07
    • Thu Sep 17 17:55:15 BST 2015:INFO:08
    • Thu Sep 17 17:55:15 BST 2015:INFO:09
    • Thu Sep 17 17:55:15 BST 2015:INFO:10

    So, basically you could get your counter value (as a String) and use padLeft(2, '0') to append a 0 when the counter is <10, is this the sort of thing you want?

     

    Cheers,

    Rupert