VLOOKUP() in Excel is one of the most powerful and famous formula. This function is very easy to use to lookup a value from a table or range. You just need to refer a key value to the column located at the most left column of the range to get result value from another column in the same row. I'll not discuss more on VLOOKUP function in this blog, you can easily Google it or watch from Youtube.
One of the requirement to use VLOOKUP, which is also limitation of VLOOKUP, is the key value must be located at the most left column in the range, but that is not always how is out data structured. What happen when the key value located at the right of the result value?
Options:
1. Move the Result or Key value column
Move the Result value column to the right of Key value, or move Key value column to the left of Result value, then use VLOOKUP.
This may work easily, but sometimes when you work with many columns and many user, move column is not really a desired option.
2. Copy the Key or Result value
Copy Key or Result value to have Key value located before of Result value, then use VLOOKUP. Same with option 1, sometimes option to move column in big worksheet and work many user is not really a good option.
3. INDEX + MATCH function
The INDEX function returns a value in a table based on the intersection of a row and column position within that table. The first row in the table is row 1 and the first column in the table is column 1.
The MATCH function searches for a specified item in a range of cells, and then returns the relative position of that item in the range.
With combination of INDEX + MATCH functions, we can get something similar with VLOOKUP, but the Key not must be located before Result column, see this sample:
What is the formula in I2? =INDEX(A:A,MATCH(H2,B:B,0),1)
A:A = result / target value
B:B = key
H2 = data for row 2
I2 = target result
Pages
Friday, January 27, 2017
Thursday, January 26, 2017
Salesforce URLFOR()
URLFOR() function in Salesforce is not widely used as it is only available in custom buttons, links, s-controls, and Visualforce pages.
Syntax: {!URLFOR(target, id, [inputs], [no override])}
target: URL or action, s-control, or static resource merge variable
id: a reference to the record (depends on the “target”)
inputs: optional parameters with format: [param1="A", param2="B"]
no override: optional boolean flag - default false. Set to true to display a standard Salesforce page, regardless of whether you have defined an override for it elsewhere.
The most common URLFOR() is used by developers in Visualforce pages to refer to a resource in Static resources, such as images or scripts.
Visualforce
<apex:image url="{!$Resource.ImagePba}" width="50" height="50" />
This ImagePba in the sample above is the Static Resource name, not the original image file name.
<apex:image url="{!URLFOR($Resource.ImagePba)}" width="50" height="50" />
But when you use the resource in an archive file (such as a .zip or .jar file) in a static resource, URLFOR() is a must as a second parameter.
<apex:image url="{!URLFOR($Resource.Images,'pba.png')}" width="75" height="75" />
<apex:image url="{!URLFOR($Resource.ImagesFolder,'image/campaign1.png')}" width="100" height="100" />
<apex:includeScript value="{!URLFOR($Resource.LibraryJS, '/base/subdir/file.js')}"/>
Custom Button or Link
Admin can make use of URLFOR() function with $Action global variable in custom Button or Link. The $Action global variable provides methods such as View, Clone, Edit, and Delete. Some objects support other additional actions, see all valid actions here.
URLFOR() determines your base URL, and the $Action determines what view of a record to go to (the view page, edit page, etc.). For example, to edit the Account from the Contact page, add the custom button or link in Contact: {!URLFOR($Action.Account.View, Account.Id)}.
More samples
New Account -- {!URLFOR($Action.Account.New)}
View Account -- {!URLFOR($Action.Account.View, Account.Id)}
Edit Account -- {!URLFOR($Action.Account.Edit, Account.Id)}
Clone Contact -- {!URLFOR($Action.Contact.Clone, Contact.Id)}
Account Tab -- {!URLFOR($Action.Account.Tab, $ObjectType.Account)}
Sunday, January 22, 2017
Salesforce: Auto Lock Record
Use case: make opportunity become read-only when opportunity reach stage Closed Won.
Options: there are multiple solutions for this, from simple to advance with code:
1. Record Type & Page Layout
This would be one of the most famous solution without code, but this will make the system more difficult to maintain as the object will have additional record type set and additional page layouts. In short, when the opportunity reach Closed Won, with Workflow, change the record type to new record type and assign the new record type with page layout with read-only fields.
2. Record Ownership
This will work by change the record owner to a system user in highest role hierarchy. This will work well when the OWD sharing setting is Public Read-Only. But, often this solution will not work well, because the original record owner changed and it is important for reporting, although you can create custom user field to store it.
3. Validation Rule
By using function PRIORVALUE() and ISCHANGED() to detect any changes happened in Closed Won record. User will get error when save opportunity has been marked as Closed Won previously.
4. Trigger
Since Winter '16, Salesforce introduce lock() and unlock() methods in the System.Approval namespace. Admin need to enable this feature, from Setup | Create | Workflow & Approvals | Process Automation Settings. Then, select Enable record locking and unlocking in Apex.
Example:
5. Process Builder and Approval Process
In previous blog, we shared about users able to edit locked record and who will see Unlock Record button. As Process Builder able to call Approval Process, we'll make use of this combination to auto submit for approval when opportunity reach Closed Won. The approval process here would be auto approve, therefore it will leave a trace in the approval process.
a). Create Approval Process
b). Create Process Builder
Drawback for option (5): opportunity approval history will show action for approval submitted and approved, this is not ideal if you use opportunity with other approval process.
Reference:
Options: there are multiple solutions for this, from simple to advance with code:
1. Record Type & Page Layout
This would be one of the most famous solution without code, but this will make the system more difficult to maintain as the object will have additional record type set and additional page layouts. In short, when the opportunity reach Closed Won, with Workflow, change the record type to new record type and assign the new record type with page layout with read-only fields.
2. Record Ownership
This will work by change the record owner to a system user in highest role hierarchy. This will work well when the OWD sharing setting is Public Read-Only. But, often this solution will not work well, because the original record owner changed and it is important for reporting, although you can create custom user field to store it.
3. Validation Rule
By using function PRIORVALUE() and ISCHANGED() to detect any changes happened in Closed Won record. User will get error when save opportunity has been marked as Closed Won previously.
4. Trigger
Since Winter '16, Salesforce introduce lock() and unlock() methods in the System.Approval namespace. Admin need to enable this feature, from Setup | Create | Workflow & Approvals | Process Automation Settings. Then, select Enable record locking and unlocking in Apex.
Example:
// Query the opportunities to lock
Opportunity[] opty = [SELECT Id from Opportunity WHERE Name LIKE 'Acme%'];
// Lock the opportunities
Approval.LockResult[] lrList = Approval.lock(opty, false);
// Iterate through each returned result
for(Approval.LockResult lr : lrList) {
if (lr.isSuccess()) {
// Operation was successful, so get the ID of the record that was processed
System.debug('Successfully locked opportunity with ID: ' + lr.getId());
}
else {
// Operation failed, so get all errors
for(Database.Error err : lr.getErrors()) {
System.debug('The following error has occurred.');
System.debug(err.getStatusCode() + ': ' + err.getMessage());
System.debug('Opportunity fields that affected this error: ' + err.getFields());
}
}
}
5. Process Builder and Approval Process
In previous blog, we shared about users able to edit locked record and who will see Unlock Record button. As Process Builder able to call Approval Process, we'll make use of this combination to auto submit for approval when opportunity reach Closed Won. The approval process here would be auto approve, therefore it will leave a trace in the approval process.
a). Create Approval Process
Drawback for option (5): opportunity approval history will show action for approval submitted and approved, this is not ideal if you use opportunity with other approval process.
Reference:
Sunday, January 15, 2017
Adding Certs and Badges to Your Salesforce Community Profile
Don't let your hard earned Trailhead badges and Salesforce Certifications buried in your desk, make sure showing off all of them on your Salesforce Community profile!
1. Login to Success Community
Login to Success Community from https://success.salesforce.com. Once login, click your avatar and select "My Profile".
2. Edit Profile
Click "Edit" button then "Profile".
4. See other People Certs & Badges
Every user in Success Community will have unique User Id, which is start with 005, example: 00530000003TTvZAAW. When you click someone profile from Success Community, notice the URL, example: https://success.salesforce.com/_ui/core/userprofile/UserProfilePage?u=00530000003TTvZAAW&tab=sfdc.ProfilePlatformFeed
Get the User Id and paste it to following URL: https://success.salesforce.com/ProfileCertificationsAndBadges?u=00530000003TTvZAAW remember to change the Id to that particular User Id.
This is not convenience to manually copy and paste, ideally there should be a link from the user Chatter Feed to User Profile, so vote for this idea.
Another option is by search that people name from search text box and select People.
Search result as below, click the name then Certifications & Badges" link at left menu.
1. Login to Success Community
Login to Success Community from https://success.salesforce.com. Once login, click your avatar and select "My Profile".
2. Edit Profile
Click "Edit" button then "Profile".
Scroll down to "Certifications & Badges" section and enable both "Show Salesforce certifications on my profile" and "Show Salesforce Trailhead Badges on my profile". Make sure to enter your account and verify it.
Click "Save Changes" and done. You will need to enter verification code sent your email.
3. Check Your Profile
Navigate back to your profile - https://success.salesforce.com/profile then click "Certification and Badges" - https://success.salesforce.com/ProfileCertificationsAndBadges, you should see your hard earned Trailhead Badges and Salesforce Certifications showing off now.
Every user in Success Community will have unique User Id, which is start with 005, example: 00530000003TTvZAAW. When you click someone profile from Success Community, notice the URL, example: https://success.salesforce.com/_ui/core/userprofile/UserProfilePage?u=00530000003TTvZAAW&tab=sfdc.ProfilePlatformFeed
Get the User Id and paste it to following URL: https://success.salesforce.com/ProfileCertificationsAndBadges?u=00530000003TTvZAAW remember to change the Id to that particular User Id.
This is not convenience to manually copy and paste, ideally there should be a link from the user Chatter Feed to User Profile, so vote for this idea.
Another option is by search that people name from search text box and select People.
Search result as below, click the name then Certifications & Badges" link at left menu.
Excel Filter: Tips and Shortcut
As Salesforce admin, sometimes we need to prepare data before load into Salesforce correctly. Recently, I need to clean and prepare some pretty big amount of raw data. Microsoft Excel apparently is one the easiest and best available tool to clean and prepare the data before loading into Salesforce.
In this blog, I would like to share some tips learned from the exercise.
TIPS
- Ctrl+Shift+L – toogle enable and disable filter, make sure cursor in the range of value
- Alt+A+C – clear ALL filters
* the last one will work even no filter added
In drop down Filter menu (Alt+Down arrow)
- E key – type search
- C key – clear filter in current cursor column
- F+E key – select blank value
- F+N key – select non-blank value
- Up and Down arrow – move cursor, Space bar key to select, and Enter to perform action
- When cursor in range of values, Home – move to top value
- When cursor in range of values, End – move to bottom value
- Alt+Down Arrow+S – sort A to Z
- Alt+Down Arrow+O – sort Z to A
- Alt+Down Arrow+T – sort by Color sub menu
- Alt+Down Arrow+I – filter by Color sub menu
- Alt+Down Arrow+F – text or Date Filter sub menu
DO
1. Double click at bottom right of a cell will copy value to visible rows only
Double click bottom right corner to auto-fill value of C2 to visible rows below it (C4 and C6). When we clear the filter, only C4 and C6 is filled, while C3 and C5 is skipped. Value of C2 can be static or formula.
You can apply this to multiple columns too.
2. Similar to point 1, copy paste will to copy value to visible rows only
- Select range C2-D2 -- copy
- Select range C4-D6 -- paste
- Result: only value in C4, C6, D4, D6 will be copied, while row 3 & 5 skipped
** the same result if you select range C2-D6 for fill with a color, row 3 & 5 will not be colored
3. Copy paste will copy only from visible rows value
- This is not applicable for manually hidden rows
- Select cells / range to copy, example: copy as below screenshot
Paste to new area, I put my cursor to cell A8 -- only visible cells are copied.
4. Deal with blank row
If you need to deal with blank row in filter, make sure to highlight/select the area (in sample below, select area A1-D10 or the whole A-D column), before hit Ctrl+Shift+L, otherwise filter will not include area below empty row (row 7 and below).
DON'T
1. Copy more than 1 row from source into target with filtered rows
Don't copy more than 1 row from source into target with filtered rows, this cause value in target hidden filtered rows will be overwritten, sample: copy 3 rows of "B" from source (B11-B13)
Paste it to target which is filtered rows, for this example: paste into cell C2
Instead of copy value "B" into C2, C4, C6 -- "B" will be copied into C2, C3, C4.
Summary, copy from multiple rows will skipped filtered target.
This action will only work well, if there is no skipped rows in the applied filter, example: Jawa in sample above is at continuous rows e.g. 2,3,4.
Excel Table
By using the Table features, you can manage the data in the table rows and columns independently from the data in other rows and columns on the worksheet.
- Ctrl+L – create Excel Table
- To delete Excel Table table without losing the data:
- Select Convert to Range from DESIGN tab menu, or
- Right-click on the table and click Convert to Range under Table menu
- Filtering controls are added to the table headers automatically
- Place cursor anywhere in table, Alt+Shift+Down arrow – show the drop down menu
- You can have filter for more than one range of data on a sheet
In this blog, I would like to share some tips learned from the exercise.
TIPS
- Ctrl+Shift+L – toogle enable and disable filter, make sure cursor in the range of value
- Alt+A+C – clear ALL filters
- Place cursor at header, Alt+Down arrow to show drop down menu
- Place cursor at body, Alt+Down arrow to show drop down of available values (except number)* the last one will work even no filter added
In drop down Filter menu (Alt+Down arrow)
- E key – type search
- C key – clear filter in current cursor column
- F+E key – select blank value
- F+N key – select non-blank value
- Up and Down arrow – move cursor, Space bar key to select, and Enter to perform action
- When cursor in range of values, Home – move to top value
- When cursor in range of values, End – move to bottom value
- Alt+Down Arrow+S – sort A to Z
- Alt+Down Arrow+O – sort Z to A
- Alt+Down Arrow+T – sort by Color sub menu
- Alt+Down Arrow+I – filter by Color sub menu
- Alt+Down Arrow+F – text or Date Filter sub menu
DO
1. Double click at bottom right of a cell will copy value to visible rows only
Double click bottom right corner to auto-fill value of C2 to visible rows below it (C4 and C6). When we clear the filter, only C4 and C6 is filled, while C3 and C5 is skipped. Value of C2 can be static or formula.
You can apply this to multiple columns too.
2. Similar to point 1, copy paste will to copy value to visible rows only
- Select range C2-D2 -- copy
- Select range C4-D6 -- paste
- Result: only value in C4, C6, D4, D6 will be copied, while row 3 & 5 skipped
** the same result if you select range C2-D6 for fill with a color, row 3 & 5 will not be colored
3. Copy paste will copy only from visible rows value
- This is not applicable for manually hidden rows
- Select cells / range to copy, example: copy as below screenshot
Paste to new area, I put my cursor to cell A8 -- only visible cells are copied.
4. Deal with blank row
If you need to deal with blank row in filter, make sure to highlight/select the area (in sample below, select area A1-D10 or the whole A-D column), before hit Ctrl+Shift+L, otherwise filter will not include area below empty row (row 7 and below).
DON'T
1. Copy more than 1 row from source into target with filtered rows
Don't copy more than 1 row from source into target with filtered rows, this cause value in target hidden filtered rows will be overwritten, sample: copy 3 rows of "B" from source (B11-B13)
Paste it to target which is filtered rows, for this example: paste into cell C2
Instead of copy value "B" into C2, C4, C6 -- "B" will be copied into C2, C3, C4.
Summary, copy from multiple rows will skipped filtered target.
This action will only work well, if there is no skipped rows in the applied filter, example: Jawa in sample above is at continuous rows e.g. 2,3,4.
Excel Table
By using the Table features, you can manage the data in the table rows and columns independently from the data in other rows and columns on the worksheet.
- Ctrl+L – create Excel Table
- To delete Excel Table table without losing the data:
- Select Convert to Range from DESIGN tab menu, or
- Right-click on the table and click Convert to Range under Table menu
- Filtering controls are added to the table headers automatically
- Place cursor anywhere in table, Alt+Shift+Down arrow – show the drop down menu
- You can have filter for more than one range of data on a sheet
Friday, January 6, 2017
Salesforce: Workflow Action Failed to Trigger Flow
You build awesome Process Builder or Flow and it works as tested. Few days later, your user start complaining see ugly error as sample below. What is this mean? Is this mean Salesforce buggy, or you have successfully hack it?
Workflow Action Failed to Trigger Flow
The record couldn’t be saved because it failed to trigger a flow. A flow trigger failed to execute the flow with version ID 30128000000AgZ7. Contact your administrator for help.
Click here to return to the previous page.
or something like this:
Workflow Action Failed to Trigger Flow
The record couldn’t be saved because it failed to trigger a flow. A flow trigger failed to execute the flow with version ID 30190000000XmQs. Flow error messages: <b>An unhandled fault has occurred in this flow</b><br>An unhandled fault has occurred while processing the flow. Please contact your system administrator for more information. Contact your administrator for help.
Click here to return to the previous page.
The one below happened when PB try to call Flow and it fail, it may be caused by the Flow is Inactive, while the one earlier is related to update record fail.
Actually, what here mean is, something is broken with Process Builder or Flow built into your org., it can be fail to update record because of validation rules, error in Flow, or etc.
In our blog earlier, we mentioned that prefix 301 is InteractionDefinitionVersion, but we can't really easily see that record content by putting into URL, or by query with SOQL. So, how to trace that 301 error is referring to which Process Builder or Flow?
The user who create the Process Builder will get email from FlowApplication, with subject "Error Occurred During Flow "flow name", this email will mentioned the flow name, but no Version Id information as in the screenshot above. If the user create that Process Builder not in office, how you can trace Version Id prefix 301 is related to what?
There are 2 options to find this:
1. Flow
Use Flow Designer to check if that Id is refer to which Process Builder or Flow -- remember that Process Builder is using Flow as it engine. Follow this Url https://na3.salesforce.com/designer/designer.apexp#Id=30190000000XmQs, change na3 to your salesforce instance and you should see the Flow Name which is Lead Share for this sample.
2. Workbench
Login to workbench, navigate to menu Info | Metadata Types & Components, select Flow from drop down and click Expand All. You should find that 301 Version Id from the components and get the Flow name, which is "Lead Share"
This is the Process Builder as result of our finding:
Reference: Validation Rule in Workflow and Process Builder
Workflow Action Failed to Trigger Flow
The record couldn’t be saved because it failed to trigger a flow. A flow trigger failed to execute the flow with version ID 30128000000AgZ7. Contact your administrator for help.
Click here to return to the previous page.
or something like this:
Workflow Action Failed to Trigger Flow
The record couldn’t be saved because it failed to trigger a flow. A flow trigger failed to execute the flow with version ID 30190000000XmQs. Flow error messages: <b>An unhandled fault has occurred in this flow</b><br>An unhandled fault has occurred while processing the flow. Please contact your system administrator for more information. Contact your administrator for help.
Click here to return to the previous page.
The one below happened when PB try to call Flow and it fail, it may be caused by the Flow is Inactive, while the one earlier is related to update record fail.
Actually, what here mean is, something is broken with Process Builder or Flow built into your org., it can be fail to update record because of validation rules, error in Flow, or etc.
In our blog earlier, we mentioned that prefix 301 is InteractionDefinitionVersion, but we can't really easily see that record content by putting into URL, or by query with SOQL. So, how to trace that 301 error is referring to which Process Builder or Flow?
The user who create the Process Builder will get email from FlowApplication, with subject "Error Occurred During Flow "flow name", this email will mentioned the flow name, but no Version Id information as in the screenshot above. If the user create that Process Builder not in office, how you can trace Version Id prefix 301 is related to what?
There are 2 options to find this:
1. Flow
Use Flow Designer to check if that Id is refer to which Process Builder or Flow -- remember that Process Builder is using Flow as it engine. Follow this Url https://na3.salesforce.com/designer/designer.apexp#Id=30190000000XmQs, change na3 to your salesforce instance and you should see the Flow Name which is Lead Share for this sample.
2. Workbench
Login to workbench, navigate to menu Info | Metadata Types & Components, select Flow from drop down and click Expand All. You should find that 301 Version Id from the components and get the Flow name, which is "Lead Share"
This is the Process Builder as result of our finding:
Reference: Validation Rule in Workflow and Process Builder
Subscribe to:
Posts (Atom)




























