Inline Scripting - To increment a unique value by +1 each submission?
Hey!
I have some tests that POST a .json to MS's Dynamics CRM. One of the .json attributes is a unique identifier (submissionid) - it's a 13 digit number treated as a string (so wrapped in quote marks)
Before now - when I've needed to make a unique identifier like this change each submission - I've parameterized the value - I've used say the following:
TestCase1_${=(new Date().format('dd-MM-yyyy'))}
So if the test is run once a day - the unique identifier is always unique - or before now I've added the time as well the date - so the test could be executed multiple times a day.
Now the submissionid value is a 13 digit numeric string (e.g. "1559999320553"), so I can't use the inline scripting option I used before to make it unique.
The .json payload is as below:
{ "whatevs_submissionid" : "1559999320553", "whatevs_exportdate" : "2019-10-12", "whatevs_DestinationCountry@odata.bind" : "/whatevs_countries(1eb03e02-e32d-e911-a975-000d3a2cb90c)", "whatevs_CommodityGroup@odata.bind" : "/whatevs_commoditygroups(1e115957-7b2f-e911-a969-000d3a29ba60)", "whatevs_CommodityTypeid@odata.bind" : "/whatevs_commoditytypes(befa3a40-902f-e911-a96d-000d3a2cbd60)", "whatevs_DeliveryMethod@odata.bind" : "/whatevs_deliverymethods(8ef00b91-6228-e911-a969-000d3a28d891)", "whatevs_EHCTemplate@odata.bind" : "/whatevs_ehctemplates(1625bacc-ba2f-e911-a969-000d3a29ba60)", "whatevs_applicationchannel" : "814250002", "whatevs_appliedehcversion" : "1.4", "whatevs_exportertrader" : "Trader", "whatevs_applicationurl" : "https://whatevs.azurewebsites.net/protected/application/1559999320553/review", "whatevs_ehcurl" : "https://whatevs.azurewebsites.net/protected/application/1559999320553/ehc", "whatevs_ukcountryofexport" : "814250000", "whatevs_Organisation@odata.bind" : "/accounts(a528f577-1bc7-e811-a95c-000d3a28da35)", "whatevs_ApplicantId@odata.bind" : "/contacts(603d0039-a019-e911-a96d-000d3a28da35)", "whatevs_numberofcertificates" : 1, "whatevs_applicantreference" : "ABC6666" }
Typically I'd parameterize these to something like as follows:
{ "whatevs_submissionid" : "${#TestCase#whatevs_submissionid}", "whatevs_exportdate" : "2019-10-12", "whatevs_DestinationCountry@odata.bind" : "/whatevs_countries(1eb03e02-e32d-e911-a975-000d3a2cb90c)", "whatevs_CommodityGroup@odata.bind" : "/whatevs_commoditygroups(1e115957-7b2f-e911-a969-000d3a29ba60)", "whatevs_CommodityTypeid@odata.bind" : "/whatevs_commoditytypes(befa3a40-902f-e911-a96d-000d3a2cbd60)", "whatevs_DeliveryMethod@odata.bind" : "/whatevs_deliverymethods(8ef00b91-6228-e911-a969-000d3a28d891)", "whatevs_EHCTemplate@odata.bind" : "/whatevs_ehctemplates(1625bacc-ba2f-e911-a969-000d3a29ba60)", "whatevs_applicationchannel" : "814250002", "whatevs_appliedehcversion" : "1.4", "whatevs_exportertrader" : "Trader", "whatevs_applicationurl" : "https://whatevs.azurewebsites.net/protected/application/${#TestCase#whatevs_submissionid}/review", "whatevs_ehcurl" : "https://whatevs.azurewebsites.net/protected/application/${#TestCase#whatevs_submissionid}/ehc", "whatevs_ukcountryofexport" : "814250000", "whatevs_Organisation@odata.bind" : "/accounts(a528f577-1bc7-e811-a95c-000d3a28da35)", "whatevs_ApplicantId@odata.bind" : "/contacts(603d0039-a019-e911-a96d-000d3a28da35)", "whatevs_numberofcertificates" : 1, "whatevs_applicantreference" : "ABC6666" }
But as I state above - I want to get the value to increment by +1 each time the test is executed.
I hope I've been clearer than I usually am! :)
Can anyone advise?
Cheers,
richie
How about below which works any time:
"whatevs_submissionid" : "${= System.currentTimeMillis()}"