Only use first 10 of integer number

Hi all,

I have probably a simple question but I cannot get it to work.
From an Api call, I get a Json (see below for data) with a field “position”.

This position used to be only 1 till 99. But the Apo developer changed it to a bigint with 19 characters.
I only need the first 10 numbers. Is there a way cut off the rest from the number?

For example:
position: 1353866160692625400

Need to change in;
position: 1353866160

I tried to use a Function but I am not able to get it right.

Could someone please help me?

{
“id”: “00349fd7-5e08-4686-94ae-cb748ebc892d”,
“board_id”: “799a2041-9dcf-4de0-9477-828e7b110675”,
“source_type”: “custom”,
“external_ref”: null,
“status”: “planned”,
“progress”: “done”,
“position”: null,
“start”: “2021-04-16”,
“end”: “2021-04-16”,
“name”: " 1x Loodusvagi Rijstwafels Puur Bio 12st",
“description”: “WO: 5929, 162 dozen per pallet”,
“due_date”: “2021-04-18”,
“meta”: null,
“custom_fields”: [
{
“name”: “Productielijn”,
“type”: “text”,
“priority”: 0,
“value”: “melklijn”
},
{
“name”: “Aantal te produceren”,
“type”: “number”,
“priority”: 1,
“value”: 162
},
{
“name”: “Werkordernummer”,
“type”: “text”,
“priority”: 0,
“value”: “5929”
}
],
“cover_image_url”: null,
“cover_color_hex”: null,
“cover_image_checksum”: null,
“cover_image_signature”: null,
“cover_image_bytes”: 0,
“created_at”: “2021-03-24T11:40:30Z”,
“updated_at”: “2021-04-16T09:20:32Z”,
“warnings”: [
],
“cards”: [
{
“id”: “776a90f1-eabb-4634-845f-50e50240c675”,
“collection_id”: “00349fd7-5e08-4686-94ae-cb748ebc892d”,
“status_id”: “c23e58a8-d60d-4ed3-a1b0-ee5d0d40b4fc”,
“stage_id”: “e6764d0b-cc7b-4934-a0e5-1ebf8b3f1cc8”,
“date”: “2021-04-16”,
“start”: “2021-04-16”,
“end”: “2021-04-16”,
“rank”: “aaapi”,
“position”: 1353866160692625400,
“name”: " 1x Loodusvagi Rijstwafels Puur Bio 12st",
“description”: “WO: 5929, 162 dozen per pallet”,
“days_diff”: 0,
“days_active”: 1,
“locked”: false,
“created_at”: “2021-03-24T12:19:29Z”,
“updated_at”: “2021-04-16T09:20:32Z”
}
]
},

Hey @heestp,

There are a few ways to do it but the quickest is probably to just add .substring(0,10) to the end of your variable in a function or expression… So it would be something like…

Expression…

{{$json['id'].substring(0,10)}}

Function…

for (item of items) {
  item.json.newID = item.json.id.substring(0,10);
}

return items;

You would need to clean it up to work with your json to take the cards array into consideration but it should get you started.

3 Likes