Create Note using shotgun-api

When you create a note using the shotgun-api, it doesn’t show up in either the Activity or the InBox.
Code responsible for creating a note:
d_arg = {
“project”: {“type”:“Project”, “id”:452},
“note_links”: [{“type”:“Shot”, “id”:2133}, {“id”:17148, “type”:“Version”}],
“subject”: “Rendering Farm”,
“content”: “…”,
“user”: {“type”: “ApiUser”, “id”: 93},
“addressings_to”: [{“id”:90, “type”:“HumanUser”},{“id”:91, “type”:“HumanUser”}],
“tasks”:[{“type”:“Task”,“id”:8473}],
“sg_note_type”:“Internal”,
}
sg.create(“Note”, d_arg)

When someone replies to a given Note, it appears in the Activity. But the Note is not displayed in the Inbox.

Is there a way to force the display of the note in the Activity and Inbox?
Maybe there is another way to notify about the work of the script?

The custom field change also doesn’t show up in the Actions and Inbox folders, but I’m “Follower” of tasks.

Same issue here. I’ve raised a ticket and they are investigating. I’d raise a ticket and mention my name so they link the reports. patrick@reformstudios.com.
Thanks
p.

1 Like

Could it possibly be because you are explicitly setting the user as “api user”?

Seems to be working fine here, note appears in inbox. We set fewer fields:

shotgun.create(
        "Note",
        {
            "sg_assigned_to": users[0],
            "addressings_to": users,
            "sg_status_list": "todo",
            "content": note_text,
            "subject": subject,
            "project": project_fields
        })

Could it have to do with the status?

Replaced this parameter and did not install it at all. does not affect the result

did not affect in any way

1 Like

mmoshev : What’s your shotgun instance authenticated as? Script or user? (sorry to double check :slight_smile: )
eg the shotgun of shotgun.create

Also, it may appear in your inbox, but can you confirm that it also appears in the “activity” of the associated Task ?
You appear to be creating a note associated with any entity (just project level). Try again with note_links field defined.

Alert in Activity and InBox only worked if executed under HumanUser using auth_token:
sg = shotgun_api3.Shotgun(
https://terminal-fx.shotgunstudio.com/”,
login=“Ivan”,
password=“Password123”,
auth_token=“dff4f58df5g4gdf8gfd45gdf6g64dfg4dfgsfewfdsf4dsf4fgh4fdh64fg46rewg4reg4f64”
)

Failed to notify this user, Ivan. All notifications created by him and sent to him (addressings_to = Ivan) are not displayed in the InBox. Because of this, I have to pay for an additional user to send messages to all users!

ヾ(`ヘ´)ノ゙

Hey, I know this discussion is from a while ago, I had the same problem and I was able to solve it. On the scripts page in shotgrid there is a field called Generate Events and I needed to have that checked on for my scripts.

Apparently it’s suppose to be on by default (or so it says when I hover over the header), but it has been defaulting to off for all of the new scripts I create.

Hope this helps someone!

2 Likes

Thanks for sharing Paulette!

I cannot provide full code because I have written complete abstraction layer for shotgrid database access.

but this is essentially it:

# optional
attachment = 'c:/temp/cat_image.jpg' # either {type,id} entity or string path, or empty list

note_data = {
            'note_links': [ {'type': entity_type, 'id':id }], # can be empty list, but addressings_to must be provided # 'Shot' and 'id' of some shot, or any other valid entity type
            'subject': subject, # str
            'sg_note_type': 'Internal',
            'content': content, # formatted str, cannot be html formated unfortunately
            'user': {'type': user['type'], 'id':user['id']}, # who sent it... apiKey token user from shotgrid_db access method  will be used if user is not provided
            'addressings_to': recipient, # may be list of humanUser entities or empty list
            'project': {'type':'Project', 'id':project_id},
            }

shotgrid_db = some method to instantiate SG DB access


ret = shotgrid_db.create('Note', note_data)
if ret:
    if attachment :
        up_ret = shotgrid_db.upload( 'Note', ret['id'], attachment, field_name='image')