go to post Timothy Leavitt · Jan 7, 2021 I generally don't use OnCreateResultSet, but here's a sample with it: Class DC.Demo.ZenPage Extends %ZEN.Component.page { XData Contents [ XMLNamespace = "http://www.intersystems.com/zen" ] { <page xmlns="http://www.intersystems.com/zen"> <fieldSet legend="Filter" layout="horizontal"> <text label="Name Starts With:" onchange="zen('myTable').setProperty('parameters',1,zenThis.getValue())" /> <dateText label="Date:" onchange="zen('myTable').setProperty('parameters',2,zenThis.getValue())" /> <button onclick="zen('myTable').executeQuery()" caption="Filter" /> </fieldSet> <tablePane id="myTable" OnCreateResultSet="CreateResultSet"> <parameter value="" /> <parameter value="" /> </tablePane> <button onclick="zenPage.Populate()" caption="Repopulate Data" /> </page> } ClassMethod CreateResultSet(Output pSC As %Status, pInfo As %ZEN.Auxiliary.QueryInfo) As %ResultSet { Set nameFilter = pInfo.parms(1) Set dateFilter = pInfo.parms(2) // Will be in ODBC format Set query = ##class(%ResultSet).%New() Set query.RuntimeMode = 1 // ODBC Set sql = "select Name, SomeDate from DC_Demo.SampleData" Set conditions = "" If (nameFilter '= "") { Set conditions = conditions_$ListBuild("Name %STARTSWITH ?") Set parameters($i(parameters)) = nameFilter } If (dateFilter '= "") { Set conditions = conditions_$ListBuild("SomeDate = ?") Set parameters($i(parameters)) = dateFilter } If (conditions '= "") { Set sql = sql _ " where "_$ListToString(conditions," and ") } Set pSC = query.Prepare(sql) If $$$ISERR(pSC) { Quit $$$NULLOREF } Set pSC = query.Execute(parameters...) If $$$ISERR(pSC) { Quit $$$NULLOREF } Quit query } ClassMethod Populate() [ ZenMethod ] { Do ##class(DC.Demo.SampleData).%KillExtent() Do ##class(DC.Demo.SampleData).Populate(20,,,,0) &js<zen('myTable').executeQuery();> } } And the data behind it (minus storage definition): Class DC.Demo.SampleData Extends (%Persistent, %Populate) { Property Name As %String; Property SomeDate As %Date; }
go to post Timothy Leavitt · Jan 7, 2021 Note - it's generally better practice to usezenPage.getComponentById('comboboxEdit').getValue()or equivalently (and shorter), zen('comboboxEdit').getValue()
go to post Timothy Leavitt · Nov 16, 2020 Rather than setting the global, could just Do $SYSTEM.Version.SystemMode(newMode) where newMode is LIVE, TEST, FAILOVER, or DEVELOPMENT (case-insensitive).
go to post Timothy Leavitt · Nov 16, 2020 re: "creative minds" - been there, done that, should probably put it on the Open Exchange at some point... ;)
go to post Timothy Leavitt · Nov 16, 2020 From my experience, foreign keys are really underrated/underused among ObjectScript developers. With relationships you don't need to worry about them, but really any time you have an object-valued property (not a relationship) there should almost certainly be a foreign key defined on it. (Same thing goes of course for non-object references to uniquely identifying fields in other tables.)
go to post Timothy Leavitt · Oct 19, 2020 Neat - I'm looking at EnsLogViewer and it seems like the "MultiType" class query is a good example of this. https://github.com/intersystems-ru/EnsLogViewer/blob/master/EnsPortal/Ev...
go to post Timothy Leavitt · Oct 16, 2020 I'm currently looking in to this and hope to have it fixed in short order. Thank you for letting us know. We apologize for the inconvenience and will let you know once the issue has been addressed.
go to post Timothy Leavitt · Oct 16, 2020 @Azezur Rahman - I'd appreciate if you could confirm that everything is working properly for you now.
go to post Timothy Leavitt · Oct 16, 2020 This issue has been resolved. Thank you again for notifying us.
go to post Timothy Leavitt · Oct 1, 2020 Code Snippets do part of the job; for other things (e.g., SOAP Wizard), see @Patrick Newton 's comment on https://github.com/intersystems-community/vscode-objectscript/issues/325 - there is planned support for these.
go to post Timothy Leavitt · Sep 21, 2020 I already use this approach as much as possible, both for the applications I develop and my Open Exchange projects. It makes it easy to trace from test to tested unit, and (in the community package manager world) it avoids collisions between different packages all trying to use the same unit test package. I strongly agree with Evgeny's recommendation.
go to post Timothy Leavitt · Sep 10, 2020 @Olga Zavrazhnova , it looks like we have a bad link at https://community.intersystems.com/post/global-masters-advocate-hub-star... (leading to the certificate error shown). @Kevin Johnson see https://intersystems.influitive.com/users/sign_in instead of the link in that article
go to post Timothy Leavitt · Aug 31, 2020 FYI, we're looking to add automatic OpenAPI generation to https://github.com/intersystems/apps-rest at some point in the reasonably-near future. (We had an intern work on it over the summer, and are just kicking the tires on it a bit on our own REST models/APIs before unleashing it on the world.)
go to post Timothy Leavitt · Aug 25, 2020 I'm intrigued to hear about expression indices - sounds really cool. Without those, another option is just to have a separate class/table. Suppose the key to the AR array is the address type (Home, Office, etc.); then you could have: Class Sample.Person1 Extends (%Persistent, %Populate) { Property Name As %String; Relationship Addresses As Sample.PersonAddress [ Cardinality = children, Inverse = Person ]; } Class Sample.PersonAddress Extends (%Persistent, %Populate) { Relationship Person As Sample.Person1 [ Cardinality = parent, Inverse = Addresses ]; Property Type As %String; Property Address As Sample.Address; } Sample.PersonAddress then can have whatever plain old normal indices you want (except bitmap indices - if you want those, make it one-to-many instead of parent/child). Generally: any time you add an array property - especially an array of objects - it's worth stepping back and thinking about whether it should just be its own full-blown class/table.
go to post Timothy Leavitt · Aug 25, 2020 I'll add, a query on this might look like: select distinct Person->ID, Person->Name from Sample.PersonAddress where Address_State = 'RI' and Type = 'Home' Note the "arrow syntax" for implicit joins.
go to post Timothy Leavitt · Aug 12, 2020 @Richard Schilke , you should be able to share a session by specifying the same CSP session cookie path for your REST web application and the web application(s) through which your Zen pages are accessed. Alternatively, you could assign the web applications the same GroupById in their web application configuration. You likely also need to configure your REST handler class (your subclass of AppS.REST.Handler) to use CSP sessions (from your earlier description, I assumed you had). This is done by overriding the UseSession class parameter and setting it to 1 (instead of the default 0). To reference header data in the UserInfo classmethod, you should just be able to use %request (an instance of %CSP.Request) and %response (an instance of %CSP.Response) as appropriate for request/response headers.
go to post Timothy Leavitt · Aug 12, 2020 @Richard Schilke - great! We have support for filtering/sorting on the collection endpoints already, though perhaps not fully documented. Pagination is a challenge from a REST standpoint but I'd love to add support for it (perhaps in conjunction with "advanced search") at some point. I'm certainly open to ideas on the implementation there. :) Users are the best, because if you don't have them, it's all just pointlessly academic. ;)
go to post Timothy Leavitt · Aug 12, 2020 @Richard Schilke - on further review, it's an issue with the Action map. See my response in https://github.com/intersystems/apps-rest/issues/7 (and thank you for filing the issue!). I'll still create a new release soon to pick up the projection bug you found. Regarding headers - you can reference %request anywhere in the REST model classes, it just breaks abstraction a bit. (And for the sake of unit testing, it would be good to behave reasonably if %request happens not to be defined, unless your planning on using Forgery or equivalent.) Regarding sessions - yes, you can share a session with a Zen application via a common session cookie path or using GroupById. You can reference this as needed as well, though I'd recommend wrapping any %session (or even %request) dependencies in the user context object that gets passed to CheckPermissions().