go to post Timothy Leavitt · Jun 19, 2017 Not the most creative output: USER>write ##class(ITPlanet.BlackBox).Main(<left as a mystery>,<also left as a mystery>) Hello World! @Eduard, I'm assuming you don't want spoilers here beyond that? One non-spoiler: there are actually two valid options for the first argument that will produce this output.
go to post Timothy Leavitt · Jun 15, 2017 A common and simple approach is to Base64-encode binary data. See $System.Encryption.Base64Encode()/$System.Encryption.Base64Decode(), plus the atob and btoa functions in JavaScript (maybe not relevant in your particular case, depending on what the client is).
go to post Timothy Leavitt · Jun 12, 2017 For a more direct approach, see the class query %SYS.ProcessQuery:PPG - it's not [SqlProc] so you need to call it the old-fashioned way. For example: Terminal 1: USER>w $j 10740 USER>s ^||demo(2)=5,^||demo=2 USER>zw ^||demo ^||demo=2 ^||demo(2)=5 Terminal 2: %SYS>set rs = ##class(%ResultSet).%New("%SYS.ProcessQuery:PPG") %SYS>set sc = rs.Execute("demo",10740) %SYS>while rs.%Next() { do rs.%Print() } demo 2 demo(2) 5
go to post Timothy Leavitt · Jun 7, 2017 Generally speaking, the parameters defined in %ZEN.DataModel.objectModelParameters can be used to customize the appearance/behavior/really anything about the controls in a dynaForm. One such parameter is: /// Optional. /// id of a group component that the control used for this property /// should be added to. This provides a way to control layout.<br> /// If not defined, the control is added directly to the <class>dynaForm</class>. Parameter ZENGROUP As STRING; For example, given the model class: Class DC.Demo.ZenDynaForm.Model Extends %ZEN.DataModel.ObjectDataModel { Property FirstName As %String(ZENGROUP = "nameGroup"); Property MiddleInitial As %String(ZENGROUP = "nameGroup"); Property LastName As %String(ZENGROUP = "nameGroup"); Property HomePhone As %String(ZENGROUP = "phoneGroup"); Property CellPhone As %String(ZENGROUP = "phoneGroup"); } The following <dynaForm> will display the three name fields in one horizontal row, and the two phone fields in another: Class DC.Demo.ZenDynaForm Extends %ZEN.Component.page { /// This XML block defines the contents of this page. /// Setting XMLNamespace turns on StudioAssist for this XML block. XData Contents [ XMLNamespace = "http://www.intersystems.com/zen" ] { <page xmlns="http://www.intersystems.com/zen"> <dataController id="myController" modelClass="DC.Demo.ZenDynaForm.Model" /> <dynaForm controllerId="myController"> <hgroup id="nameGroup" /> <hgroup id="phoneGroup" /> </dynaForm> </page> } }
go to post Timothy Leavitt · Jun 7, 2017 Here's some relevant documentation, if I'm understanding your question correctly: http://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY=GZAP_customizationThere are two topics covered here: custom Zen components, which have their own HTML rendering, and composite components, which are simply reusable groupings of other Zen components.These really wouldn't be "system-defined" - you'd have them in a separate XML namespace and they'd be distinct from the "system-defined" Zen component classes, but they can be used in the same page alongside standard Zen components.
go to post Timothy Leavitt · Jun 6, 2017 19 in non-expression mode: Set ^oddDEF("ITPlanet.Task2","m","main",30,1)=" q $lg("""_$c(7,4)_"ê"_$c(22)_"°L"_$c(2)_""")" Do $System.OBJ.Compile("ITPlanet.Task2") The actual class code contains a few control characters, but not ASCII 0-9.
go to post Timothy Leavitt · May 24, 2017 Thanks Vitaliy - that's really interesting. It's also fascinating what Google Translate does to Caché ObjectScript! if ex . The Name = "<the METHOD of DOES the NOT EXIST>" { s st = $$$ the ERROR ( $$$ MethodDoesNotExist , method )
go to post Timothy Leavitt · May 23, 2017 Hi Laura - not sure if you ever figured this out, but here's an example using a generic OnDrawCell delegator method. The specific example is intended to run against a table in the SAMPLES namespace. Class DC.Demo.CellTitle Extends %ZEN.Component.page { /// This XML block defines the contents of this page. /// Setting XMLNamespace turns on StudioAssist for this XML block. XData Contents [ XMLNamespace = "http://www.intersystems.com/zen" ] { <page xmlns="http://www.intersystems.com/zen" height="100%"> <tablePane tableName="Sample.Company"> <column colName="ID" hidden="true" /> <column colName="Name" /> <column colName="Mission" OnDrawCell="DrawMissionCell" seed="90" /> </tablePane> </page> } /// <var>pSeed</var> is the maximum length to show in the cell. Method DrawMissionCell(pTable As %ZEN.Component.tablePane, pName As %String, pSeed As %String) As %Status { Set tFullText = %query(pName) Set tTitle = "" Set tStyle = "" Set tLine = $Extract(tFullText,1,pSeed) If (tLine '= tFullText) { Set tStyle = "font-style: italic;" Set tTitle = tFullText Set tLine = tLine_" ..." } &html<<div style="#(tStyle)#" title="#(..EscapeHTML(tTitle))#">#(..EscapeHTML(tLine))#</div>> Quit $$$OK } } An OnDrawCell delegator method generally just renders HTML for the table cell. In this case, if the text in the cell is greater than some specified length (the "seed" attribute of the column, which is passed to the OnDrawCell delegator method), then the text in the column is italicized and the tooltip is set to the full text. Otherwise, the cell is shown as usual with no tooltip. Note that the HTML escaping is done at the very end - you wouldn't want to truncate the text in the middle of an escape sequence. You could make this method simpler and always have it show the tooltip, if you'd like. It's also generic (no hard-coded column name), so you could put it in a Zen template class and reuse it across multiple pages (probably after giving it a better name). Another alternative would be subclassing %ZEN.Component.tablePane and overriding %DrawTable to add zen expression support to cellTitle, but unfortunately that method is quite ugly and monolithic. OnDrawCell is the most clear and maintainable option.
go to post Timothy Leavitt · Apr 14, 2017 Perhaps consider using SOAP logging (see documentation) to compare a valid request from a web client that works (using a Caché-based client or a third-party tool like SoapUI) to what your PHP client is sending - that might make it more obvious how the correct XML differs from what PHP is sending.
go to post Timothy Leavitt · Apr 12, 2017 It looks like some of this may have come from https://community.intersystems.com/post/example-connecting-cach%C3%A9-web-service-php The remainder of that example may also be useful, for demonstrating how to use the correct SOAPACTION (which the error message you have refers to). This entails using __soapCall with an array of options including the expected SOAPACTION value. // Object with parameter names and values for the SOAP call $request = new stdClass(); $request->id = $id; // This goes in an associative array with key FindPersonSoapIn (see WSDL) $params = array(); $params['FindPersonSoapIn']=$request; // In the array of options for the soap call, soapaction must be specified since there's no WSDL to refer to. // PHP provides a default value of <uri>#<method>, but that's incorrect. $options = array('soapaction'=>$uri.'/SOAP.Demo.FindPerson'); // Actually call the web service $result = $client->__soapCall("FindPerson",$params,$options);
go to post Timothy Leavitt · Apr 12, 2017 The problem with using the strategy from that code snippet on breakpoints is that they're separate persistent objects - the approach in the code snippet is to make a temporary change to the object that will be exported, but this doesn't seem to work (after a few attempts with different approaches) for breakpoints without breaking things in Studio.Having project items sorted alphabetically is helpful to avoid conflicts in source control with multiple people working on the same project at the same time.Example:User A adds a file. User B adds a file. User A commits their change. User B goes to commit their change and can't because a conflict is detected due to User A's change to the same line of code (because both added new project items at the end of the list).
go to post Timothy Leavitt · Apr 12, 2017 This is a great list!For (10), I always use a global starting with ^mtemp rather than ^debug (for example). By default, ^mtemp is mapped to CACHETEMP. This is handy for a few reasons:Debugging global sets from all namespaces go to the same database.This database is reinitialized each time the system starts, so it's a great place to put data you don't care about losing. (No need to fill/expand databases you do care about with debugging information, especially for the off chance that you accidentally forget to remove the debugging code.)Since CACHETEMP isn't journaled, if the debugging information is logged in a transaction, those global sets won't be rolled back even if/when the transaction is.Since CACHETEMP isn't journaled, if debug code sets a lot of globals, there won't be the extra space taken up by journals. (I once crashed a shared development environment when a process running overnight filled up the disk with journal files from setting the same debug global millions/billions of times.)I find TDD most useful for cases where there's a simple input and output to/from complex server-side processing. It'd be great to see the unit test tool you built on GitHub/etc.!One thing missing from your list is code review. This is particularly helpful for making sure you're *actually* doing #5-8.
go to post Timothy Leavitt · Apr 12, 2017 Some indirect answers that may be useful: I don't tend to use the call stack view in the Studio debugger. For many cases where stack information is useful for debugging, I'll typically just add this to my code: do LOG^%ETN Then run it, and then look in the application error log (visible in Management Portal at System Operation > System Logs > Application ErrorLog, or via do ^%ER) to see what the stack/variables were when it was called. Also, you should be able to clear out locks (perhaps cautiously) in the management portal from System Operation > Locks > Manage Locks.
go to post Timothy Leavitt · Apr 12, 2017 Here's a snippet from my Studio Extension (a subclass of one of the more standard extensions) that you might use and adapt in yours. It deals with a few other things that /diffexport misses - the timestamp, and the order of project items (which will normally have newly-added items at the bottom, out of alphabetical order). Unfortunately, I haven't found a way to handle breakpoints - probably the easiest way to get rid of those would be applying an XSLT to the file after it's been exported, which is pretty bad. Method OnAfterSave(InternalName As %String, Object As %RegisteredObject) As %Status { Set tFileName = ..ExternalName(InternalName) If tFileName = "" { Quit $$$OK } Set tName = $Piece(InternalName,".",1,*-1) Set tExt = $ZConvert($Piece(InternalName,".",*),"U") // Special handling for projects to ensure that newly-added items don't show up at the bottom of the XML export. // This tends to cause meaningless diffs (at best) and conflicts (at worst) If (tExt = "PRJ") { Set tProject = ##class(%Studio.Project).%OpenId(tName,,.tSC) If $IsObject(tProject) { // Save the project for real (we'll be in %OnAfterSave for the project when this happens, // but %Studio.SourceControl.Interface protects against <FRAMESTACK> by moving %SourceControl // to tmp, so this should be perfectly fine). // If the project is not saved, the items will be in the wrong order. If tProject.%Save() { // Reload the project. We need to save first to be sure all ProjectItem changes are commited. // This will load them up freshly, in the normal order. Do tProject.%Reload() } // Clear a few properties, since /diffexport won't be respected. // This won't actually be saved, but these things shouldn't be in the export to disk. Set tProject.LastModified = "" Set tProject.Target = "" Set tProject.TargetType = "" } } Quit ##super(.InternalName,.Object) }
go to post Timothy Leavitt · Apr 11, 2017 If you're looking to add RegEx-based validation to a property, see this post. If you're looking to do RegEx matching in a query... I don't think there's a built in function for this (!), but it's easy enough to do in a stored procedure: ClassMethod MatchesRegEx(pText As %String, pRegEx As %String) As %Boolean [ SqlProc ] { Quit $Match(pText,pRegEx) }
go to post Timothy Leavitt · Apr 10, 2017 See class documentation for Security.Applications. Example: Class DC.Demo.DeepSeeEnable { ClassMethod SetDSFlag(pApplicationName As %String, pValue As %Boolean = 1) As %Status { Set tSC = $$$OK Try { New $Namespace Set $Namespace = "%SYS" Set tApplication = ##class(Security.Applications).%OpenId(pApplicationName,,.tSC) If $$$ISERR(tSC) { Quit } Set tApplication.DeepSeeEnabled = pValue Set tSC = tApplication.%Save() } Catch e { Set tSC = e.AsStatus() } Quit tSC } } Use: USER>s sc = ##class(DC.Demo.DeepSeeEnable).SetDSFlag("/csp/user",1) USER>w sc 1