Forum Discussion

swampyedwards's avatar
swampyedwards
New Contributor
4 years ago

Converting local UK dates in to UTC ISO formats

Hi

I am looking to take a local UK format DATETIME and convert it to an ISO UTC format

Currently I am parsing the date using a substring() in to LocaleDateTime.parse($inputStrings) to create a snaplocaledate value

When I try to parse the value out as a $snapLocalDateTime.toLocaleDateTimeString({“timeZone”:“UTC”, “format”:“yyyy-MM-ddTHH:mm:ssZ”})

I just get an error

Expression

$snapLocalOccurredAt.toLocaleDateTimeString({"timeZone":"UTC", "format":"yyyy-MM-dd HH:mm:ss"})

[
{
failure:
"Unknown method: toLocaleDateTimeString"
value:
"Please check expression syntax"
reason:
"Please check expression syntax"
sub-expression:
{
0: $snapLocalOccurredAt:
[
{
_snaptype_localdatetime:
"2021-10-18T07:20:52.000"
}
]
1: {"timeZone":"UTC", "format":"yyyy-MM-dd HH:mm:ss"}:
[
]
2: ({"timeZone":"UTC", "format":"yyyy-MM-dd HH:mm:ss"}):
[
[
{
timeZone:
"UTC"
format:
"yyyy-MM-dd HH:mm:ss"
}
]
]
}
}
]

Any help would be great

Using a GroundPlex in UK.

1 Reply

  • SpiroTaleski's avatar
    SpiroTaleski
    Valued Contributor

    akarsh 

    You just need to split the array using the JSON Splitter Snap, once you read the file and parse the content, so you will have the nested structure split and pipeline will process the records one by one. Then you can proceed with developing the rest of the logic.

    Note: You should use REST API Mode within the Salesforce Snaps, in order records to be processed one by one. 

  • akarsh's avatar
    akarsh
    New Contributor III

    One more question.

    I have the following snap structure

    read from JMS ( List of object) -> Json Splitter -> lookup on sales force for ID -> Send data to sales force using salesforce upsert -> maps and post it to JMS.

    What's happening here is data is being posted individually. is it possible to collect it in a single JSON and send it once to JMS?

    • SpiroTaleski's avatar
      SpiroTaleski
      Valued Contributor

      akarsh 

      Yes, you can utilize Group By N Snap in order to have a list with all records inside. You can specify also the size of each group within the snap. 

      • akarsh's avatar
        akarsh
        New Contributor III

        As mentioned above 

        I have a input json file like below please see the dummy example below

        { "totalCount": 2, "dataList": [ { "IFA": "IFA1", "voltage": "200", "power": "100", "equipid": "1234ABC", "SN": "SalesForce-1" }, { "IFA": "IFA2", "voltage": "200", "power": "100", "equipid": "1234ABC", "SN": "SalesForce-1" } ] } 

        this will be split using json splitter and sent to salesforce through API which returns an output.

        Output from salesforce will be like this

        [{"assetguid":"test","sfdcid":"id","status":"SUCCESS","updatedTime":"2023-11-24T08:59:34.167Z"}]

        I want to collect these output in single file as you mentioned I tried Group By N but it doesn't return any output. 

        my group by n snap looks like this

        as you can see group by n got 2 documents but there was not output

        can you please help me here? what am I doing wrong here?