How do I add a comment via Script automation?

I tried:

await fibery.addComment("space/dataSource", entity["Id"], "someting", automationUserId, "md")

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.

Using the no-code interface, you can do this:

Also the GraphQL interface has an “AddCommentInput” mutation, but I do not have any more info on it. Maybe @Oleg can help here?

1 Like

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.

Hi, @Lug-gl

Looks like it is a bug. We will fix it in nearest future.

Thanks,
Oleg

2 Likes

ah ok thank you!

That was a bug on our side indeed. Issue is fixed an deployed.
Please write here if there are still any problems with that api.

2 Likes

@Sergey_Truhtanov
Thank you!

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.

@Oleg, I am seeing an error from addComment()

When I call:

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"]}. 

:question:

Hello.
This was a regression from our side. Fixed and deployed, should work fine now.
Sorry for inconvenience.

1 Like

@Sergey_Truhtanov, I am not getting any errors, but await fibery.addComment() is not creating a new comment.

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:

{
  Author: { Id: 'f13af52d-dea3-40af-83dc-b41876015c00', Name: 'Matt B' },
  Id: 'd71c8650-e8d2-4229-8b08-fa347d46a916',
  'Public Id': '44',
  Parent: { Id: null, 'Document Secret': null },
  'Document Secret': '90d022b3-2c54-43ea-8c73-d345780b5b6c',
  'Creation Date': '2024-01-03T16:55:56.450Z'
}

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. :confused:

So now I understand that entity comments do not appear in the Comments sidebar when the older entity Comments area is closed/minimized/folded.

1 Like

Yep, that’s a current issue with our Comments panel :frowning:

1 Like