Skip to main content

#Lookup Relationships0 discussing

0/9000
1 comment
  1. Mar 18, 2024, 9:14 AM

    check whether you have added the employee field in page layout.

0/9000
2 answers
  1. Feb 28, 2024, 5:36 PM

    Step 1: Create Lookup Relationship Field on Product 

    Step 2: Apex Script to Create Leads and Products 

    // Apex script to create Leads and Products and associate them

     

    List<Lead> leadsToInsert = new List<Lead>{

        new Lead(LastName='Doe', Company='Doe Inc.'),

        new Lead(LastName='Smith', Company='Smith LLC'),

        new Lead(LastName='Johnson', Company='Johnson Corp.')

    };

     

    insert leadsToInsert; // Inserting the Leads

     

    // Assuming the Leads are inserted and we have their IDs, create Products and associate them

    List<Product2> productsToInsert = new List<Product2>{

        new Product2(Name='Product A', Related_Lead__c=leadsToInsert[0].Id),

        new Product2(Name='Product B', Related_Lead__c=leadsToInsert[0].Id),

        new Product2(Name='Product C', Related_Lead__c=leadsToInsert[1].Id),

        new Product2(Name='Product D', Related_Lead__c=leadsToInsert[1].Id),

        new Product2(Name='Product E', Related_Lead__c=leadsToInsert[2].Id)

    };

     

    insert productsToInsert; // Inserting the Products

0/9000

I have created an LWC component which uses record-edit from. I have added this component in Aura App and called this aura app in VF page. Ihave called this vf page in list view button.

Now through this list view button is placed on opportunity page. In desktop mode i am able to use look fields ie. related account to an opportunity and create new records. But in salesforce mobile app, i am unable to use lookup filed ie related account in opportunity while creating new records using this list view button. So is lookup field not supported in salesforce mobile? Or is there any alternative.

#Salesforce_Mobile_App #Lookup Relationships

 

#Mobile Application Salesforce #Salesforce 

1 answer
  1. Manoj Nambirajan (Dell Technologies) Forum Ambassador
    Feb 16, 2024, 7:20 AM
0/9000

I'm building an app for a youth camp, so there are children, parents, teachers, volunteers, staff members and others involved.

Is it best practice to use the contacts object only with multiple record types or a separate object for each type of person?

If I use a separate object for each, which type of relationship should I house in the Contacts object? Or do I just pick one and it doesn't matter?

#Data #Best Practices #Lookup Relationships #Fields & Relationships
5 answers
  1. Ajaypreet Singh Saini (Grantbook) Forum Ambassador
    Feb 18, 2024, 1:58 AM

    Hey @Tom Rawling, I agree with Andrew.

    You should use the just contact with no separate record types for different relationships.

     

    You can use either picklist field as Andrew mentioned above or you can create a custom relationship object that will be related to the Contact object so that you can store the relationships there.

    This model is already utilized by Non-profit Success Pack (in the non-profit space) and here is the entity diagram to see the relationship between those 2 objects:

    https://architect.salesforce.com/1/asset/immutable/s/30bce1c/assets/images/data-models/nonprofit-success-pack-data-model.png

0/9000

I'm doing some practice tests for my admin exam and am a bit confused about the lookup field.

 

One record is "student" and the other is "enrollment". For every student account, there can be various enrollment records.

 

Which record do I create the lookup field on to track enrollment for each student?

 

I selected: Enrollment lookup field on Account, but the correct answer is Account lookup field on Enrollment.

 

Can someone explain how I know which record to put it on? Thank you!

 

#Trailhead Challenges  #Lookup Relationships  #Fields & Relationships

2 answers
  1. Eric Praud (Activ8 Solar Energies) Forum Ambassador
    Feb 15, 2024, 10:41 AM

    Hi Domenika,

     

    The lookup should then be on Enrollment.

    Think of it as a one-to-many. One being the Student and many being the enrollments since 1 student can have many enrollments against them

    The many is always where the lookup goes, so you can now enter the name of the same (one) student on multiple (many) enrollments

0/9000

Hi Team,

I'm creating a new lookup field but I encountered this error:

Cannot create new relationship. Each object can have no more than 40 custom relationships, including Master-Detail and Lookup relationships.

 

but we only have 39 lookup fields and do not have any Master-Detail relationship .

Many thanks for your advice!

6 comments
  1. Jul 2, 2021, 6:33 PM

    Did you try deleting them from your recycle bin as well? You may aslo have to ask SFSupport to delete them for you.

0/9000

Hey All! I have a question that I'm hoping someone could help with...

 

In Classic, when we created custom object records from related Contacts or Accounts, it would automatically fill in that Account (from Account record),  or Account and Contact (from Contact record). In Lightning, this does not happen. Is there a way that it needs to be set up, or do I need to look into creating a trigger to do so ahead of time?

1 comment
  1. Jun 18, 2020, 10:14 PM
    Going from classic to lightening I had issues with this; however you could trying updating the field to be formula to populate the related Account.
0/9000

Does anyone how to export / import lookup relationships with sfdx cli ?

I have successfully exported / imported account and contacts since they are in MD relationship but how do I export a lookup relationship

 

I am using sfdx force:data:tree:export and sfdx force:data:tree:import with the plan option

In the SOQL if I have SELECT Account__c FROM XXX I get in the export

Reference Account not found for Account__c.  Skipping record undefined

 

If I have Account__r.Id in the export, the export works but in the import I get

{"statusCode":"INVALID_FIELD","message":"Cannot reference a foreign key field Account__r.","fields":[]}

same error if I use an external field

 

Account__c is a lookup field and the accounts are already imported to the org

 

Exporting / Importing MD relationships works find

3 comments
  1. Apr 29, 2020, 2:28 PM
    Thanks, I will give the npm package a try. I find it quite remarkably that a normal lookup relationship with dot notation does not work in the standard cli.
0/9000

New post!  If you're relatively new to automation and your org has lookup relationships, you'll want to take a look at this one!

 

Part 3 of a "how I did this" series about cross-object field updates. This time we use Flow to help update an record once all related records meet a certain criteria in a Lookup Relationship.

Reciprocal Status Updates on Related Records (Part 3: Lookup Relationship)

0/9000