Hello, I encountered a similar issue but managed to resolve it.

If you were connected directly to the server-side folders, try the following steps: 
1. Click: View -> Command Palette -> Open Workspace Settings (JSON) 

2. In the "folders" property of the JSON you should see something like: 

"folders": [
	{
		"name": "<server_folder_name>:<namespace>",
		"uri": "isfs://<server_name>:<namespace>/"
	}
]
ObjectScript
ObjectScript

3. Try replacing the old one with the new one. 

If you were working on a local folder that was connected to a server, you should have a .vscode folder in your VSC workspace.

1. Try editing the settings.json file inside the folder. You should see something similar to: 

"objectscript.conn": {
    "server": "<server name>",
    "ns": "<namespace name>",
    "active": true
}
ObjectScript
ObjectScript

2. Edit the connection with the name of the server you want to reach

Hi Muhammad, great article! 

Do you know by chance how to switch from an instance to another through the ObjectScript extension? 

I have a local folder where I'm setting up a Docker instance, but the folder is linked to my IRIS local instance and it is not possible to unlink them even by doing Toggle connection or Refresh connection. Of course, I would like to connect to my containerized instance instead. 

Thanks :) 

Hi, you can try something like this: 

Set sc = $$$OK
// Send a GET request
Set messageStatus = httpRequest.Get()

// Analyze response code
If '($$$ISERR(messageStatus)) {
    If httpRequest.HttpResponse.StatusCode = 200 {
        // If a positive response was received 
        // ...
        // ...
    } ElseIf httpRequest.HttpResponse.StatusCode = 404 {
        // Manage an HTTP status error
        // ...
        // ...
        // If you want a custom error status
        Set ErrorText = "This is a string that contains your custom error text"
        Set sc = $$$ERROR(ErrorCode, ErrorText)
    } Else {
        // You can manage other HTTP codes here
    } 
} Else {
    If '($ISOBJECT(httpRequest.HttpResponse.StatusCode)){
        // Manage an error raised if the endpoint couldn't be reached or if you didn't get a response in time
        // ...
        // ...
        Set ErrorText = "This is a string that contains your custom error text"
        Set sc = $$$ERROR(ErrorCode, ErrorText)
    }
}

Return sc
ObjectScript
ObjectScript

You can manage any status code in the way you prefer (not just code 200 or 404) 

I know that answering a question and providing your own response may seem unusual, but I won't delete this question as it could be helpful to someone in the future.

The issue was related to the method "jsonFormatter.FormatToStream", which returned "ByRef" a pStream object that, for some reason, Postman and the other client software didn't handle well. 

A solution is to remove the jsonFormatter and to pass directly the OriginalStream to the function:

Set pResponse = ##class(EnsLib.HTTP.GenericMessage).%New(OriginalStream,,tHttpResponse)
ObjectScript
ObjectScript

If you prefer to keep the JSONFormatter, just declare the pStream as an object of %Stream.FileCharacter class before using the FormatToStream method:

// Format the newJson with the correct indentation
Set jsonFormatter = ##class(%JSON.Formatter).%New()
// Declare a new stream object
Set pStream = ##class(%Stream.FileCharacter).%New()
Set sc = jsonFormatter.FormatToStream(jsonACK, .pStream)
ObjectScript
ObjectScript

Now everything works fine.

I don't know if this can help, but in objectscript the command to extract some elements from a list is the following: 

SELECT * FROM <tableName> WHERE FOR SOME %ELEMENT (<listName>) (%VALUE = '<value>')

For example, if you have a persistent class like this: 

Class User.SQLtable Extends %Persistent
{
    Property propertyList As list Of %String(MAXLEN = 100) [ Required ];
    Index ListIdx On List(ELEMENTS);
}
ObjectScript
ObjectScript

You can extract information using: 
SELECT * FROM User.SQLtable WHERE FOR SOME %ELEMENT (propertyList) (%VALUE = '67')

In this way you can retrieve the row that contains the specific data value of interest with dynamic or static SQL and subsequently extract the list as a property of the SQL result object

Hi Enrico,

Thank you for the response. I've tried both adding an OnFailureTimeout method in my custom BO and directly modifying the OnFailureTimeout method inside the Ens.BusinessOperation. However, in the first case, nothing happens, while in the second case, the error "ERROR #5883: Item 'Ens.BusinessOperation' is mapped from a database that you do not have write permission on" occurs

 

Hi Ashok,

Thank you for your response. As I said to Ian, maybe I expressed wrong and I apologize for any confusion, but I did not intend to start a new line within the log that is printed in the Visual Trace. Instead, I wanted to start a new line within VSC in order to avoid writing long one-line logs in the visual interface of VSC.

For example, I am looking for a way to transform this line of code:

$$$LOGINFO("this is the first line "_$c(13,10)_"this is second line"_$c(13,10)_" this is third line")
ObjectScript
ObjectScript

 Into something like that, to improve code readability: 

$$$LOGINFO("this is the first line "
            _$c(13,10)_"this is second line"
            _$c(13,10)_" this is third line")
ObjectScript
ObjectScript

Hi Ian,

Thank you for your response. Maybe I expressed wrong and I apologize for any confusion, but I did not intend to start a new line within the log that is printed in the Visual Trace. Instead, I wanted to start a new line within VSC in order to avoid writing long one-line logs in the visual interface of VSC.

For example, I am looking for a way to transform this line of code:

$$$LOGINFO("this is the first line "_$c(13,10)_"this is second line"_$c(13,10)_" this is third line")
ObjectScript
ObjectScript

 Into something like that, to improve code readability: 

$$$LOGINFO("this is the first line "
            _$c(13,10)_"this is second line"
            _$c(13,10)_" this is third line")
ObjectScript
ObjectScript