Pages

Tuesday, February 21, 2017

How to run Regex in Microsoft Excel?

1. Show Developer tab in Excel ribbon
If you do not see the tab, follow this URL to enable it.
https://msdn.microsoft.com/en-us/library/bb608625.aspx


2. VBA
To run Regex in Excel, you need to use VBA (Visual Basic for Applications).
From Developer tab, click Visual Basic icon.



3. Enable Regex for VBA for the workbook
In "Microsoft Visual Basic for Applications" window select "Tools" from the top menu.
Select "References".
Check the box next to "Microsoft VBScript Regular Expressions 5.5" to include in your workbook.
Click "OK".




Use Case:
We would like to parse specific patterns from range of cells in Excel, each cell could contain 0, 1 or more matches.
Here sample of data that user enter manually over times, to a text field without a good standard:
- Monitor 2X225,32C235, 21D2251
- 21A225; or 2C235; 21Z0251 keyboard

We need to capture and parse those ID, this looks like manual job, but with regex, we can parse this automatically. Regex should work with any new modern programming language, such as: Java, .Net and etc., but since Excel support VBA, we can make use of it.

If you notice above IDs, here is the possibility of patterns:
- 9X999
- 99X999
- 99X9999

With some testing with www.regex101.com, here is the RegEx to parse it:
[0-9]{2}[A-Z][0-9]{4}|[0-9]{2}[A-Z][0-9]{3}|[0-9][A-Z][0-9]{3}

From VBA window, copy and paste following script:
 Private Sub splitUpRegexPattern()  
   Dim regEx As New RegExp  
   Dim strPattern As String  
   Dim MyRange As Range  
   Dim i As Integer  
   Dim strMatch As String  
   'Source Data  
   Set MyRange = ActiveSheet.Range("A2:A15")  
   For Each C In MyRange  
     ' Regex pattern  
     strPattern = "[0-9]{2}[A-Z][0-9]{4}|[0-9]{2}[A-Z][0-9]{3}|[0-9][A-Z][0-9]{3}"  
     If strPattern <> "" Then  
       With regEx  
         .Global = True  
         .IgnoreCase = True  
         .Pattern = strPattern  
       End With  
       Set Matches = regEx.Execute(C.Value)  
       ' Reset the variables  
       strMatch = ""  
       i = 1  
       ' Iterate through the Matches collection  
       For Each Match In Matches  
         strMatch = "'" & Match.Value  
         ' Display the matches at right columns  
         C.Offset(0, i) = strMatch  
         i = i + 1  
       Next  
     End If  
   Next  
 End Sub  

Result:


The step and script is tested with Microsoft Excel 2013 and 2016.



Sunday, February 19, 2017

Your Organization's Salesforce.com pages has moved

If your user get a splash warning message "Your Organization's Salesforce.com pages has moved. Redirecting...", what is this mean? and why this happened?



This warning message usually happened when your admin enable "My Domain" feature, but still allowed user login from https://login.salesforce.com

As admin, you can check this from Setup | Domain Management | My Domain, and look for Redirect Policy under My Domain Settings.


If Redirected to the same page within the domain is selected, users are immediately sent to the new URL, without notification.

If Redirected with a warning to the same page within the domain is selected, users briefly see a warning message before being redirected to the new URL. The warning gives users a chance to change their bookmarks and get used to using the new sub-domain URL. You can’t customize the message.

If Not redirected is selected, the user gets a “page not found” error. Eventually, you want your users to use only sub-domain URLs, but it’s a best practice to use Redirected with a warning to the same page within the domain for a short time after you deploy your sub-domain so that users can get used to the new URLs.


Reference:



Salesforce Web-to-Lead with Enable spam filtering

Web-to-Lead has been available for many years for Salesforce users, this feature is simple but allow you easily capture lead from your company website and the data goes directly to Salesforce.

The enhancements in Spring '17 release will allow you to enable spam filtering with reCAPTCHA from Google.

As per normal Web-to-Lead setup, navigate to Setup | Customize | Leads | Web-to-Lead, click "Create Web-to-Lead Form". Tick option for "Enable spam filtering (recommended)", then you need to create reCAPTCHA API Key Pair.

How to create reCAPTCHA API Key Pair?
1. Make sure you have Google account.
2. Navigate to Google reCAPTCHA page, login to Google account, and click Get reCAPTCHA button.
3. Enter label and domain name, make sure this is domain that you will use to host Web-to-Lead HTML.


4. Copy the Site Key and Secret Key.


Now, back to Salesforce setup page to enter reCAPTCHA API Key Pair created. Click lookup icon in reCAPTCHA API Key Pair, then click New button, enter API Key Pair Nickname, Secret Key and Site Key created earlier. Click Save button to store the keys for Web-to-Lead.


As per normal, continue with selecting fields to show in the web form, and the return URL.

Sample:




Reference:


Page-level ad