User bio
404 bio not found
Member since Mar 22, 2022
Replies:

@Robert Cemper 

Hope this is something better.

Class REST.BOOK Extends %Library.Persistent 

{

Property Title As REST.TITLE;

Property Author As %String;

Storage Default

{

<Data name="BOOKDefaultData">

<Value name="1">

<Value>%%CLASSNAME</Value>

</Value>

<Value name="2">

<Value>Title</Value>

</Value>

<Value name="3">

<Value>Author</Value>

</Value>

</Data>

<DataLocation>^REST.BOOKD</DataLocation>

<DefaultData>BOOKDefaultData</DefaultData>

<IdLocation>^REST.BOOKD</IdLocation>

<IndexLocation>^REST.BOOKI</IndexLocation>

<StreamLocation>^REST.BOOKS</StreamLocation>

<Type>%Library.CacheStorage</Type>

}

}

Class RESTAPI.TITLE Extends %Library.Persistent

{

Index IDKeyIndex On RowId [ IdKey, PrimaryKey, Unique ];

Property RowId As %Library.String(COLLATION = "EXACT", TRUNCATE = 0) [ Required, SqlColumnNumber = 1, SqlFieldName = RowId ];

Property Title As %String;

Property Text As %String;

Storage Default

{

<Data name="TITLEDefaultData">

<Value name="1">

<Value>%%CLASSNAME</Value>

</Value>

<Value name="2">

<Value>Title</Value>

</Value>

<Value name="3">

<Value>Text</Value>

</Value>

</Data>

<DataLocation>^REST.TITLED</DataLocation>

<DefaultData>TITLEDefaultData</DefaultData>

<IdLocation>^REST.TITLED</IdLocation>

<IndexLocation>^REST.TITLEI</IndexLocation>

<StreamLocation>^REST.TITLES</StreamLocation>

<Type>%Library.CacheStorage</Type>

}

}

@Robert Cemper 

set book=##class(BOOK).%New()

set book.RowId=obj.ID     ;  from JSON obj

set book.Title=obj.Title    ;  from JSON obj ------->This line causes an OREF error I tried this initially, the Json object is a string eg "CACHE BOOK" and I want to save the RowId in the Title row in BOOK table when creating a new object in book.

do book.%Save()

Retrieving an existing ID I managed to work on that the problem or issue came to creating a new object in BOOK where I have to get RowId inserted into Title field given the obj.Title from postman is a string.

Certifications & Credly badges:
Abraham has no Certifications & Credly badges yet.
Global Masters badges:
Followers:
Abraham has no followers yet.
Following: