Trying to learn Apex and i'm stuck with triggers. I have three objects:  Jet__c and field Total_flied_hours_on_jet__c; Customer__c and field Total_Flied_Hours__c; Booking__c - Junction object and field  Status__c;  I want to whrite a triger when we creating a record on Booking__c, automatically set booking Status__c if Customer__с.Total_Flied_Hours__c &gt;= Jet__c.Total_flied_hours_on_jet__c. My Trigger: trigger BookingTrigger on Booking__c (before insert) {     if(Trigger.isBefore){         if(Trigger.isInsert){             BookingTriggerHendler.bookingApproval (Trigger.new);         }     } }  My Booking Trigger Hendler: public class BookingTriggerHendler {      public static void bookingApproval (List&lt;Booking__c&gt; newList) {         for(Booking__c bookingStatus : newList){             if(bookingStatus.Customer__r.Total_Flied_Hours__c &gt;= bookingStatus.Jet__r.Total_flied_hours_on_jet__c) {                 bookingStatus.Status__c = 'Automatically Approved';             }         } }  I dont know how to get record Ids, and put them in to the map &lt;Id , sObject&gt;. Pls help me
This is a canonical question and answer developed by the community to help address common questions. If you've been directed here, or your question has been closed as a duplicate, please look through the resources here and use them to shape more specific questions. To browse all canonical questions and answers, navigate to the  tag. This question and answer is owned by the community! If you can improve it and make it more useful, you're welcome to edit it. I am building a trigger, a unit test, or other Apex code. I'm working with sObject records, and trying to access related record information. For example, I might have a structure like this: Account a = new Account(Name = 'Test'); insert a;  Opportunity o = new Opportunity(Name = 'Donation', AccountId = a.Id); insert o;  System.assertEquals(o.Account.Name, 'Test', 'Correct Account associated'); // Assertion fails!  Or, in a trigger, I might be aiming for something like this: trigger ContactTrigger on Contact (after insert) {     for (Contact c : Trigger.new) {         if (c.Account.Name == 'Test') {             // Take some action here         }      } }  Why doesn't this work? Why am I getting null values, or NullPointerExceptions?
I know that its is the possessive and it's is the contraction, and know when to use them.  But why doesn't the possessive have an apostrophe?   "The bear's eating a fish." [contraction] "The bear's coat is brown." [possessive] "It's eating a fish." [contraction] "Its coat is brown." [possessive] "One's eating a fish." [contraction] "One's coat is brown." [possessive]    lists the etymology as "From  +‎ ", and  says that this is actually the original form:     Originally written it's, and still deliberately spelled thus by some writers until early 1800s.   So what happened to the apostrophe?  When did people stop using it, and why did they?  It seems that it's as the possessive is more natural, as most people do this until they're taught that it is wrong (or even after).  Update: Online Etymology Dictionary has been updated to include two potential explanations:     The apostrophe came to be omitted, perhaps because it's already was established as a contraction of it is, or by general habit of omitting apostrophes in personal pronouns (hers, yours, theirs, etc.).   Can anyone back up either of these arguments?  The possessive one's still has the apostrophe, despite these. $\operatorname{tr}(A)=\operatorname{tr}(A^{2})= \ldots = \operatorname{tr}(A^{n})=0$ implies $A$ is nilpotent Add Fake Display when No Monitor is Plugged In I have an Ubuntu 14.04 server that has no external monitor connected.  I use NoMachine to remote control the machine.  When I do so, the Unity/Gnome interface doesn't see any monitors connected, so I can only use 800x600 when connecting with NoMachine.  If I plug in a monitor, I can set the resolution to whatever size the NoMachine window is on the remote computer.  Is there a way to create a "fake" monitor device on Ubuntu so I can set a desktop resolution in Unity/Gnome? Error in Obj-C : Expected identifier or '(' How to make a process invisible to other users? How could you launch a process and make it invisible to the top command? The process is started by a normal user (not root), and should not be visible to other normal users. Sum of $k {n \choose k}$ is $n2^{n-1}$ Proof that $\suṃ̣_{k=1}^{n}k {n \choose k}$ for $n \in \mathbb N$ is equal to $n2^{n-1}$.  As a hint I got that $k {n \choose k} = n {n-1\choose k-1} $.  I tried solving this by induction but, in the inductive step I'm not arriving to the correct result. I have a Category entity which has a Nullable ParentId field. When the method below is executing and the categoryId is null, the result seems null however there are categories which has null ParentId value.  What is the problem in here, what am I missing?  public IEnumerable&lt;ICategory&gt; GetSubCategories(long? categoryId) {     var subCategories = this.Repository.Categories.Where(c =&gt; c.ParentId == categoryId)         .ToList().Cast&lt;ICategory&gt;();      return subCategories; }   By the way, when I change the condition to (c.ParentId == null),  result seems normal. How do I turn off some formats in GeoServer's WMS? What is the difference between a gameplay programmer and a game designer/developer? Problem with gummy-bears being too much like jelly I've been trying a simple recipe I found on the internet, which is a simple recipe consisting mostly of gelatin.  The problem is that the end result is basically just a fruit-flavoured jelly (Jell-O?), rather than the more chewy gummy-bears (Haribo) style of jelly confectionery.  Can anyone suggest what I need to do to make them less springy and more chewy.  It's all difficult to articulate!  Here's what I used for the first test-batch:   12 tbsp sugar 12/3 cup fruit juice 8 tbsp Golden Syrup 8 tbsp gelatin   soften the gelatin in 1/2 cup of cold water. place sugar, syrup and the juice in a pan and gently heat until sugar dissolves. Stir in the gelatin and stir until dissolved. Pour into moulds and wait until set.    Thanks Prove the existence of an analytic function Let $\Delta=\{z\in \mathbb C: |z| &lt; 1\}$. Let $f: \Delta \rightarrow \mathbb C$ be a one-to-one analytic function fixing the origin. Prove that there is a one-to-one analytic function $g: \Delta \rightarrow \mathbb C$ such that $[g(z)]^2=f(z^2)$. Further, show that such a function is odd.  The only idea which comes to my mind is the following (not sure whether it is the right direction though). Let $h: \Delta \rightarrow \Delta \rightarrow \mathbb C,\ z\mapsto z^2\mapsto f(z^2)$. Note that $h'(0)=0,\ h''(z)=2f'(z^2)+4z^3f''(z^2)$; since $f$ is one-to-one and analytic, its derivative never vanishes, so $h''(0)\ne 0$. So $h$ is an analytic function of $\Delta$ with a zero of order two at the origin. Then there is an analytic function $g$ defined in an open disc about the origin with a simple zero at the origin such that $[g(z)]^2=f(z^2)$.   This is the only thing I came up with, but it seems to be a little bit irrelevant since I don't see any way of extending this $g$ to the whole $\Delta$, and also the injectivity and oddness of such a $g$ are unclear. In how many ways can we pick three different numbers out of the group $1,2,3,\dots,100$ such that the largest number is larger than the product of the two smaller ones? (The order in which we pick the numbers does not matter.) Why aliases in a non-interactive Bash shell do not work Getting inverse of a transposition key Some of you might insist that it was not a murder, as we know that a rebounding spell had hit Ariana, as shown in .  However, a death in such a well known family would not go uninvestigated, I presume. Were the Dumbledore brothers investigated? How did they get away with their sister suddenly dropping dead?  I'd think that Ministry of Magic has means to recognize a death caused by magical means. That's how we know that Tom Riddle Snr. was killed by Avada Kedavra. So Ariana's failing health might be a poor excuse. My Déjà Dup backups have become quiet large and I noticed they contain a huge number of unnecessary files (e.g. *.pyc files, **__pycache__ folders and other build related temporary stuff).   I know that I can ignore specific folders, but is there a way to exclude files and or folders by patterns?  I thought there might be more options usable trough a configuration file, but Déjà Dup doesn't use one. So I looked at duplicity (the CLI it is based on), but the man page doesn't mention a configuration file either. I know that duplicity can ignore files and folders based on patterns (--exclude, --exclude-filelist), but I have no idea how to combine this with Déjà Dup.  Do I have to ditch Déjà Dup and use duplicity manually? Or is there a way to set the needed options, so that they are used automatically, when duplicity is used by Déjà Dup? I was drinking iced-water from a drinking glass (made of glass) at a restaurant yesterday when I was taking a drink, I noticed that there is very little ice water coming out and then suddenly, the ice water mixture comes crashing down. With my open mouth overfilled with ice water, my shirt gets wet – I hate when this happens. After drying myself off, I started thinking why this does happen:   How does ice that starts off loose and separated in water fuse together to form one large clump? What causes the ice-water mixture to stop flowing momentarily and then suddenly starting flowing again? Is it that the ice fuses together in the glass and forms one large clump, and then the friction with the edges builds a "dam-like" situation? Or are there individual pieces of ice fusing with the edges of the drinking glass damming-up the ice? Math Induction Proof: $(1+\frac1n)^n < n$ So I have to prove:      For each natural number greater than or equal to 3,   $$(1+\frac1n)^n&lt;n$$   My work: Basis step: $n=3$ $$\left(1+\frac13\right)^3&lt;3$$ $$\left(\frac43\right)^3&lt;3$$ $$\left(\frac{64}{27}\right)&lt;3$$ which is true.  Now the inductive step, assume $P(k)=\left(1+\frac1k\right)^k&lt;k$ to be true and prove $P(k+1)=\left(1+\frac1{k+1}\right)^{k+1}&lt;k+1$.   This is where I am stuck because usually you add or multiply by $k+1$ or some similar term. A high-reputation, highly-active user has already been dinged once for a sockpuppet, and I just dinged him again. He probably has another sockpuppet as well.   What are the guidelines for handling users who game the system in this fashion? Specifically,   How can I be sure I'm looking at a sockpuppet? When should sockpuppets be considered a problem? How should moderators handle problematic sockpuppets once they've been identified? I was suspended for sockpuppetting and feel this is unfair using a:hover to change the color of an image