Fields & Links
12 min
tl;dr to reference a field write e g \<font color="#ff6900">description\</font> if a field contains spaces or other special characters, write e g \<font color="#ff6900">\[billing city]\</font> to reference a field of a related module, write e g \<font color="#eb144c">calls\</font> \<font color="#ff6900">subject\</font> use \<font color="#9900ef">\<all!\>\</font> before a link name to specify "all and at least one" records for example, typing \<font color="#9900ef">\<all!\>\</font> \<font color="#eb144c">calls\</font> \[ \<font color="#ff6900">start date\</font> ] = \<font color="#9900ef">tomorrow\</font> in accounts will find all accounts that have at least one related call, and all their related calls start tomorrow use \<font color="#9900ef">\<all?\>\</font> to specify "all or none" for example, typing \<font color="#9900ef">\<all?\>\</font> \<font color="#eb144c">calls\</font> \[ \<font color="#ff6900">start date\</font> ] = \<font color="#9900ef">tomorrow\</font> in accounts will find all accounts that either have no related calls, or if they do, they all start tomorrow discover why all! and all? are important /#difference between and use \<font color="#9900ef">\<some\>\</font> to specify "one or more" for example, typing \<font color="#9900ef">\<some\>\</font> \<font color="#eb144c">calls\</font> \[ \<font color="#ff6900">start date\</font> ] = \<font color="#9900ef">tomorrow\</font> in accounts will find all accounts that have one or more related calls that start tomorrow the \<font color="#9900ef">\<some\>\</font> can be omited, so typing \<font color="#eb144c">calls\</font> \[ \<font color="#ff6900">start date\</font> ] = \<font color="#9900ef">tomorrow\</font> gives the same result field names a field is referenced by its name if the name contains spaces or other special characters, enclose it in square brackets \[ ] if for some strange reason, the character ] is part of the actual name of the field, precede it with a backslash \ both system names and labels can be used when auto filling from a hint docid\ p4uiqlb6kdnaoydfb8uhb , quickquery uses the label variant if it's available, and automatically adds brackets and backslashes if they're needed fields in linked records to reference a field in a related module, write the name of the link, followed by a period , and then the name of the field link names follow the same rules as stated above (square brackets when special characters are involved etc ) quantifiers the query above searched for \<font color="#eb144c">accounts\</font> that have \<font color="#9900ef">some\</font> (i e at least one) \<font color="#eb144c">opportunity\</font> having \<font color="#fcb900">likely\</font> \<font color="#9900ef">\>\</font> \<font color="#3b9f0f">$25k\</font> however, you could easily want to search for accounts where all opportunities have \<font color="#fcb900">likely\</font> \<font color="#9900ef">\>\</font> \<font color="#3b9f0f">$25k\</font> this is what quantifiers are for quantifiers are written before the link name , and enclosed in < and > there are three quantifiers in quickquery \<font color="#9900ef">\<some\>\</font> at least one linked record satisfies the condition \<font color="#9900ef">\<all?\>\</font> all linked records satisfy the conditions or no linked records exist \<font color="#9900ef">\<all!\>\</font> all linked records satisfy the condition, and at least one linked record exists if you omit the quantifier, it is interpreted as \<font color="#9900ef">\<some\>\</font> difference between \<font color="#9900ef">all!\</font> and \<font color="#9900ef">all?\</font> the only difference between \<font color="#9900ef">\<all!\>\</font> and \<font color="#9900ef">\<all?\>\</font> is how they treat situations where there are no linked records \<font color="#9900ef">\<all!\>\</font> excludes those records, while \<font color="#9900ef">\<all?\>\</font> includes them think of the question mark ❓ as a " maybe exists? ", while the exclamation mark ❗as a " must exist! " to understand why this is useful, imagine you want to find out which accounts haven't been called in the past month in other words, \<font color="#9900ef">all\</font> \<font color="#eb144c">calls\</font> are \<font color="#9900ef">strictly before\</font> \<font color="#2166ae">last month\</font> \<font color="#9900ef">\<all!/all?\>\</font> \<font color="#eb144c">calls\</font> \[ \<font color="#fcb900">start date\</font> ] \<font color="#9900ef">strictly before\</font> \<font color="#2166ae">last month\</font> the question is, what quantifier should you use \<font color="#9900ef">\<all?\>\</font> or \<font color="#9900ef">\<all!\>\</font> ? well, let's think about it what if an account had no calls at all, ever ? that would certainly qualify as the type of account you would want to see on your list, wouldn't it? and that's precisely why \<font color="#9900ef">\<all?\>\</font> is there for you to use contrast that with the query on the picture above, which looks for \<font color="#eb144c">accounts\</font> where all \<font color="#eb144c">opportunities\</font> are expected to close the month after next, or later in that situation, it is obvious that you don't want to see accounts that have no opportunities it makes no sense and that's why you would use \<font color="#9900ef">\<all!\>\</font> the only thing you need to remember is this when searching by related fields, always think about how you want to treat situations where no linked records exist do you want to include them? use \<font color="#9900ef">\<all?\>\</font> do you want to exclude them? use \<font color="#9900ef">\<all!\>\</font> negating quantifiers let's take a look at the following two queries (we're in accounts) \<font color="#eb144c">tasks\</font> \<font color="#ff6900">description\</font> \<font color="#9900ef">not empty\</font> \<font color="#9900ef">not\</font> \<font color="#9900ef">(\</font> \<font color="#eb144c">tasks\</font> \<font color="#ff6900">description\</font> \<font color="#9900ef">empty\</font> \<font color="#9900ef">)\</font> obviously, both are somehow asking for \<font color="#eb144c">accounts\</font> where the \<font color="#eb144c">task\</font> \<font color="#ff6900">description\</font> isn't \<font color="#9900ef">empty\</font> however, there is a difference between the two the first query is easy to understand we didn't include a quantifier, so it's \<font color="#9900ef">\<some\>\</font> , which means that we're looking at \<font color="#eb144c">accounts\</font> where at least one \<font color="#eb144c">task\</font> doesn't have an \<font color="#9900ef">empty\</font> \<font color="#ff6900">description\</font> the second query is a little trickier the inside part denotes \<font color="#eb144c">accounts\</font> where at least one \<font color="#eb144c">task\</font> does have an \<font color="#9900ef">empty\</font> \<font color="#ff6900">description\</font> this is wrapped in \<font color="#9900ef">not ( )\</font> , which means it's the opposite however, the "oppositeness" doesn't only apply to the \<font color="#9900ef">empty\</font> part, it also applies to the \<font color="#9900ef">\<some\>\</font> part! to figure out what the opposite of \<font color="#9900ef">\<some\>\</font> is, it is useful to translate it to its technical meaning, which is "exists" in other words, the inside query is "a \<font color="#eb144c">task\</font> with an \<font color="#9900ef">empty\</font> \<font color="#ff6900">description\</font> \<font color="#9900ef">exists\</font> " the opposite of that is "a task with an \<font color="#9900ef">empty\</font> \<font color="#ff6900">description\</font> \<font color="#9900ef">doesn't exist\</font> " and if such a task doesn't exist, it means that either all linked \<font color="#eb144c">tasks\</font> have non empty \<font color="#ff6900">descriptions\</font> , or no linked \<font color="#eb144c">tasks\</font> exist at all whew! 🥵 math class ptsd flashbacks anyone? yeah, us too that's why we prepared the table bellow, where you can simply look up the negation of a given quantifier if you ever need it, and be done with it you can find some examples bellow as well quantifier technical meaning negation negated quantifier \<font color="#9900ef">\<some\>\</font> x at least one linked record exists that satisfies x either all linked records satisfy \<font color="#9900ef">not\</font> x or no linked records exist \<font color="#9900ef">\<all?\>\</font> not(x) \<font color="#9900ef">\<all?\>\</font> x every linked record satisfies x or no linked records exist at least one linked record satisfies \<font color="#9900ef">not\</font> x \<font color="#9900ef">\<some\>\</font> not(x) \<font color="#9900ef">\<all!\>\</font> x every linked record satisfies x either at least one linked record satisfies \<font color="#9900ef">not\</font> x or no linked records exist \<font color="#9900ef">\<some\>\</font> not(x) or "empty" (see example) bellow) example for \<font color="#9900ef">\<some\>\</font> the following two queries are equivalent example for \<font color="#9900ef">\<all?\>\</font> the following two queries are equivalent example for \<font color="#9900ef">\<all!\>\</font> the following two queries are equivalent quantifier ordering when using quantifiers, their order begins to matter take the following two queries for instance (we're in accounts) at first glance, we might feel that both should give the same result, but this is not the case the reason for this can be seen when you read those queries out loud the query on the left is saying "accounts where every opportunity id equals some opportunity id under that account" well, when you think about it, that's always the case! naturally, every opportunity id is equal to itself, so there will always be at least one opportunity id under that account which will match! however, the query on the right is saying "accounts where some opportunity id equals every opportunity id", which is a very different beast it means that one id must be the same as all the other ones , which basically means that they must all be the same! since ids are always unique, this can only occur when there is a single record, since that is the only situation where " one equals all "