how to pass system timestamp in script in every iteration in place of OrderNO which is highlighted in XML

package hbc.testRunner

import io.gatling.core.Predef._
import io.gatling.http.Predef._

import java.text.SimpleDateFormat
import java.time.LocalDateTime
import java.util.Calendar
import java.time.format.DateTimeFormatter

object trisha {

  • Base URL

val csvfeeder = csv(“data/HBCCreateOrder1.csv”).queue
val format =“YYYYMMdd_HHmmss”))

val scn = //scenario(“HBCInventoryLookup”)
forever() {
pace(2, 4)
.exec(session => {
session.set(“OrderDate”, format.format(Calendar.getInstance().getTime()))

.basicAuth(“admin”, “password”)
.header(“Content-Type”, “text/xml”)

<Order Action=“CREATE” AllocationRuleID=“BAY_SCH” AuthorizedClient=“BAY” PaymentStatus=“NOT_APPLICABLE”
CustomerEMailID="" DocumentType=“0001”
DraftOrderFlag=“N” EnteredBy=“Web” EnterpriseCode=“BAY”
EntryType=“Online” OrderDate="${OrderDate}Z"
OrderNo=“8979797” SellerOrganizationCode=“BAY”>



"${currentDate(<pattern>)}" // new Date() formatted with a java.text.SimpleDateFormat pattern

thank you Stephane,

I am very new to gatling, i substituted that method in place of paramater, but it is not working, can you help me with the exact code.

Please show what you’ve done so far.

val csvfeeder = csv("data/HBCCreateOrder.csv").queue

val format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss")

val scn = //scenario("HBCInventoryLookup")
  forever() {
   // pace(2, 4)
      .exec(session => {
        session.set("OrderDate", format.format(Calendar.getInstance().getTime()))

        .basicAuth("admin", "password")
        .header("Content-Type", "text/xml")

<Order Action="CREATE" AllocationRuleID="BAY_SCH" AuthorizedClient="BAY" PaymentStatus="NOT_APPLICABLE"
  CustomerEMailID="[](" DocumentType="0001"
  DraftOrderFlag="N" EnteredBy="Web" EnterpriseCode="BAY"
  EntryType="Online" OrderDate="${OrderDate}Z"
  OrderNo="${currentTimeMillis()}" SellerOrganizationCode="BAY">



Thank you Stephane,

But it is failing and giving below error

HBCCreateOrder1: Failed to build request: No attribute named ’ 20020 (100.0%)
yyyy-MM-dd’T’HH:mm:ss’ is defined

No idea what you’re doing exactly, but the problem is on your side and the syntax I provided is correct, see