Pages

Friday, June 10, 2016

Salesforce: Convert Multi-Select Picklist to Text


Multi-Select Picklist is nice for user to use in Salesforce user interface, but there are many limitations for admin to use this type of field, because it support limited functions compare to other fields type.

More than a year ago, we blog about How to sort Multi-Select Picklist in View? This blog will share about how to convert Multi-Select Picklist to Text, so you can use it in many areas.

As of now (Summer '16 release), multi-select picklist only support following functions:
  • INCLUDES()
  • ISBLANK()
  • ISNULL()
  • ISCHANGED() - only in assignment rules, validation rules, workflow field updates, and workflow rules in which the evaluation criteria is set to Evaluate the rule when a record is: created, and every time it’s edited.
  • PRIORVALUE()only in assignment rules, validation rules, workflow field updates, and workflow rules in which the evaluation criteria is set to Evaluate the rule when a record is: created, and every time it’s edited.

With a simple formula field return text format, you can get the multi-select picklist values in Text.
Let say you have a custom multi-select picklist field called Country__c with 5 values. Here is the formula:
 IF( INCLUDES(Country__, 'Singapore'), 'Singapore,', null) +   
 IF( INCLUDES(Country__, 'Indonesia'), 'Indonesia,', null) +   
 IF( INCLUDES(Country__, 'Malaysia'), 'Malaysia,', null) +   
 IF( INCLUDES(Country__, 'China'), 'China,', null) +   
 IF( INCLUDES(Country__, 'Japan'), 'Japan,', null)   


Reference: Tips for Working with Picklist and Multi-Select Picklist Formula Fields


Thursday, June 9, 2016

Salesforce System Status Alert with IFTTT

Salesforce Trusthttp://trust.salesforce.com is the main area to monitor if any issues happened with your Salesforce org, but you need to know what is your Salesforce instance, for production instance, it start with NAxx, EUxx, and APxx, while CSxx for sandbox instances.

It is a good idea to have central place to monitor all instances, or your specific instances. For this blog I'll use sample instance NA17. We'll not always keep monitor that website - http://trust.salesforce.com/trust/instances/NA17, but I expect that Salesforce Trust will email me directly if any post related to my instance.

Solution: because Salesforce Trust also publish RSS feed, we can use this and combine with IFTTT.com to trigger send email. The same result can be achieved using other tools support rss feed to email such as: blogtrottr.com, but for this blog, we'll just use IFTTT.com

RSS Feed for NA17 = http://trust.salesforce.com/rest/rss/NA17
  1. Login or Signup to ifttt.com
  2. Create a Recipe
  3. Select if "Feed"
  4. Enter NA17 Feed URL: http://trust.salesforce.com/rest/rss/NA17
  5. Select then "Email"
  6. Leave the Subject and Body as default
  7. Done and you have your recipe running.



If any post related to NA17, IFTTT will send you email, see sample below:




Thursday, May 26, 2016

Salesforce: Multi-Person Calendar Event (User as invitee)

In previous blog Multi-Person Calendar Event (Contact / Lead as invitee), we discussed about adding contact or lead as invitee, we also discussed the structure at the backend and how we can use API to add contact or lead as invitee.

But, when the invitee is a user, the structure will be a little different, although the objects used is the same.

1. Event object
Instead of create only 1 event record as add contact/lead as invitee, invite user will create multiple event record based on number of invitee + sender. In this scenario, we are going to invite 2 users and 1 contact.


Sample query: Select Id, Subject, OwnerId, GroupEventType, IsChild, WhatId, WhoId, CreatedDate, ActivityDate, ActivityDateTime, StartDateTime, EndDateTime, EventSubtype, IsReminderSet, Type, WhatCount, WhoCount FROM Event WHERE Subject = 'Test with User'


This will create 3 events with same subject, one event for each User, but only 1 with IsChild = False, which is "parent" event. Also notice that each record have different Owner Id, and all events with GroupEventType = 1, remember that we cannot populate / update GroupEventType manually.


2. EventRelation object
Sample query: SELECT Id,EventId,RelationId,IsParent,IsWhat,IsInvitee,Status,CreatedDate FROM EventRelation WHERE EventId IN ('00U63000001T8Y9EAK','00U63000001T8YAEA0','00U63000001T8YBEA0')


Notice that records created in this object is relate to: 1 opportunity, 1 contact and 2 users, but all linked to the same event, which is parent event where IsChild = False.


3. EventWhoRelation object
Same with EventRelation object, only 1 record created as we only have 1 contact relate to the event, and it is linked to the parent Event (IsChild = False)

Sample query: SELECT Id, EventId, RelationId, Type, CreatedDate FROM EventWhoRelation WHERE EventId IN ('00U63000001T8Y9EAK','00U63000001T8YAEA0','00U63000001T8YBEA0')



How to auto add User as Invitee Event with API?

You just need to insert record(s) to EventRelation object, 1 record for 1 contact / lead. Here are fields you need to populate:
1. EventId = Event Id
2. RelationId = User Id
3. IsParent = False
4. IsWhat    = False
5. IsInvitee = True
6. Status   = New

This is similar with add Contact / Lead as invitee, the difference is: Salesforce will auto create event record for the user as child record, if the parent record initially is not for multi-person, GroupEventType will change from 0 to 1.



Salesforce: Multi-Person Calendar Event (Contact / Lead as invitee)


In Salesforce, you can create event and relate to multiple Contacts (up to 50 contacts), but make sure you have enable Allow Users to Relate Multiple Contacts to Tasks and Events from Setup | Customize | Activities | Activity Settings.

You also can invite Contacts that is not defined in the Relate To for the event, including from Leads.


As you see from screenshot above, the event is relate to Opportunity and 2 contacts, we add both Contacts as invitee, and then we also add 2 Leads as Invitee.


So what happened in the backend ?

1. Event object
Salesforce create a new event record, because this is Multi-Person Calendar Event, notice GroupEventType = 1; while WhoId is the primary Contact.

Note that you cannot populate GroupEventType from API, but the value will be auto populate based on event category:
  • 0 (Non–group event)—An event with no invitees.
  • 1 (Group event)—An event with invitees.
  • 2 (Proposed event)—An event created when a user requests a meeting with a contact, lead, or person account using the Salesforce user interface.  

Sample query: Select Id, CreatedDate, ActivityDate, ActivityDateTime, ReminderDateTime, StartDateTime, EndDateTime, EventSubtype, GroupEventType, IsReminderSet, OwnerId, Subject, Type, WhatCount, WhatId, WhoCount, WhoId FROM Event WHERE Id = '00U63000001T8XGEA0'


2. EventRelation object
Represents people (a user, a lead, or contacts) or a resource (such as a conference room) invited to an event.  For above screenshot scenario, query to this object for above event will return 5 records: 2 Contacts, 2 Leads and 1 Opportunity.

Sample query: SELECT Id, EventId, RelationId, IsParent, IsWhat, IsInvitee, Status, CreatedDate FROM EventRelation WHERE EventId = '00U63000001T8XGEA0'



3. EventWhoRelation object
Represents the relationship between an event and a lead or contacts, this object DO NOT have relation with invitee, but it is pure on contacts or lead Relate To the Event. EventWhoRelation allows a variable number of relationships: one lead or up to 50 contacts. Available only if you’ve enabled Shared Activities for your organization.

Sample query: SELECT Id, EventId, RelationId, Type, CreatedDate FROM EventWhoRelation WHERE EventId = '00U63000001T8XGEA0'

From the top screenshot scenario, query will return 2 records which is Contact relate to: Mike Lee and Jack Man. We cannot create record directly in EventWhoRelation object with API.


How to auto add Contact / Lead as Invitee Event with API?

You just need to insert record(s) to EventRelation object, 1 record for 1 contact / lead. Here are fields you need to populate:
1. EventId = Event Id
2. RelationId = Contact Id / Lead Id
3. IsParent = False
4. IsWhat    = False
5. IsInvitee = True
6. Status         = New


Reference:


Wednesday, May 25, 2016

Salesforce: Automate Assigning Managed Package Licenses

When you purchase 3rd party app by License (from AppExchange or others), once installed in Production, you will find the Packaged in Setup | Installed Packages. For free package, it will be available for all users, but for license by user, you will notice Manage Licenses link next to the Package Name. Then admin or user with Manage Package Licenses permission need to add users for particular license. This is simple job, but when you have new user onboard and offboard over the times, this activity often forget and become not practical.

Can we automate this? 
Since Summer 14 release, Salesforce make the object available via API, where you can use Process Builder + Flow or Trigger to automate license assignment and license removal.

There are 2 object you need to work with:

1. PackageLicense
Represents a license for an installed managed package.
This object only support record query, not create, update, and delete.

2. UserPackageLicense
Represents a license for an installed managed package, assigned to a specific user.
This object support record create, delete, query, but not update.

I'll not go down to the detail on how to create Process Builder + Flow or Trigger code in this blog, but the idea is based on objects above, you need to get the PackageLicense Id, the create new record in UserPackageLicense, you just need to provide PackageLicenseId and UserId.


Sample Query
SELECT Id, NamespacePrefix, AllowedLicenses, UsedLicenses FROM PackageLicense WHERE Status = 'Active' AND AllowedLicenses > 0 ORDER BY NamespacePrefix


SELECT Id, PackageLicenseId, UserId FROM UserPackageLicense WHERE PackageLicenseId = '050o0000000DC8JAAW'


Reference:


Sunday, May 22, 2016

Salesforce: New Event versus New Meeting Request

In previous blog, we discussed about New Meeting Request. However, using Event and Select Invitee, this will also can be used to send invite for coworkers and customers.

What is similar between New Event with select Invitee versus New Meeting Request?
  • Both can be launch from Home page calendar and Open Activities of lead and contact.
  • When you can use customize logo in meeting request, it will be the same logo for both, you can configure from Setup | Customize | Activities | Activities Setting | Show Custom Logo in Meeting Requests
  • Both can invite User, Lead, and Contact
  • Both have start and end date time
  • Both have Location and Subject
  • Invitees will get email of the invite, although the message a little different, Meeting Request have more content, see screenshots below
  • Invitees to response the invite
  • Both event is report-able using standard report type = Events with Invitees

New Event with select Invitee


New Meeting Request


What is the difference between New Event & New Meeting Request?
An event does not necessarily mean that you will be having a meeting with someone, even the event type is meeting, your customer will not receive meeting invite, until you add them as Invitee. When you create new event, scroll down to the bottom and look for Select Invitees section

Once you add invitee to the event, notice the event title change from New Event to New Multi-Person Calendar Event, and there is a button Save & Send Update, this will send email to all invitee. Once New Meeting Request is confirmed, it will have the same behavior as Event with invitee.

New Event 
  • Sender will receive initial email and it consider confirmed invite
  • Meeting times is fixed
  • No customized message 
  • Event send will show in sender Calendar as "Scheduled Meetings"
  • Invitees to accept or decline invite, issue: sender do not get email when invitee response.

New Meeting Request
  • Sender can propose up to five meeting times
  • Sender can customize message
  • When meeting invite sent, event will be show in sender Calendar as "Requested Meetings"
  • Invitees receive email and select preferred meeting times or propose new times
  • After invitee responses, sender to confirm the meeting, sender will get email when invitee response.
  • Invitees will receive email and need to accept or decline confirmed meeting times, here we have the same issue as New Event, sender do not received email as well.
  • When sender confirmed the meeting time, event will move from "Requested Meetings"to "Scheduled Meetings" in Home page

Sample Report
In this scenario, we are using report type "Events with Invitees"
 Sender = Jack Bob
 Invitee 1 = Linda Yie (co-worker)
 Invitee 2 = Sean Lee (lead)

Initial sent
Linda received email
Sean received email

Linda select a time
Nothing change in report

Sean select a time
Nothing change in report

Jack confirm the meeting time
Linda received email
Sean received email

Sean accept & Linda reject the invite


Sender can track who has accept, decline and has not responded to the invite from the event itself.



Reference:


Page-level ad