Skip to main content
September 19, 2023
Question

a!fromJson () Function Date format

  • September 19, 2023
  • 7 replies
  • 0 views

Hi all

I have a requirement to build a WEB API and a Process model to update other external system. The request to the web api is:

{
"accountNumber": "20171941",
"houseNumber": "13329892",
"contractStartDate": "2022-08-25T00:00:00.0000000+01:00",
"contractEndDate": "2023-08-25T00:00:00.0000000+01:00"
}

From the WEB API I am using the function a!fromJson to get the values for the process model from the http!request.body, as usual. When we validate the process model and it execution the dates on the request changed from 2022-08-25T00:00:00.0000000+01:00 to 8/24/2022 11:00 PM GMT+00:00.

I understand that the JSON functions detects the Date but we really need to keep that format from the request. Any Idea? 

Thanks

Mario

    7 replies

    mikes0011
    Brainy
    September 19, 2023

    Can you explain more about the dates having "changed"?  As a reminder, Appian carries all date values as their underlying GMT value, and typically upon rendering shows you the relative value according to your local timezone (but the underlying value is still the same).  I'm unclear what may be happening in your case as it sort of depends on details you haven't provided yet.

    mrios0001Author
    September 19, 2023

    When the value is passed from the WEB API to the process Model, I notice that the Strings for the date values change from 2022-08-25T00:00:00.0000000+01:00 to 8/24/2022. I understand that APPIAN understands that the string is a date based on the format but I need to keep the format, this is I need to treat it as string. 

    Mario

    mikes0011
    Brainy
    September 19, 2023
    I notice that the Strings for the date values change from 2022-08-25T00:00:00.0000000+01:00 to 8/24/2022.

    Can you clarify what you're seeing to make you think this?  Where are you seeing "8/24/2022"?  What data type is the PV it's being stored in - is it actually string?

    stefanhelzle0001
    September 19, 2023

    I need to ask this question ... Are you aware that a value and it's visual representation are two different things?

    So, my next question is: "Why do you need to keep that format?"

    a!localVariables(
      local!json: "{
        ""accountNumber"": ""20171941"",
        ""houseNumber"": ""13329892"",
        ""contractStartDate"": ""2022-08-25T00:00:00.0000000+01:00"",
        ""contractEndDate"": ""2023-08-25T00:00:00.0000000+01:00""
      }",
      local!appian: a!fromJson(local!json),
      a!toJson(local!appian)
    )

    This returns a date like: "2022-08-24T23:00:00Z" which is, by the ISO 8601 definition, the exact same value. In UTC.

    mrios0001Author
    September 19, 2023

    Hi Stefan, thanks for the explanation. 

    When the value is passed from the WEB API to the process Model, I notice that the Strings for the date values change from 2022-08-25T00:00:00.0000000+01:00 to 8/24/2022. I understand that APPIAN understands that the string is a date based on the format but I need to keep the format, this is I need to treat it as string. 

    Mario

    stefanhelzle0001
    September 19, 2023

    Why do you think you would need to keep the format?

    July 6, 2026

    You can use an older version of the function (a!fromJson_19r2). That version doesn't convert automatically to Date or Date and Time types.