Written by

Software Architect at Visum
Question Yuri Marx · Apr 12, 2021

%JSONExport - ID export

Hi Community,

How Can I do to return ID when I call %JSONExport()?

Product version: IRIS 2020.3

Comments

Robert Cemper · Apr 12, 2021

create a calculated property and it looks like any other one

Property MyId As %Integer [ Calculated, SqlComputeCode = { set {*}={%%ID}}, SqlComputed ];

0
Timothy Leavitt  Apr 12, 2021 to Robert Cemper

This is the right answer. It would be nice if there was a more built-in way to include row IDs in %JSONExport without having to do this though.

0
Yuri Marx  Apr 12, 2021 to Timothy Leavitt

I agree with you, a Parameter for example

0
Robert Cemper  Apr 12, 2021 to Timothy Leavitt

Hi, @Timothy Leavitt .#

What's about a prodlog ?  devil

"JSONid public" would be nice pairing with "rowid privat" ?  wink
 

0
Evgeny Shvarov  Apr 23 to Timothy Leavitt

Is it implemented yet? Found the need for it too :)

0
Yuri Marx  Apr 12, 2021 to Robert Cemper

Thanks Cemper.

0
Eduard Lebedyuk · Apr 12, 2021

While I do agree, what's the use case?

If you're requesting objects en masse it's usually via sql and it's easy to provide id there.

In a case of a singular object you usually request it by ID so it's known beforehand.

0
Yuri Marx  Apr 12, 2021 to Eduard Lebedyuk

I followed https://openexchange.intersystems.com/package/iris-rest-api-template to construct some API and the GetAll used JSONExport, but when you work with JavaScript projections to the objects is nice convert the JSON to object. With no ID return you need write an additional instruction to set the ID. After the insert operation, in the master detail forms, get the ID after persist the master, help us to build conditional detail forms.

0