Jan 15, 2017

Sujesh Ramachandran

Brand your lightning component


Do you want to brand your lightning component while display under app builder? here it is an out of box feature to show an icon for your lightning component. All you need to do is to design an SVG icon for your component and add under the SVG supporting file of your lightning component.

Also, ThemeColorConfigure.design can also be used to configure the display name of the ThemeColorConfigure.cmp in app builder using the attribute 'label' for the design:component . In this example, I have given as 'Theme Color Picker', so that the name will be displayed under the available custom lightning component list.

Here is an example to show the icon and label for the lightning component and will see how it looks like in the app builder.


Screenshot from App Builder:



follow me @ramsujesh

Read More
Sujesh Ramachandran

Event Monitoring in Salesforce


Salesforce Provides detailed info about the user activty and you could use the details to Monitor data loss, Increase adoption, Optimize performance and bulid powerful tools to either visualize the details or any automated service for User tracking etc. Event monitoring is one of many tools that Salesforce provides to help keep your data secure. It lets you see the granular details of user activity in your organization. These user activities are referred as events. You can view information about individual events or track trends in events to swiftly identify abnormal behavior and safeguard your company’s data.

Event monitoring provides tracking for more than 30 different types of events, including:
  • Apex Callout
  • Apex Execution
  • Apex SOAP
  • Apex Trigger
  • API
  • Async Report
  • Bulk API
  • Change Set Operation
  • Content Distribution
  • Content Document Link
  • Content Transfer
  • Dashboard
  • Document Attachment Downloads
  • Login
  • Login As
  • Logout
  • MDAPI Operation
  • Multiblock Report
  • Package Install
  • Queued Execution
  • Report
  • Report Export
  • REST API
  • Salesforce1 Adoption (UI Tracking)
  • Sandbox
  • Sites
  • Time-Based Workflow
  • Transaction Security
  • UI Tracking
  • URI
  • Visualforce Request
  • Wave Change
  • Wave Interaction
  • Wave Performance

All these events are stored in event log files. An event log file is generated when an event occurs in your organization and is available to view and download after 24 hours. The event types you can access and how long the files remain available depends on your edition.

  • Developer Edition (DE) organizations have free access to all 30+ log types with one-day data retention.
  • Enterprise, Unlimited, and Performance Edition organizations have free access to the login and logout log files with one-day data retention. For an extra cost, you can access all log file types with 30-day data retention.

Considerations while using Event Monitoring:
  • LogDate tracks usage activity for a 24-hour period, from 12:00 a.m. to 11:59 p.m. UTC time.
  • Log files are available based on CreatedDate for the last 30 days when orgs purchase User Event Monitoring or one day for Developer Edition orgs.
  • In the unlikely case where no log files are generated for 24 hours, contact Salesforce.
  • Log data is read-only. You can’t insert, update, or delete log data.
  • Use the EventType field to determine which files were generated for your org.
  • An event generates log data in real time. However, log files are generated the day after an event takes place, during nonpeak hours. Therefore, log file data is unavailable for at least one day after an event.
  • CreatedDate tracks when the log file was generated.
  • Log files, represented by the EventType field, are generated only if there is at least one event of that type for the day. If no events took place, the file isn’t generated for that day.
  • All event monitoring logs are exposed to the API through the EventLogFile object, however there is no access through the user interface.

Event monitoring Using REST

Use the SObject Describe resource to retrieve all metadata for an object, including information about fields, URLs, and child relationships.

Query Event Monitoring Data with REST
Use the Query resource to retrieve field values from a record. Specify the fields you want to retrieve in the fields parameter and use the GET method of the resource. You can use Workbench to query event monitoring data. To retrieve event monitoring records based on LogDate and EventType

Get Event Monitoring Content from a Record
Use the SObject Blob Retrieve resource to retrieve BLOB data for a given record. You can use Workbench to retrieve BLOB data for event monitoring. In the Execute text box, use a GET request similar to this: /services/data/v32.0/sobjects/EventLogFile/0ATD000000000pyOAA/LogFile.

Download Large Event Log Files Using cURL with REST
You might have some event log files that are larger than your tool can handle. A command line tool such as cURL is one method to download files larger than 100 MB using the SObject Blob Retrieve object.
curl https://***yourInstance***.salesforce.com/services/data/v32.0/sobjects/EventLogFile/0AT30000000000uGAA/LogFile
-H "Authorization: Bearer token" -H "X-PrettyPrint:1" -o ~/downloads/outputLogFile.csv

For more details, check the Trail Head Module

follow me @ramsujesh

Read More

Jan 1, 2017

Sujesh Ramachandran

Design resource in lightning component



2017 begins, and I thought somehow should publish an article on the first day to keep the momentum going well. Here is the an out of box way to pass the attributes to the lightning component from app builder. Lets take an example to configure the theme color of a component and the theme color could be provided by an admin user who configure the lightning component in the app builder.

ThemeColorConfigure.cmp is the component we are going to create and when an admin drag and drop this component into app builder, admin will get an option to  configure the theme color of the component. After drag and drop the component, admin could enter the color name or code in to the right panel for the attribute "Theme Color". Based on the Theme color the component theme color will be displayed.

Lets jump into the technical part of ThemeColorConfigure.cmp. we have created an attribute 'ThemeColor' in the ThemeColorConfigure.cmp. Also, to expose this attribute to the app builder, we have created the ThemeColorConfigure.design wherein we have mentioned the 'ThemeColor' attribute and the label name(display name) for app builder.

Use a design resource to control which attributes are exposed to the Lightning App Builder. A design resource lives in the same folder as your .cmp resource, and describes the design-time behavior of the Lightning component—information that visual tools need to allow adding the component to a page or app.

Also, ThemeColorConfigure.design can also be used to configure the display name of the ThemeColorConfigure.cmp in app builder using the attribute 'label' for the design:component . In this example, I have given as 'Theme Color Picker', so that the name will be displayed under the available custom lightning component list.

Here is the code of the above example:


Here is the screenshot of the app builder looks like while trying to add the ThemeColorConfigure.cmp to configure the theme color value.



Some more information about design resource of a lightning component

1) As of now a design resource supports only attributes of type int, string, or boolean.
2) To Render a field as a picklist, , add a datasource onto the attribute in the design resource, like this


3) You can set a default value on an attribute in a design resource, like this

4) Restrict a component to one or more objects
Use the sfdc:object tag set to specify which objects your component is valid for.
For example, in the above example let's restrict the lightning component to only Account object by adding the below code

follow me @ramsujesh
Read More