You need to sign in to do that
Don't have an account?
Boris Vaser
How to make my custom object to be "1 to many" ?
Hello, I am new here and I am having some difficulties.
I need to build shop that sells items to the end customers.
My data model is :
1. custom objects: Customers, fields: user name, phone and email.
2. Items, fields:name, count, price and image.
3. Reservation, fields : master-detail to items, master-detail to customers and a date.
As it now, I am able to make a reservation just for 1 item to 1 customer. I need to to make it that customer will be able to buy more than 1 item.
What changes I need to do for that ?
Thank You!
I need to build shop that sells items to the end customers.
My data model is :
1. custom objects: Customers, fields: user name, phone and email.
2. Items, fields:name, count, price and image.
3. Reservation, fields : master-detail to items, master-detail to customers and a date.
As it now, I am able to make a reservation just for 1 item to 1 customer. I need to to make it that customer will be able to buy more than 1 item.
What changes I need to do for that ?
Thank You!
Just change master-detail relationship to lookup relationship.
For more information;
https://www.salesforce.com/developer/docs/api/Content/relationships_among_objects.htm
Go to the item object creat a lookup type field and select the Lookup Object as Customer Object.
You are done !!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Now every item you create can be linked to a customer and Customer can have multiple Items.
Let me know if you have any question.
Have a look on below links.
Relationships Among Objects
https://www.salesforce.com/developer/docs/api/Content/relationships_among_objects.htm
How do I create a hierarchy (parent/child relationship) within the same object?
https://help.salesforce.com/apex/HTViewSolution?id=000005141&language=en_US (https://help.salesforce.com/apex/HTViewSolution?id=000005141&language=en_US)
Don't forget to select best answer to make our efforts visible in the developer forum.
Please mark this as solution by selecting it as best answer if this solves your problem, So that if anyone has this issue this post can help.
,
but I still cannot create more than item in a new reservation:
it allows me just 1 item. :-\\
You can built your data model as below .
Shop (Master ) Item is child , means a relationship field in Item to Shop .
Shop (Master ) Customer Child , means a relationship field in Customer to Shop .
Customer(Master ) item child , means a relationship field in Item to Customer .
If you will build like above then one shop can have more then one customer and more then one Item
And one customer can have more then one item as well .
It can be master detail or look up that depends on you .
If you want to make the relationship always mandatory in child object or any rollup field in master object then you can go for master detail else go for look up ,Both relationship is for one to many .
Thanks
Manoj
I want to do that in 1 Reservation I will be able to choose more than 1 item for the same customer.
Do you have lookup relationships as Manoj has pointed above?
If yes then you can create many records of records and can select same Customer means that your customer can have more than one Item.
Similarly if you have the relationship between shop and customer that means you can have many customers for a single shop.
Now I will discuss a simple realtime problem.
Suppose I have 10 items say Biscuits,Coldrinks,Dry fruit etc
And my customer wants to buy them all.
What you need to do just display the products on the site with add button once the customer clicks the add button.
Just you need to update the field of Customer on the Item record.
Update it with the Id of the customer.
Now go to customer and goto the item related list you can see the Items added by the customer.
Hope this makes things clear.
Don't forget to select best answer to make our efforts visible in the developer forum.
Please mark this as solution by selecting it as best answer if this solves your problem, So that if anyone has this issue this post can help.
if I understand you all, I need that a customer will add many items and than i will make 1 reservation for that customer with all his items.
Please check your Schema if the relationship is like below it will work .
Thanks
Manoj
this is my schema right now, but when I create new "shop", I can just pick a date, and inside it I have to choose customer and items,
when I go to Item, I cannot pick my items that already exist, it wants me to create new item.
I want it to be: when I create new "shop" I will have to choose the customer and the list of the items.