Forum Discussion

Dofus01's avatar
Dofus01
New Contributor
6 years ago

Update an xml tag in an xml file that has been loaded via Directory loading

Hi all,   So, my project continues.    I now have 20 xmls in a directory, which I am able to load via a DataSource step, SOAP request, Data loop.   I have realised that I have a fundament...
  • richie's avatar
    6 years ago

    Hi Dofus01 

     

     

    you can use inline/dynamic scripting to sort that to generate today's date.  The value in your post includes a time component - does the time matter or can you just rely on the date?

     

    you can use the following to generate today's date:

    ${=(new Date().format('yyyy-MM-dd'))}

    if you need to add the UTC timezone indicator and time T20:00Z, you can specify

    ${=(new Date().format('yyyy-MM-dd'))}T20:00Z

    the above will work if there isnt any issue having a hard coded time.

     

    I'll have to do some reading to determine a datetime function in groovy - one of the other people on here will almost certainly know it

     

    All you need to do now is in your XML in your datasource, in your ScheduleDate tag instead of a hardcoded date value, input the following:

     

    <ScheduleDate v="${=(new Date().format('yyyy-MM-dd'))}T20:00Z"/>

    When the message is injected - it will generate today's date and the hardcoded UTC time - I've just done it on my laptop and it generates:

     

    <ScheduleDate v="2019-09-06T20:00Z"/>

    hope this helps!

     

    nice one,

     

    rich