go to post Ashok Kumar · Aug 24, 2023 Exactly. Thanks for the samples. This will helps to figure out the property is modified or not.
go to post Ashok Kumar · Aug 24, 2023 As we mentioned above the DOB should have +$H value instead of MM/DD/YYYY. However you can try the below If DOB is date format IRISMYDEV>set dob="12/01/1993" IRISMYDEV>write $translate($ZDT($ZDTH(dob),3)," ","T")_"Z" 1993-12-01T00:00:00Z If DOB is +$H value IRISMYDEV>set dob=+$H IRISMYDEV>write $translate($ZDT(d_",00000",3)," ","T")_"Z" 2023-08-24T00:00:00Z
go to post Ashok Kumar · Aug 23, 2023 Hello Scott, I had created ZAUTHENTICATE.mac in %SYS namespace. Implemented the GetCredentials and validated the authentication for delegated user. It works for me without any issues.
go to post Ashok Kumar · Aug 23, 2023 Hello @Joel Solon The %ValidateObject() method is used to validate the property. Not to find out the property is modified in the opened object IRISMYDEV>set obj = ##Class(Samples.NewClass2).%OpenId(1) IRISMYDEV>write obj.Name Test IRISMYDEV>zwrite obj.%ValidateObject() 1 IRISMYDEV>set obj.Name="newname" IRISMYDEV>zwrite obj.%ValidateObject() 1 m%_Property is used to verify whether the property is modified before save. Incase If we need to verify Class Samples.NewClass2 Extends %Persistent { Property Name As %String; Method modified() { write "Property modifed : ",$Property(,"m%Name") } } IRISMYDEV>set obj = ##Class(Samples.NewClass2).%OpenId(1) IRISMYDEV>do obj.modified() Property modifed : 0 IRISMYDEV>set obj.Name="test" IRISMYDEV>do obj.modified() Property modifed : 1 IRISMYDEV> I hope, we don't have any built in method like "propertyIsModified" to verify the property is modified
go to post Ashok Kumar · Aug 23, 2023 Hello Smythe, I agree with @Robert Cemper points. The %Date datatype is for +$H which means numeric date value. Not an string. You should modify the datatype of the property or use string functions. IRISMYDEV>s obj = ##Class(CSVtoHL7.Inputfile.Record).%New() IRISMYDEV>s obj.DOB="12/12/1993" IRISMYDEV>zw ##Class(%Date).IsValid(obj.DOB) "0 "_$lb($lb(7207,"12/12/1993",,,,,,,,$lb(,"IRISMYDEV",$lb("e^IsValid+1^%Library.Date.1^1","e^^^0"))))/* ERROR #7207: Datatype value '12/12/1993' is not a valid number */ IRISMYDEV>w $SYSTEM.OBJ.DisplayError() ERROR #7207: Datatype value '12/12/1993' is not a valid number1 IRISMYDEV>s obj = ##Class(CSVtoHL7.Inputfile.Record).%New() IRISMYDEV>s obj.DOB=$ZDateH("12/12/1993") IRISMYDEV>zw ##Class(%Date).IsValid(obj.DOB) 1
go to post Ashok Kumar · Aug 21, 2023 Hello Pierre, No problem. You can use the merge command(sorry not a string function) to take a copy of entire global node and subtree merge queryparam = %request.Data zwrite queryparam ;print the entire node and subtree
go to post Ashok Kumar · Aug 20, 2023 Nice article. However, there is a minor problem while setting the trailing zero values in %Set() of dynamicobject. But, It's not happening in literal constructor {} syntax. Due to objectscript not keep the trailing zeros. But json number do. set json = { "decimal": 12.000} zw json set json1= ##Class(%DynamicObject).%New() do json1.%Set("decimal", 12.000) ; this is consider as string do json1.%Set("decimal1", $FN(12,,2), "number") zw json1 #;output json={"decimal":12.000} ; <DYNAMIC OBJECT> json1={"decimal":12,"decimal1":12} ; <DYNAMIC OBJECT>
go to post Ashok Kumar · Aug 20, 2023 Hello Pierre, You have two options to get query parameters You can merge the entire %request.Data into local array and use string function. User %request.Next(data) method to loop the %request.Data one by one and get query parameter values ClassMethod GetQueryParams() { set data="" For { set data = %request.Next(data) quit:data="" write data,! } } OUTPUT Bottom Name Top For cgiEnvs. You can follow same merge option to get all values. Otherwise use %request.NextCgiEnv(cgi) to get the list of available values. ClassMethod GetcgiEnvs() { set cgi="" for { set cgi = %request.NextCgiEnv(cgi) quit:cgi="" write cgi,! } }
go to post Ashok Kumar · Aug 18, 2023 Hello @ARTHUR L A SILVA You create a your custom task and schedule this task in task manager if it's required. Follow the below steps to schedule the task. Create a new class definition with extends of %SYS.Task.Definition. Override the OnTask() method and necessary logic inside the method Goto System Management portal > System Operation>Task Manager>NewTask Add unique task name Select namespace Assign the task type ( which is your class definition) Select output file when task running Provide your ouputfile.csv in the output file schedule the execution date and time. Finish the task Class Samples.TaskMgr.SQLExportTask Extends %SYS.Task.Definition { Parameter TaskName As STRING = "ExportQueryToCSV"; Method OnTask() As %Status { set statement = ##class(%SQL.Statement).%New() /// Place your sql query set sql = "Select Name,dob,Phone From Samples_DB.Person" set tSC = statement.%Prepare(sql) if $$$ISERR(tSC) Q $$$OK set result = statement.%Execute() #dim meta As %SQL.StatementMetadata= result.%GetMetadata() for i=1:1:meta.columnCount { if i>1 w "," write meta.columns.GetAt(i).colName } write $$$NL while result.%Next() { write result.Name,",",result.dob,",",result.Phone,$$$NL } return $$$OK } } Task scheduler
go to post Ashok Kumar · Aug 16, 2023 Hi @Sakthivel Perumal Can you try the below sample to download file from the directory Class Samples.CSPFileDownload Extends %CSP.Page { Parameter CONTENTTYPE As STRING = "application/text"; ClassMethod OnPage() As %Status { do %stream.OutputToDevice() return $$$OK } ClassMethod OnPreHTTP() As %Boolean { #; your directory and file set file="C:\Users\readmyfile.txt" set stream=##class(%Stream.FileCharacter).%New() set sc=stream.LinkToFile(file) set %stream = stream set %response.ContentType = ..#CONTENTTYPE set %fileName = file set %response.ContentLength=stream.Size return $$$OK } }
go to post Ashok Kumar · Aug 15, 2023 Hello @Elijah Cotterrell Thanks for the suggestion, I need to verify whether the property is modified while saving for opened object and Generally I do some verification with the mentioned piece of code. So, I thought to generate a method like getter and setter method in some cases. Class Samples.Person Extends %Persistent { Property Name As %String; Property Age As %String; ClassMethod ValidateObject() { Set obj =##Class(Sample.Person).%OpenId(1) w "before: ",obj.PropertyIsModified("Age"),! Set obj.Age=12 Write "after: ",obj.PropertyIsModified("Age"),! } Method PropertyIsModified(Property) { Return $Select(Property'="":$Property($THIS,"m%"_Property), 1:0) } }
go to post Ashok Kumar · Aug 14, 2023 Hello @Eduard Lebedyuk Thanks for the samples.Creating my own datatype and implementation is works for me.
go to post Ashok Kumar · Aug 13, 2023 Hi @Steven Hobbs Thanks for the wonderful explanation with samples. It make sense
go to post Ashok Kumar · Aug 11, 2023 Hi Pierre Can you try with below. And try Create a subclass of %CSP.SessionEvents and try override OnStartRequest, OnEndRequest . ClassMethod Page(skipheader As %Boolean = 1) As %Status [ ProcedureBlock = 0 ] { set ^Pierre("login")="on login (by overrided method Page)" return ##super(skipheader) }
go to post Ashok Kumar · Aug 11, 2023 Thanks Vitaliy for the suggestion, %ScrollableResultSet is works for the Cache SQL. We are actually fetching multiple Resultsets and not working as expected for language=tsql. ClassMethod tt() [ Language = tsql, SqlName = mycls, SqlProc ] { SELECT Name FROM sample_SQL.NewClass4 SELECT Name, Age FROM sample_SQL.NewClass5 } set results=##class(%ScrollableResultSet).%New() set tsc = results.Prepare("call sample_SQL.MYCLS()") if $$$ISERR(tsc) W $SYSTEM.OBJ.DisplayError(tsc) do results.Execute() ERROR #6048: Invalid Statement Type: 'CALL'1
go to post Ashok Kumar · Aug 11, 2023 Hello Pierre, You can Override the method OnPreDispatch from the %CSP.REST in your dispatcher class and capture your user connect information in application log. ClassMethod OnPreDispatch(pUrl As %String, pMethod As %String, ByRef pContinue As %Boolean) As %Status { set ^Pierre(pUrl)="" /// your implementation return $$$OK }
go to post Ashok Kumar · Aug 10, 2023 If you're receiving unexpected fields(key value pairs) as part of the JSON and the properties are not included in the class definition. You need to add the below parameter in your class definition(%JSON.Adaptor extended class). This will ignore loading the unexpected field. Parameter %JSONIGNOREINVALIDFIELD As BOOLEAN = 1 In addition, The JSON key-value pair data type should match with class definition property datatype.
go to post Ashok Kumar · Aug 10, 2023 Hello Scott, As of m understanding, If your dynObject is actually the expected JSON format. Create a instance for class response class and load the dynObject into object by method obj.%JSONImport(dynObject)