Salesforce formula for End of string - salesforce

I have some salesforce roles following the format:
developer_team_london
developer_team_paris
developer_team_madrid
I need to create a formula field named Team that takes only what's after the substring team, so in this case the result will be london (paris, madrid).
How can I achieve this?
Thank you.

Many ways to do it, depends on data, how likely it is to change. What have you tried?
SUBSTITUTE(LastName, 'developer_team_', '')
MID(LastName, LEN('developer_team_') + 1, 99)
MID(LastName, FIND('team_', LastName) + LEN('team_'), 99)

Related

Dynamically query or filter a table in Google Sheets using checkboxes and searchbox

I have a database of songs and want to use filter or query to return results based on a dashboard with search-boxes and check-boxes. This seems rudimentary, but I can't find what I'm looking for after a few days. Query seems super powerful, but largely when hard coding. I need a user-friendly interface! I've seen some tutorials on incorporating drop-down boxes, but I don't necessarily want to use those.
I couldn't figure out how to add IF() statements to the WHERE clause in query.
=QUERY(A4:G9, "WHERE IF '"(C2=TRUE, "' '"C CONTAINS TRUE"'",1))
This is what I'm starting with, and I know its all kinds of wrong.
GOAL: When the checkbox for MP3 is ticked, all songs with MP3s are listed. But when I also tick the WAV box, only songs with MP3s and WAVs remain, etc.
I will keep the source data and the search key on different tabs. Eventually like to add ranges to the length and bpm boxes too.
Any suggestions on the methods or formulas would be much appreciated.
Please read: Query
=query(A4:G9,"select A,B,C where 0=0"&IF($B$2," and B=TRUE","")&IF($C$2," and C=TRUE",""),1)
try:
=IFERROR(QUERY(A4:G, "where "&TEXTJOIN(" and ", 1,
IF(B2=TRUE, "B=TRUE", ),
IF(C2=TRUE, "C=TRUE", )), 1), QUERY(A4:G))
UPDATE:
=IFERROR(QUERY(A4:G, "where "&TEXTJOIN(" and ", 1,
IF(B2=TRUE, "B=TRUE", ),
IF(C2=TRUE, "C=TRUE", ),
IF(F1<>"", "lower(D) contains '"&F1&"'", )), 1), QUERY(A4:G))

EXCEL - Multiple Arrays within COUNTIF formula

Attempting to count:
Named range "STATUS" if the value of the cells equals Reserved, Blocked, Pending OR Archive
AND
Named range "COMPANY" equals Company A, Company B OR Company C.
I'm also counting multiple other criteria, all of the which are working. When I added the array for the Company the formula is no longer counting the Status.
Here is the formula I'm using:
=SUM((COUNTIFS(DATES,">="&A19,DATES,"<"&EDATE(A19,1),AGENT,"JOHN DOE",COMPANY,{"COMPANY A","COMPANY B","COMPANY C"},STATUS,{"Reserved","Blocked","Pending","Archive"})))
Any help is greatly appreciated and thank you in advance!
Try this
=SUM((COUNTIFS(DATES,">="&A19,DATES,"<"&EDATE(A19,1),AGENT,"JOHN DOE",COMPANY,{"COMPANY A";"COMPANY B";"COMPANY C"},STATUS,{"Reserved","Blocked","Pending","Archive"})))
or
=SUM((COUNTIFS(DATES,">="&A19,DATES,"<"&EDATE(A19,1),AGENT,"JOHN DOE",COMPANY,{"COMPANY A","COMPANY B","COMPANY C"},STATUS,{"Reserved";"Blocked";"Pending";"Archive"})))
Note the ; instead of , in arrays. For details on why to use semi-colon instead of comma see this.
If you want to use your formula it should be as follows
=SUM((COUNTIFS(DATES,">="&A19,DATES,"<"&EDATE(A19,1),AGENT,"JOHN DOE",COMPANY,"COMPANY A",STATUS,{"Reserved","Blocked","Pending","Archive"}))) +
SUM((COUNTIFS(DATES,">="&A19,DATES,"<"&EDATE(A19,1),AGENT,"JOHN DOE",COMPANY,"COMPANY B",STATUS,{"Reserved","Blocked","Pending","Archive"}))) +
SUM((COUNTIFS(DATES,">="&A19,DATES,"<"&EDATE(A19,1),AGENT,"JOHN DOE",COMPANY,"COMPANY C",STATUS,{"Reserved","Blocked","Pending","Archive"})))
you can create additional column with all of the conditions you need as if inside an IF condition, e.g.
=(A2>=A19) * ((B2="COMPANY A") + (B2="COMPANY B")))
and then =COUNTIF(ALL_CONDITIONS, ">0")

SOQL: Performing Query with both LIKE & IN

I have a list of accounts that I would like to perform a LIKE query on. Ideally, my query would be something like:
SELECT id, owner.name FROM Account WHERE name LIKE IN :entityList
Is there any way I can do this?
The issue is that my entity names come from a third party source, which means that small variations in name may be present, i.e
"Bay Ridge apt." VS "Bay Ridge Apartments"
It's hard to predict where the difference in spelling might be, and I was hoping that the LIKE filter might be some magical filter that can figure this out for me and match on a substring (i.e. "Bay Ridge").
How can I perform this query?
Thank you!
EDIT: The Salesforce guide doesn't include this option in their guide, so it might not be possible to combine a LIKE and an IN. Maybe there's a solution around it?
SOQL Comparison Operators
EDIT: Maybe there's a way to perform a SOSL query on a list? Something like :
Find {entityList} In Account
I can't seem to find this any where...
You can achieve this through looping and make dynamic query depend upon your list.
String[] entityList = new String []{'CEO','CFO','CMO','CTO','CIO','COO','VP','DIRECTOR','VIP'};
Boolean first = true;
query = 'Select Id FROM CONTACT';
for(String el : entityList){
if(!first){
query += ' OR';
} else {
query += ' WHERE';
}
query = query + ' name LIKE \'%' + el + '%\'';
first = false;
}
Turns out, you don't need to have both LIKE & IN. By setting the return value as a list, and referencing an iterator in the query, IN is implied. This query does both:
SELECT id, owner.name FROM Account WHERE name LIKE :entityList
See here:
SOQL: Performing Query with both LIKE & IN
Also, there doesn't seem to be a good way to bulkify the SOSL query

Salesforce Junction Objects

To all salesforce experts i need some assistance. I have my contacts and a custom object named programs. I created a junction object using to master detail relationships with contacts and programs. I want to avoid relating the same contact to the same program. I tried triggers but I couldn't create the testing part to use it outside sandbox.
I went back to the basics and created a Unique text field. I tried to use default value but EVERYTHING i write in that crap is wrong -_-. I tried Contact__r.Email & "-" & Program__r.Name but to no avail.
I tried workflow rules with a field update but my field update NEVER runs.(Yes I did activate the workflow rule) and I didn't know what to write in my rule's code.
The workflow firing condition could be simply a formula that says true. Alternatively use "every time record is inserted". It also depends whether your master-details are set once and that's it or they will be "reparentable" (option introduced in Summer '12 I think). Maybe post a screenshot / text description of your firing condition? Also - is your unique field set to "case sensitive"?
As for the formula to populate the unique field - something like Contact__c + ' ' + Program__c (or whatever the API names of your fields are) should be OK. Don't use Contact__r.Email etc as these don't have to be unique...
You'll have to somehow fill in the uniqueness criteria for all existing records (maybe that's why you claimed it doesn't work?). If you can use Apex for data fixes - something like this should get you started.
List<Junction__c> junctions = [SELECT Contact__c, Program__c
FROM Junction__c
WHERE Unique_Text_Field__c = null
LIMIT 10000];
for(Junction__c j : junctions){
String key = String.valueOf(j.Contact__c).left(15) + ' ' + String.valueOf(j.Program__c).left(15);
j.Unique_Text_Field__c = key;
}
update junctions;
Keep rerunning it until it starts to show 0 rows processed. The Ids are cut down to 15 chars because in Apex you'd usually see full 18-char Id but workflows use 15-char versions.

Database of common name aliases / nicknames of people

I'm involved with a SQL / .NET project that will be searching through a list of names. I'm looking for a way to return some results on similar first names of people. If searching for "Tom" the results would include Thom, Thomas, etc. It is not important whether this be a file or a web service. Example Design:
Table "Names" has Name and NameID
Table "Nicknames" has Nickname, NicknameID and NameID
Example output:
You searched for "John Smith"
You show results Jon Smith, Jonathan Smith, Johnny Smith, ...
Are there any databases out there (public or paid) suited to this type of task to populate a relationship between nicknames and names?
I'm adding another source for anyone who comes across this question via Google. This project provides a very good lookup for this purpose.
https://github.com/carltonnorthern/nickname-and-diminutive-names-lookup
It's somewhat simpler and less complete than pdNickName but on the other hand it's free and easy to use.
A google search on "Database of Nicknames" turned up pdNickName (for pay).
In addition, I think you only need a single table for this job, not two, with NameID, Name, and MasterNameID. All the nicknames go into the Name column. One name is considered the "canonical" one. All the nickname records use the MasterNameID column to point back to that record, with the canonical name pointing to itself.
Your two table schema contains no additional information and, depending on how you fill in the nickname table, you might need extra code to handle the canonical cases.
I just found this site.
It looks like you could script it pretty easily.
http://www.behindthename.com/php/extra.php?terms=steve&extra=r&gender=m
I just wish I could auto narrow this to english..
Another commercial name matching database is: http://www.basistech.com/name-indexer/
It looks quite professional (though potentially expensive).
They claim to support the following languages:
Arabic, Chinese (Simplified), Chinese (Traditional), Persian (Farsi / Dari), English, Japanese, Korean, Pashto, Russian, Urdu
Here is a github repo with csv of related names, and you can contribute back:
The first few lines show the format:
aaron,ron
abel,abe
abednego,bedney
abijah,ab,bige
abigail,ab,abbie,abby,gail
abner,ab,abbie,abby
abraham,abe,abram,bram
absalom,ab,abbie,app
There is a database out there called pdNicknames (found at http://www.peacockdata2.com/products/pdnickname/). It contains everything you need, at a cost of $500.
Similar format as Stan James's csv, but folded two ways for lookups:
Name to nickname: https://github.com/MrCsabaToth/SOEMPI/blob/master/openempi/conf/name_to_nick.csv
Nickname to name: https://github.com/MrCsabaToth/SOEMPI/blob/master/openempi/conf/nick_to_name.csv
To select similar sounding name use: (see MSDN)
SELECT SOUNDEX ('Tom')
This is a good choice: https://github.com/onyxrev/common_nickname_csv
id, name, nickname
1, Aaron, Erin
2, Aaron, Ron
3, Aaron, Ronnie
4, Abel, Ab
5, Abel, Abe
6, Abel, Eb
7, Abel, Ebbie
8, Abiel, Ab
9, Abigail, Abby
10, Abigail, Gail

Resources