· May 1, 2022

Help to Accessing Foreign key property using JSON Object

Given I have a property 

Class All.AllBooks Extends %Library.Persistent

Property ID As %Integer;

Property Title As User.Book;



In the class method

ClassMethod GetABookById(id As %Integer) As %Status

SET MyBooks = ##class(All.Allbooks).%OpenId(id)

SET obj = {

     "ID" : (MyBooks.%Id())

     "Title" : (MyBooks.Title)



Quit 1


How do Access the foreign key in JSON() data

Product version: IRIS 2019.4
Discussion (7)0
Log in or sign up to continue

@Robert Cemper 
Thank you taht solves the problem for the OREF the challenge I find around it it doesn't post the data to the database the object I have can look like this


I want it to store the following in the database

ID - > autoincrement - this I know how to do it.
Title -> I want to store the ID where Value is "LEARNING CAHE REST API" in the All.Allbooks table

Thank you for all you help. it has open my eyes more. sorry if I ask the obvious questions I'm A C#/ASP.NET developer trying to learn Objectscript/CACHE/MUMPS