Perspective Comments Panel

Hi all,

My implementation of a Comments Panel component in Perspective is now live on the exchange!

I wanted to create a thread so that people can yell at me for my silly implementation provide feedback or information others might find helpful (since I didn’t have an opportunity to test it out with different databases or versions of Ignition on this initial version).

I hope you find it useful. Happy developing!

7 Likes

Hi Daniel,

I get an error that global library “Java” not found. Have you encountered this error before?

Do you know how it can be fixed?

Thanks,

Sorry for missing this for so long, guess I need to get back in the habit of checking the forums! :grimacing:

I can’t say I’ve seen this error, no. Can you give me more details on what’s going wrong, and where?

  • What version of Ignition are you using?
  • Which component(s) are giving the error? Which script(s)?

I need to be able to reproduce the error, ideally.

Hi Daniel,

I tried this on v8.0.5 and v8.0.13.

This is the error I get :

Error running action ‘component.onActionPerformed’ on Components/Comments Panel@D$0:1/root/New Note/FlexContainer/Button: Traceback (most recent call last): File " ", line 24, in runAction NameError: global name ‘java’ is not defined

********** Full Error ************

com.inductiveautomation.ignition.common.script.JythonExecException
Traceback (most recent call last):
File “function:runAction”, line 24, in runAction
NameError: global name ‘java’ is not defined

at org.python.core.Py.NameError(Py.java:290)
at org.python.core.PyFrame.getglobal(PyFrame.java:265)
at org.python.pycode._pyx333.runAction$1(<function:runAction>:41)
at org.python.pycode._pyx333.call_function(<function:runAction>)
at org.python.core.PyTableCode.call(PyTableCode.java:171)
at org.python.core.PyBaseCode.call(PyBaseCode.java:308)
at org.python.core.PyFunction.function___call__(PyFunction.java:471)
at org.python.core.PyFunction.__call__(PyFunction.java:466)
at org.python.core.PyFunction.__call__(PyFunction.java:456)
at org.python.core.PyFunction.__call__(PyFunction.java:451)
at com.inductiveautomation.ignition.common.script.ScriptManager.runFunction(ScriptManager.java:788)
at com.inductiveautomation.ignition.common.script.ScriptManager$ScriptFunctionImpl.invoke(ScriptManager.java:917)
at com.inductiveautomation.ignition.gateway.project.ProjectScriptLifecycle$AutoRecompilingScriptFunction.invoke(ProjectScriptLifecycle.java:625)
at com.inductiveautomation.perspective.gateway.script.ScriptFunctionHelper.invoke(ScriptFunctionHelper.java:91)
at com.inductiveautomation.perspective.gateway.action.ScriptAction.runAction(ScriptAction.java:71)
at com.inductiveautomation.perspective.gateway.model.ActionCollection$ActionSequence$ExecuteActionsTask.lambda$call$0(ActionCollection.java:263)
at com.inductiveautomation.perspective.gateway.api.LoggingContext.mdc(LoggingContext.java:54)
at com.inductiveautomation.perspective.gateway.model.ActionCollection$ActionSequence$ExecuteActionsTask.call(ActionCollection.java:252)
at com.inductiveautomation.perspective.gateway.model.ActionCollection$ActionSequence$ExecuteActionsTask.call(ActionCollection.java:221)
at com.inductiveautomation.perspective.gateway.threading.BlockingTaskQueue$TaskWrapper.run(BlockingTaskQueue.java:154)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.base/java.lang.Thread.run(Unknown Source)

Caused by: org.python.core.PyException
Traceback (most recent call last):
File “function:runAction”, line 24, in runAction
NameError: global name ‘java’ is not defined

... 25 more

Ignition v8.0.5 (b2019101516)
Java: Azul Systems, Inc. 11.0.4

Did you read and follow the setup instructions? I think this is a database error because you might not have the necessary tables and/or named query in your project–this is not an out-of-the-box usable component. To save you some searching, here’s the instructions copy-pasted from the Exchange:

  • After importing all of the resources, open the Comments Panel view and look under it’s custom properties for one called projectName. Set the value of projectName to the name of your project (look at your designer’s titlebar if you don’t remember). This is used within several system.db.runNamedQuery() calls since Perspective operates within the gateway scope.

  • Look under your project’s Named Queries for a Comments Panel folder. Run the CreateCommentsTable query somewhere to create the table that your Comments Panels will use to store and retrieve comments (if your database version is unlisted, just use the two given queries as guidelines to write your own–disclaimer, the MySQL one is untested, but it should work).

  • Voila! Setup is complete. You can test out your comments panel in the designer and ensure the queries for saving, editing, and deleting comments work. I have not performed any testing on database besides SQL Server, so you may run into some issues–nevertheless, it should be faster to debug than to create your own implementation from scratch (ideally).

  • After ensuring the database queries work, use Embedded View components to put comments panels wherever you need them (keeping the width around 375px or so for best out-of-the-box results). Be sure you give each comment panel a unique “id” parameter or they will display the same comments.

Hi @kirsten.chambers

I did follow the setup instructions.

I have entered projectName as mentioned in the instructions and the database table has also been created as mentioned in the instructions.

After going through the setup instructions I placed all the components into a view as follows :slight_smile:

@kirsten.chambers I get the error when I click on Save after having typed something into the notes.

hi folks - I tried out the comments panel but didn’t end up using it in my initial project. Didn’t remember having issues there. I’m using it for something else now, and @omairapril the issue you might be having is that you have a non-numeric number as part of the ID.

I’m having some height scaling issues now kirsten that I didn’t remember having previously when I used this. component width is 375px - maybe an 8.1 thing? Doubtful, probably a me thing.

I have the exact same issue as omairapril

It should be noted i am using the untested MySQL version

i was digging around in the button and noticed this is a little different? but messing around with it didn’t fix anything

in the onactionperformed the other strings have the str() , like the str(note) and the str(userName) before them but the attach one doesn’t , does this matter?

im kind of just shooting in the dark I dont really understand what is doing what here

It’s a good guess, since the system.db functions are very particular about the parameters, but you’ll notice on line 15 I am calling str() on attach so that shouldn’t be the issue.

The think the problem lies in the table. In the MySQL version for creating the table, I seem to have accidentally misnamed one of the columns, which is causing inserting to fail.

Here’s the updated MySQL version of the Comments Panel/CreateCommentsTable query. I’ll push it to the exchange in a bit as well:

CREATE TABLE PerspectiveComments (
	id INT NOT NULL AUTO_INCREMENT,
	attachmentType VARCHAR(5), -- here's where the error was; it was named 'attachment' instead of 'attachmentType'
	note VARCHAR(500),
	panelId INT NOT NULL,
	sticky BIT,
	tStamp DATETIME,
	userName VARCHAR(50),
	PRIMARY KEY (id) );

You can just edit the PerspectiveComments table and rename that column, then hopefully the issue should be resolved.

I changed that to match yours since it will probably help , but its still giving that error

is the INSERT INTO in the InsertComment named query supposed to be attachment or attachmentType? also is the name of the parameter in that named query supposed to be attachment or attachmentType?

Apologies for not making it clear.

Run this instead, @IgnitionNewbie:

ALTER TABLE PerspectiveComments RENAME COLUMN attachment TO attachmentType;

This will rename the old column named attachment into attachmentType. Changing this query, which is run only once during the setup of the comments panel, won’t do anything on its own.

Also, it appears that you have a parameter “attachment” defined, but you are attempting to use “:attatch” in the query.

That’s not how the query originally was–good catch. @IgnitionNewbie be sure to change the InsertComment query that back to how it originally was, including the parameters. Here it is:

INSERT INTO PerspectiveComments(note, panelId, sticky, tStamp, userName, attachmentType)
OUTPUT INSERTED.id
VALUES (:note, :panelId, :sticky, :tStamp, :userName, :attachmentType);

alright i finally was free to try that, still no dice , will keep looking

i see in the get comments my attachmentType is attachment as well , but that didnt fix it either

I think I finally found the problem–it’s in the InsertComment query. There’s an MS SQL-specific statement that I used that doesn’t work in MySQL.

I’m not 100% sure this replacement will work, but it’s worth a try. Try replacing the InsertComment query with the following:

-- MySQL ver
INSERT INTO PerspectiveComments(note, panelId, sticky, tStamp, userName, attachmentType)
VALUES (:note, :panelId, :sticky, :tStamp, :userName, :attachmentType);
SELECT LAST_INSERT_ID();

The goal is to output the ID of the last inserted row from the query. If this solution doesn’t work hopefully this helps point you in the right direction, at least.

Fwiw theres an arg to try to return the row ids updated from the runPrepUpdate function, although there's a caution that not all DB's support it. Can't tell you what arg it is atm as docs are offline