i've a custom object Score has to be rollup to grand parent Account. Score-project-account is the lookup currently. How to get count of a field of score onto account?
123486
I have three different objects A (Grand Parent), B (Child) &amp; C (Grand Child). All the three objects are related by a lookup relationship. Now, there is field on A object, IsActive which is a checkbox and another field IsEligible on object C which is also a checkbox.  Now, if any of the Grandchild associated with A is having IsEligible marked as TRUE, then IsActive on the A's record should be marked as TRUE . If none of the Grandchild records are having IsEligible marked as TRUE, then IsActive should be marked as FALSE.  Parent - A Child  - B1, B2 GrandChild - C1, C2 associated with B1 &amp; C3, C4 associated with B2.  If either of the records, C1, C2, C3, C4, has IsEligible = TRUE, then IsActive = TRUE on A. If neither of the records, C1, C2, C3, C4, has IsEligible = TRUE, then IsActive = FALSE on A.  How can this functionality be achieved?
117047
I've to Query a field(e.g X) from one object. Say I'm getting 20 records(LIST)  Now, I've to Query another object using result of above Query using field X  (X field is common to both objects but has different names, say here Field1 and Field2)  What is the easiest way to get data in Developer console ? is below correct   List&lt;string&gt; TP;  List&lt;ObjA &gt; Ds1=  [Select id, name , TPID__C       from QRS_Quote_LOC_Plan_Bundle__c      where Field3 = '1111']; // Field3 is some another field  For(ObjA  b : Ds1 )  TP.add(b.Field1); // storing common field data  List&lt;ObjB&gt; MasterD = [Select id, name from ObjB where Field2 in :TP ]; System.debug(MasterD );
23445
I am looking to get a count on the polygonNieghbor and if it has polygons in it then I want to move to the next step MakeFeatureLayer. and If it doesn't have any features I would like it to finish.   Is there any other way to do this?      arcpy.GetCount_management(PolygonNeighbor_TableSelect) arcpy.AddMessage(arcpy.GetMessages())  if arcpy.GetCount_management(PolygonNeighbor_TableSelect) &gt; 0:     arcpy.MakeFeatureLayer_management(MapUnitPolys, inFeatures_lyr)  else      print "done"
51103
I am populating a junction object on from Events and want to capture info from the Event but getting the Account from Account field pulls null. Same who the name via the Who. But if I query the Event record, the AccountId field is populated. And of course, the code compiles properly. Can someone explain how to grab this related info?  trigger TripMeetingFromMeeting on Event (after insert, after update) {      Set&lt;id&gt;EventId = new Set &lt;ID&gt;();     List &lt;Trip_Meeting__c&gt; TMS = new List &lt;trip_meeting__c&gt;();      for (Event E:trigger.new){         if (e.Business_Trip__c!=null){             TMS.add(new Trip_Meeting__c(Meeting__c =e.id, Business_trip__c=e.Business_Trip__c,                                         Meeting_Date__c=e.ActivityDate, Meeting_subject__c=e.Subject,                                        TripNameDELETE__c=e.Business_Trip__r.name,                                         mWhatID__c=e.Whatid,                                        Meeting_Company__c=e.Account.name,                                        Meeting_Name__c=e.Who.name)                                         );          }     }     system.debug('TMS!!!============================'+TMS);      Database.insert(tms, false);  }
33726
Is there any way that we can put the date filter on child record (like created in last one year) while creating roll-up summary field? I want to count only those child records which are created within last one year. I tried it by creating formula field on child object  but it does not appear while filtering the records (As per the doc: Automatically derived fields such as current date or current user are not allowed in roll-up summary fields). Any workaround if someone face this issue before ?
70437
How do reference a related object within a Salesforce Trigger?  I am creating a record for a related object and need to assign a value to one of the fields in the new related object (relatedOject1) from a second related object (relatedOject2).  I understand that a parent or related object is not returned in the list.  I wrote o.relatedObject2__r.Name below to illustrate the intended data to be returned at this point.  trigger objectTrigger on object__c (after insert) {      List&lt;relatedObject1__c&gt; ListToInsert = new List&lt;relatedObject1__c&gt;();      for (Order__c o : Trigger.new) {         relatedObject1__c ro = new relatedObject1__c();         ro.Type__c = 'New Customer';         ro.RecordTypeId = '0121a000000e8sX';         ro.relatedOject2__c = o.relatedObject2__c;         ro.Description__c = 'Open Order:'+o.relatedObject2__r.Name+'  Date: '+o.Date__c;         ro.object__c = o.Id;         ListToInsert.add(ro);     }      if(ListToInsert.size() &gt; 0) {         insert ListToInsert;      } }
24631
I have a custom object that has various record types. How would I construct URLFOR statement to take me to the new action for a particular record type?  URLFOR($Action.Relationship_Detail__c.New)  The RecordType I want to go to is called AccountAccountRelationship in the Record Type Name field  Also I feel like I should mention that this is part of an outputLink and the value is being set to this URLFOR
123645
According to the documentation  in order to retrieve a list of picklist values for an object we need to pass in a Record Type Id which can be retrieved using the getObjectInfo method.   The issue is that these are both wire functions and I cannot figure out how to chain these methods.  If I try code like the following:  getObjectInfo({ objectApiName: ACCOUNT_OBJECT })             .then(result =&gt; {                 return getPicklistValues({recordTypeId: result.defaultRecordTypeId, fieldApiName: TYPE_FIELD});             })             .then(result =&gt; {                 this.picklistValues = result.data             })             .catch(error =&gt; {                 this.error = error;             });   I get an error      render threw an error in 'c:getpicklistexample' [Imperative use is not   supported. Use @wire(getObjectInfo).]   If I try something like   @track rtId;      @wire(getObjectInfo, { objectApiName: ACCOUNT_OBJECT })     handleResult({error, data}) {         if(data) {             this.rtId = data.defaultRecordTypeId;         }     }      @wire(getPicklistValues, {recordTypeId: this.rtId,fieldApiName: TYPE_FIELD})     picklistValues;   Then it throws an internal server error. Anybody have an idea as to how I could retrieve the record type Id and then call to get the pick list values like the documentation suggests?  FYI my imports are:  import { LightningElement, wire, track } from 'lwc'; import { getPicklistValues, getObjectInfo } from 'lightning/uiObjectInfoApi'; import TYPE_FIELD from '@salesforce/schema/Account.Type'; import ACCOUNT_OBJECT from '@salesforce/schema/Account';
123199
A->B are two objects connected using lookup relationships. If somehow, I get read only access to child record but do not have access on parent record then still i am able to see data from parent record through formula fields. Similarly will SOQL in Apex also allow me to fetch fields from parent record regardless of using 'WITH Sharing ' keyword at class level?
26472
We have an object (let's call it Child) with a formula field that does a lot of checking of various fields and spits out a numeric result (estimated number of days some work will take, based on a bunch of flags and conditions).  Another object (Parent) has multiple Children related to it through a lookup.   I wrote an apex class that aggregates the Children of a Parent in various ways based on several fields, including the formula result. I now want to test that logic, but when I try to create some sample Children to feed into my test, I'm told that I can't write to formula fields.  I don't want to figure out how to build a tree of objects and set specific fields to get the value I want to test from the formula field. Furthermore, the formula has a limited set of results, which may change in the future (say, the business decides that some particular type of work takes 8 days instead of 10). I want to test various edge cases that the formula can't produce today.   What's the best approach to this?
115603
How to find Accounts with no child Accounts? I tried Aggregate Query but its not returning proper result and inner query isn't supported for Self-Relation. Thoughts?
38431
I have More amount of Records in salesforce, i have created field as not Unique.So for account Records is created with duplicate Records also,I want to check how many Records contain dulplicate Records  for that I have wrote Query : I have lot of account records, i don't want to use limit for filtering the records when querying, i want to query all the records in salesforce.  But when i use:  SELECT JDE_ship_to_account_no__c, count(Id) records FROM account GROUP BY JDE_ship_to_account_no__c HAVING count(Id) &gt; 1   for that they suggested answer for this question:    How to write a batch apex code for above scenario, account records contain duplicates or Not?  I want to check all the records whether the record contain duplicates or Not
19790
Please Help me...  Account sObject is Parent of Attachment. Now I want to bring Read-only Field Custom field (isReadOnly__c).  SELECT Id, Name, Account.isReadOnly__c FROM Attachment   How It Gets ?  Thanks in Advance  Manu
52330
Situation: I am trying to build a custom validation rule via apex that will stop users from saving a charge item to a quote if the   charge item exceeds the available product quantity. The charge item   being saved is a child of (and has a lookup relationship to) a "Rate   Plan", which is the object that carries the available product quantity   field.      Object that triggers apex: zqu__QuoteCharge__c      Relationship field on QuoteCharge: zqu__ProductRatePlanCharge__c     The trigger is currently in the BEFORE INSERT context, to block users from saving new records. I pass Trigger.new as a parameter to my class/method: z_QuoteChargeTriggerHandler.customValidation(Trigger.new);    In my for() loop, I've added a bunch of System debugs since my if statement wasn't being triggered.   When I System.debug(zqu__ProductRatePlanCharge__c) it returns an Id, so I know the relationship is there.   However, when I System.debug(zqu__ProductRatePlanCharge__r.Ascent_Quantity__c) I return null. Expected: 0.     Ultimate Question: Since I cannot SOQL query this record during BEFORE INSERT (At least, I think so, since the record hasn't been   inserted yet?) How can I reference related objects using the __r   relationship before insert of a new record in the context of   Trigger.new?   Code:  public void customValidation(List&lt;zqu__QuoteCharge__c&gt; newList){     if (newList != null &amp;&amp; newList.size() &gt; 0){     List&lt;zqu__ProductRatePlanCharge__c&gt; rpc = new List&lt;zqu__ProductRatePlanCharge__c&gt;(); // create a list per other Stack suggestion         for(zqu__QuoteCharge__c quoteCharge: newList){             if(quoteCharge.Name != 'Discount'){                 rpc.add(quoteCharge.zqu__ProductRatePlanCharge__r); // add to that list?                 System.debug('MM++++ rpc: ' +rpc); // rpc returns null but shouldnt?                 System.debug('MM++++ Charge Name: ' +quoteCharge.Name);                 System.debug('MM++++ Charge Quantity: ' +quoteCharge.zqu__Quantity__c);                 System.debug('MM++++ RatePlan Link: ' +quoteCharge.zqu__ProductRatePlanCharge__c); // returns ID (Lookup, expected)                 System.debug('MM++++ RatePlan Name: ' +quoteCharge.zqu__ProductRatePlanCharge__r.Name); // returns null (expect name)                 System.debug('MM++++ Ascent Quantity: ' +quoteCharge.zqu__ProductRatePlanCharge__r.Ascent_Quantity__c); // returns null (expect: 0)                  if(quoteCharge.zqu__ProductRatePlanCharge__r.Ascent_Quantity__c == 0 || quoteCharge.zqu__ProductRatePlanCharge__r.Ascent_Quantity__c &lt; quoteCharge.zqu__Quantity__c){                     quoteCharge.addError('The Product: ' +quoteCharge.Name + ' only has ' +quoteCharge.zqu__ProductRatePlanCharge__r.Ascent_Quantity__c + ' in stock but you are trying to sell ' +quoteCharge.zqu__Quantity__c);                 }             }         }             } }
109966
i have posted this question earlier but i'm not getting the proper solution  please read the requirement carefully.* i have a custom object Integration__c and it has fields username__c,password__c,url__c,account__c(lookup field) fields. and Integration__c has some records.   here comes my requirement is i have created a trigger on Case object as after insert event. 1.when case creating must be select an account lookup field with one salesforce account. 2.now after clicking the save button it will check with Integration__c custom object records with the matching account field in case record. 3.if any record is in the Integration__c is match with the case object account field then returns the field values of integration__c from that record only. for that i have developed a trigger on Case : trigger Type on Case (after Insert) {      List&lt;ID&gt; cIds = new List&lt;ID&gt;();           Set&lt;String&gt; lst_accountName = new Set&lt;String&gt;();     List&lt;String&gt; allaccountnamesList = new List&lt;String&gt;();          //Map&lt;ID, Integration__c&gt; mapIds = new Map&lt;ID,  Integration__c&gt;();                           for(Case cObj : Trigger.new){                        if(cObj.Account.Name != null &amp;&amp; cObj.IntegrationTo__c != null){                                cIds.add(cObj.Id);                                } lst_accountName.add(cObj.Account.Name);                        }allaccountnamesList.addAll(lst_accountName );                  List&lt;Case&gt; cas = Trigger.new;          List&lt;Integration__c&gt; listAll = [SELECT id,name,username__c,password__c,URL__c,account__c,integrationwith__c FROM Integration__c ];                      for(Case c : cas  ){             for(integer i=0; i&lt;=listAll.size();i++){                     if(listAll.get(i).IntegrationAccount__c.contains(c.Account.Name)){                                                                                                                                          String name = listAll.get(username__c);                      String pwd = listAll.get(password__c);                      String url = listAll.get(URL__c);                                                                        }        }    } }  How can I get the only matched account field value on case with any of the records in Integration__c, then return the record  details from that record only? when i saving the above code it shows an error called :  Error: Compile Error: Variable does not exist: username__c at line 32 column 48
24554
I have a lookup relationship.  If I just do the following query it works fine:  Sobject c = [select field__r.fieldchild__c from custom_obj where Id = :someId]; system.debug('c:' + c);   However with the following I get an error:  Sobject c = [select field__r.fieldchild__c from custom_obj where Id = :someId]; String c2 = (String) r.getSobject('field__r').get('fieldchild__c');   Error message:     FATAL_ERROR System.NullPointerException: Attempt to de-reference a   null object
83578
i need to count total number of records in an sObject which can have around one million records. Will the code below work ? If no, how can this be done ? I dont need to use this in a vf page.   I will be using this COUNT() SOQL Query in a batch class which is scheduled to run at specific time.  AggregateResult results = database.query('SELECT COUNT(id) result FROM someSObject');     System.debug('No of ids are: '+results.get('result'));