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 = LocalDateTime.now.format(DateTimeFormatter.ofPattern(“YYYYMMdd_HHmmss”))

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

.post(“https://hudsn-preprod-1.oms.supply-chain.ibm.com/smcfs/restapi/executeFlow/HBCCreateOrderSyncService/”)
.basicAuth(“admin”, “password”)
.header(“Content-Type”, “text/xml”)
.body(StringBody(
“”"

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





























“”"))
.check(status.is(204)))

}
}

https://gatling.io/docs/gatling/reference/current/session/expression_el/

"${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)
      feed(csvfeeder)
      .exec(session => {
        session.set("OrderDate", format.format(Calendar.getInstance().getTime()))
      })
      .exec(http("HBCCreateOrder")

        .post("[https://hudsn-preprod-1.oms.supply-chain.ibm.com/smcfs/restapi/executeFlow/HBCCreateOrderSyncService/](https://hudsn-preprod-1.oms.supply-chain.ibm.com/smcfs/restapi/executeFlow/HBCCreateOrderSyncService/)")
        .basicAuth("admin", "password")
        .header("Content-Type", "text/xml")
        .body(StringBody(
          """

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

.body(StringBody(

“”"

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 https://github.com/gatling/gatling-private/blob/main/gatling-core/src/test/scala/io/gatling/core/session/el/ElSpec.scala#L618.