then always this error occures:
Failed to execute Action “Script”: addComment: Cannot add collection items to readonly comment/author field for comments/comment database.
Do I have to create an comment entity first like descripted in API docu?
if yes what kind of values do I have to set and so on? There is not much to find in script docu.
Sure this works fine and also GraphQL would be an option, but it would be a bigger workaround. The script fibery function provides the addComment, but I doesn’t understand how it should work.
PS: I think it’s sending two notifications if you set authorID. One by fibery ghost and one by authorId mention. if authorID = “” it’s only the ghost thats cool.
await fibery.addComment("Workflows/WTask", // comments enabled on DB
"7f6f1e90-835d-11ee-9610-37ed00f0ca21",
`😁Good news everyone!\n blah blah...`,
"f13af52d-dea3-40af-83dc-b41876015c00", // User Id
"md")
This error is thrown:
getEntityById: null field is not a collection. Expr: {"v":["comments/parent"]}.
Oh wow. Works perfectly for me.
Can you please share a script or part of it, that doesn’t work?
What does this method return for you? (It should return Id of created comment).
My looking through codebase does not show risky places. It creates comment and links it to entity via batch command. Then it sets a text to a created comment. If anything fails you should get exception.
Maybe you catch and swallow some errors in your script code?
It is odd… the code works for one type, but not for a different type.
This is the entire test Button code:
///// This works correctly for the WAction type:
// const type = 'Workflows/WAction'
// const id = 'cb123770-9ed7-11ee-9b81-213a7b82dfc6' // "On State=Open" (43)
///// For the WTask Type: it "appears" to work, but then there is no comment on the entity:
// NOTE this entity already has one RESOLVED comment.
const type = 'Workflows/WTask'
const id = '7f6f1e90-835d-11ee-9610-37ed00f0ca21' // "Proof Page" (5)
const result = await fibery.addComment(type, id, "😁Good news everyone! #3", userId, "md")
console.log(result)
For WTask (failure case), it logs this result, which looks correct:
But when I check the entity, there is no new comment on it – only the older resolved one.
UPDATE:
Weirdness: I was looking for the API-created comments in the new Comments sidebar (via the button at the top-right of entity view), and I was not seeing any new comments there, after creating many.
But after I opened (unfolded) the older “Comments field” in the same entity view, now suddenly I can see all the missing comments in both places.
So now I understand that entity comments do not appear in the Comments sidebar when the older entity Comments area is closed/minimized/folded.