You need to sign in to do that
Don't have an account?
Sourav P
To Refer a field value from a child object under certain criteria
Dear All,
I have the below fields on Quote object ( parent) , Named Driver ( Child object). I have set up certain fields ( through formula and apex) which will take the minimum age driver from the list of driver records.
The extreme below field , takes the min driver number ID, and the first one is the hyperlink formula on that.
The first one is set as the formula,
Now i want that, which ever record number being set here, The account name * 2nd field) and the birthday from the NamedDriver will show here. I tried to create a PB , but its not working. Can you plz suggest how to goahead, thanks
Below is my PB i tried,
Criteria :
Action :
I have the below fields on Quote object ( parent) , Named Driver ( Child object). I have set up certain fields ( through formula and apex) which will take the minimum age driver from the list of driver records.
The extreme below field , takes the min driver number ID, and the first one is the hyperlink formula on that.
The first one is set as the formula,
HYPERLINK( Youngest_DriverT__c , Name_of_Driver__c )
Now i want that, which ever record number being set here, The account name * 2nd field) and the birthday from the NamedDriver will show here. I tried to create a PB , but its not working. Can you plz suggest how to goahead, thanks
Below is my PB i tried,
Criteria :
Action :
Hi Sourav,
Please use below line in the class:
Replace Accountname and DOB by API name on Quatation Driver(Named Driver) object.
oppList.add(new Quote(Id = objNamedDriver.Quote__c, Youngest_DriverT__c = URL.getSalesforceBaseUrl().toExternalForm() + '/' + objNamedDriver.Id,Name_of_Driver__c=objNamedDriver.Name,Young_Driver_AccountName__c =objNamedDriver.Accountname,Young_Driver_DOB__c=objNamedDriver.DOB));
All Answers
Hi Sourav,
Please confirm "Young Driver Account Name" is look up field to Account.
Also, Birthday field is on which object?
Thanks
Deepak
Young Driver Number, we got the same way that you have suggested earlier through the Apex and the formula field. But we too need the Account name & the DOB from the Named Driver object , i tried to change the apex code, but it didnt worked.
The two marked fields are on the Named Driver object (Young_Driver_AccountName__c & Young_Driver_DOB__c). The Young Driver aaccount name is just a text field.
But i have also created a lookup to Named Driiver field for try, as below
The earlier code suggested by you link :
https://developer.salesforce.com/forums/ForumsMain?id=9060G000000ICaeQAG
Thanks for your help .
The API name of objects which you have shared are on the quote object.
Please give the API name of same fields on Quatation Driver(Named Driver) object.
Hi Sourav,
Please use below line in the class:
Replace Accountname and DOB by API name on Quatation Driver(Named Driver) object.
oppList.add(new Quote(Id = objNamedDriver.Quote__c, Youngest_DriverT__c = URL.getSalesforceBaseUrl().toExternalForm() + '/' + objNamedDriver.Id,Name_of_Driver__c=objNamedDriver.Name,Young_Driver_AccountName__c =objNamedDriver.Accountname,Young_Driver_DOB__c=objNamedDriver.DOB));
Hi Sourav,
Did you try above solution?
Thanks
I tried as per below, but its showing me some issues. plz suggest.
Account__c , is the look up relationship on teh Named Driver object,
But while adding a named driver record, its showing the below error,
Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger DealTrigger caused an unexpected exception, contact your administrator: DealTrigger: execution of AfterInsert caused by: System.SObjectException: SObject row was retrieved via SOQL without querying the requested field: Quotation_Driver__c.Account__c: Class.OpportunityHandlers.aggregateResults: line 71, column 1
I just changes in few places ( or only in aggregate ? ) as below, If these OK ?
1. AggregateResult[] groupedResults = [SELECT MIN(AgeUpdated__c), Quote__c,Name,Account__c,DOB__c FROM Quotation_Driver__c where Quote__c IN :oppIDs GROUP BY Quote__c];
2. for (Quotation_Driver__c objNamedDriver : [SELECT Id,Name, AgeUpdated__c, Quote__c,Account__c,DOB__c FROM Quotation_Driver__c WHERE Quote__c IN :oppIDs ])
3. oppList.add(new Quote(Id = objNamedDriver.Quote__c, Youngest_DriverT__c = URL.getSalesforceBaseUrl().toExternalForm() + '/' + objNamedDriver.Id,Name_of_Driver__c=objNamedDriver.Name,Young_Driver_AccountName__c =objNamedDriver.Account__c,Young_Driver_DOB__c=objNamedDriver.DOB__c));
Its showing me the below error while saving the record,
Error: Compile Error: Field must be grouped or aggregated: Name at line 56 column 36
line 56 is, the No 1. in aggregate no.
Thanks
Hi Sourav,
Is the issue resolved?
I kept aggregate as same,
and changed in teh last two points, Able to save it now, but the values are not coming , plz suggest
Please check DOB and Account Name on Quotation Driver record is filled or not.
Maybe they are blank.
Hi Sourav,
Were you able to find the real cause?
If not please let me know
Hi Sourav,
Please elaborate. I didn't get you.
also till , i am not able to get the values, i refreshed the page here,
and , all are maintained in the Named driver object. shall we need to change somthing in the code? DOB is a fomula field here which is coming from account. and below i have created another account name field which is as well a formula field. but we are taking the first look up account field one. I think it shd work,isnt it.
Young Driver Account Name Young_Driver_AccountName__c Text(255)
Young Driver DOB Young_Driver_DOB__c Date
Hi Sourav,
I have tried in my org. Its working fine.
When I used Account__c it gave account id.
Then I use Account__r.Name then it gave me Account name easily.
Did you try to insert, update or delete Quotation driver records?
Hi Sourav,
Did you try?
The name is not coming,
i just tried my formula field ( But i think account__r.name would have been better) as below
" Account_name__c"
and,