Post

2 followers Follow
0
Avatar

How to call a custom action through the api

I am trying to send an external message to a user through the api. I have the Session ID for this user and was hoping that I do not need to specify this other than in the header as login credential. I want only this user to see this message.

I read below post, but cannot figure out how to make it work.
https://success.clarizen.com/hc/en-us/community/posts/208138257-using-the-executeCustomAction-API

Below call only tries to run the custom action (no parameters), but that does not work.
The name of the custom action is DisplayErrorMessageFromAPI.

curl -H "Authorization: Session 199a00bf-cef7-XXXX-9258-51ae455a6964_ZZZZZ" https://api.clarizentb.com/V2.0/services/data/executeCustomAction -d "{'customAction': 'DisplayErrorMessageFromAPI'}"

Error message: No item was selected

If someone knows how to do this, then please also let me know how to pass text to a custom action for display in a pop up to a user.

 

Mattias Hallberg Answered

Please sign in to leave a comment.

4 comments

0
Avatar

Hi Mattias,

In the post you referenced, a parameter named targetId was sent as a part of the request. I believe this represents the custom action's target object to run on (in the Clarizen UI custom actions usually run on a specific object). 

I'm not sure if a target is required when the Custom Action is called via the API, so the below may or may not work:

Custom actions can be marked as available with no item selected. If you don't need to run the custom action on a specific object as an input (for currentObject()) perhaps marking the custom action as available with no selected object could also help. See screenshot:

Hope this helps,

Ophir

Ophir Kenig 0 votes
Comment actions Permalink
0
Avatar

Hi Ophir

 

I have attached the custom action below.

It runs on Project work item and has no such setting.

 

Mattias Hallberg 0 votes
Comment actions Permalink
0
Avatar

Hi Mattias,

Click on Advanced below Error notifications to show the settings I mentioned.

Hope this helps,

Ophir

Ophir Kenig 0 votes
Comment actions Permalink
0
Avatar

Thanks

I got it to work, but it was not due to the advanced setting.

Below setup works with this command

 

curl -H "Authorization: Session 2fe27cb3-abc-42a0-def-d33f072ghij_1234567" https://api.clarizentb.com/V2.0/services/data/executeCustomAction -d "{'targetId': '/User/ererererkboww6slxy1tt0cchu3','customAction': 'DisplayErrorMessageFromAPI2User', 'values': [{'fieldName':'NotificationTitle', 'value': 'My Notification Title Text'},{'fieldName':'NotificationBody', 'value': 'Notification Body My Text'},{'fieldName': 'User', 'value': '/User/ererererkboww6slxy1tt0cchu3'}]}"

Mattias Hallberg 0 votes
Comment actions Permalink