7

I have a custom object and under Buttons, Links and Actions section I have several Actions created. Now I would like to retrieve somehow the Actions related to my custom object via code.

I was looking for an object that I can query like ApexPage but I didn't find anything with the word Action. Also I tried through the SObjectType.getDescribe(), but no luck either.

Any advice?

1
  • 2
    Can't find specific documentation at the moment, but I believe you cannot do this via Apex. Jul 8, 2014 at 14:59

3 Answers 3

5

You can query the rather misleadingly named WebLink SObject to find all of the information you need about a custom button:

Select Width, Url, SystemModstamp, ShowsStatus, ShowsLocation, ScontrolId, 
RequireRowSelection, Position, PageOrSobjectType, OpenType, NamespacePrefix, Name,
MasterLabel, LinkType, LastModifiedDate, LastModifiedById, IsResizable, 
IsProtected, Id, Height, HasToolbar, HasScrollbars, HasMenubar, EncodingKey, 
DisplayType, Description, CreatedDate, CreatedById 
From WebLink
Where PageOrSObjectType = 'ObjectOfInterest__c';

Edit: these aren't the droids you are looking for....this will only return information about Buttons and Links, but alas not Actions. :(

3
  • 1
    Woah, did not no that was available, awesome find!! Jul 8, 2014 at 21:53
  • That is a fantastic idea!! Unfortunately it returns just information about Buttons but nothing related to Actions. Lets ask Salesforce :) Jul 9, 2014 at 7:13
  • Ah, sorry - I should have read the question more carefully :( Jul 9, 2014 at 7:49
3

After raising a case, Salesforce confirms that for now, it is not possible to do it via Apex. I have posted an idea, so maybe in the future we can find it on WebLink or any other place.

0
1

You can do this with the QuickAction.describeAvailableQuickActions() method:

// Called for Account object
List<QuickAction.DescribeAvailableQuickActionResult> result1 = QuickAction.DescribeAvailableQuickActions('Account');  

// Global actions (as they appear on the Chatter or Home tab)
List<QuickAction.DescribeAvailableQuickActionResult> result2 = QuickAction.DescribeAvailableQuickActions('Global');  

Here's the documentation for the QuickAction class.

Note it returns actions that are available in the Publisher Actions section of the page layout based on the profile/record type, not all possible actions.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .