Custom Buttons
Spring 2019 NOTE: we recommend that you use SFDC Quick Actions, but PSL custom buttons will continue to be supported.
Overview
Some admins have setup custom buttons backed by Apex code to accommodate a Salesforce work flow. For example, a custom button click would create an object with certain fields already filled in from the values found in the current object. Pulsar also supports defining custom buttons using Pulsar Settings and the Pulsar Settings Language (PSL).Â
Here are some of the actions supported within PSL that can be used for custom button actions:
Alert: Will show a pop-up dialogue with the appropriate message for the user.
Display: Another Salesforce object.
Create: Create a new object of type you specify.
CreateAndMapFields: Create a new object with fields already populated from the current object.
SetField: Set a particular field within the current object.Â
SetLocation: Set a particular Geolocation field within the current object.Â
CloneRecentObject: Create and clone the data from the most recent object in the list.
CloneCurrentObject: Create and clone the current object.
See the documentation for PSL for more detailed information.
Usage
There are three Pulsar Settings used to enable custom buttons. The format of each is below:
Enable Custom buttons
Name:Â Enable Custom Buttons
Key:Â pulsar.detail.custombuttons.show
Value: TRUEDefine the labels and identifiers for each custom button action.
Name:Â Object Name - custom button
Key:Â pulsar.<Object API Name>[.<Record Type Friendly Name or "default">].buttons
Value: Newline separated list of "button_Id:Label" pairs. Labels can contain spaces, button id's cannot contain spaces. See the example below.
EXAMPLE:
Name:Â Event custom buttons
Key:Â pulsar.event.default.buttons
Value: Start_Visit:Start VisitÂ
      End_Visit:End VisitÂ
      Display_Contact:Display Contact
      Create_Call_Record:Create Call RecordÂ
      View_Call_Record:View Call Record
ÂNow define each individual button action using PSL:
Name:Â Object Name - Button_Id - Action
Key:Â pulsar.buttonActions.<Object API Name>.button_id
Value: PSL. See examples below.
EXAMPLES:
Name:Â Event - Start_Visit - Action
Key:Â pulsar.buttonActions.Event.Start_Visit
Value: See code below. The code checks if the visit Is_Started flag is set, and if not, Â saves the current location and sets the flag, informing the user that the visit has started.DEFAULT{ Action=SetVar; VarName=Is_Started; VarValue=Is_Started__c; | Action=SqlQuery; QueryString=SELECT CASE WHEN '%%Is_Started%%' = 'TRUE' THEN 1 ELSE 0 END AS IsEventStarted; QueryReturnFields=IsEventStarted; QueryTest=%%IsEventStarted%%=1; QueryTestTrue=EVENT_ALREADY_STARTED; | Action=SetField; FieldType=TimeStamp; FieldName=StartDateTime; | Action=SetField; FieldType=General; FieldName=Is_Started__c; FieldValue=TRUE; | Action=SetLocation; LocationType=DeviceLocation; FieldName=Event_Location__c; | Action=Alert; Message=Visit Has Been Started; } EVENT_ALREADY_STARTED{ Action=Alert; Message=Visit has already started. You can only start the visit once; }
Name:Â Event - Create_Call_Record - Action
Key:Â pulsar.buttonActions.Event.Create_Call_Record
Value:Â See code below. The code checks if a Call Record has already been recorded for the current Event, and if not, creates the new Call Record by mapping field values from the current Event.
DEFAULT{ Action=SetVar; VarName=Event_Id; VarValue=Id; | Action=SqlQuery; QueryString=Select COUNT () AS Count_Call_Records FROM Call_Record__c WHERE Related_Event__c = '%%Event_Id%%'; QueryReturnFields=Count_Call_Records; QueryTest=%%Count_Call_Records%%>0; QueryTestTrue=DISPLAY_MESSAGE; | Action=CreateAndMapFields; ActionShouldComplete=TRUE; ObjectType=Call_Record__c; Related_Event__c=Id; WhatId__c=WhatId; WhoId__c=WhoId; Subject__c=Subject; Description__c=Description; Start_Date_Time__c=StartDateTime; End_Date_Time__c=EndDateTime; } DISPLAY_MESSAGE{ Action=Alert; Message=You have already created a call record for this Event; }
Â
See the screenshots below to see the logic in action:
| |
---|---|
Name | Custom Buttons Icon |
Key | pulsar.layout.{sobjectType}.customButtons.icon |
Value | |
Default Value (if any) | |
Compatibility | iOS Windows Android |
Description | No value is needed, but attach a PNG file to this setting and that will be used as the custom buttons icon. Otherwise the default (...) horizontal ellipsis is used. |
Notes/Comments/Examples |
| |
---|---|
Name | Controlling Visibility of Custom Buttons with PSL Logic |
Key | pulsar.<Object API Name>[.<Record Type Friendly Name or "default">].buttons.listitems |
Value | |
Default Value (if any) | |
Compatibility | iOS Windows Android |
Description | OPTIONAL The value of this setting should be valid PSL (Pulsar Settings Language (PSL)) and should result in a SetResult PSL Action that sets the result value to a string in the format expected by the pulsar.<Object API Name>[.<Record Type Friendly Name or "default">].buttons setting. |
Notes/Comments/Examples | DEFAULT{
Action=SetVar;
VarName=ShowOriginalOrder;
VarValue="FALSE";
|
Action=SqlQuery;
QueryString=SELECT '%%ShowOriginalOrder%%' as BoolVal;
QueryReturnFields=BoolVal;
QueryTest='%%BoolVal%%'='TRUE';
QueryTestTrue=ORIGINAL_ORDER;
QueryTestFalse=REVERSE_ORDER;
}
ORIGINAL_ORDER{
Action=SetResult;
Result=Launch_Yahoo:Launch Yahoo
Launch_Skype:Launch Skype
Launch_News:Launch News
Launch_SIP:Share In Pix;
}
REVERSE_ORDER{
Action=SetResult;
Result=Launch_Skype:Launch Skype
Launch_News:Launch News
Launch_SIP:Share In Pix
Launch_Yahoo:Launch Yahoo;
} |