function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Ravi kumar 292Ravi kumar 292 

How to write a code

Hi all,

I have a requirement. I need to write a code based on a custom field of custom object. Custom object(XYZ__c) is lookup to Contact object and Contact is lookup to Lead Object.. for example

if(picklist field == 'test'){
    if(custom field == text value){
       String text ='done';
}

Here am confused that how to take the custom filed with relation..

Please help on this..
Mahesh DMahesh D
Hi Ravi,

If you can explain little bit more in detailed then it will be easy to help you.

Regards,
Mahesh
Prem Anandh 1Prem Anandh 1
Can you provide detailed information?
Ravi kumar 292Ravi kumar 292
Hi,

On Contact Oject i have a Lookup(Lead) field called Lead__c and On Custom Object(XYZ__c) also i have a Lookup(Contact) field called Contact__c. And Score__c is custom field on custom object(XYZ__c). Now i want to fetch the custom field from contact. Here am confused that how to fetch.

Now am writing trigger on Contact obejct whenever record is updated. In this trigger i need to write some calculation based on custom field(Score__c).

 
Prem Anandh 1Prem Anandh 1
As per your scenario you are going to udpate Child record field from Parent record(Contact). Are you going to update all the child records which is related to contact?  or any Specific records? 

if specific, any conditions are there?
Ravi kumar 292Ravi kumar 292
Hi,

IF(Sector__c=='Salaried'){
    IF(score__c >=600 && score__c<650){
        InterestRate = 12.00%;
    }

Here Sector__c picklist is in Contact object, Score__c is in XYZ__c custom object and InterestRate is in Lead object. Now based on Sector__c and Score__c, i need to update the InterestRate in Lead Object.
Can i fetch them by querying 3 objects seperately?? give me some example...


Thanks 
Prem Anandh 1Prem Anandh 1
Okay. Question is score__c field is coming from Child object but you are writting trigger on Contact(Parent). How you will decide score__c i.e which child record. 

Ex: 
Contact:  Test Contact 1 and it has 3 child record(XYZ__c) Child 1, Child 2 and Child 3. So which child record you consider for Score__c 
Ravi kumar 292Ravi kumar 292
Yes. That is wat am confusing here.. How to do?
Prem Anandh 1Prem Anandh 1
Please confirm with the requirement. As per my knowledge we can write trigger on XYZ__c but I am not sure about your entire requirement
Mahesh DMahesh D
Hi Ravi,

Still I am not 100% clear with the requirement, please provide us your full details.

Regards,
Mahesh