1

I have 2 custom objects: Package and item. Each package can have multiple items, and I know that when I create a new package.

I tried to have a lookup field on package to display items. - But that's wrong as there can only be one item.

p.s. - each item can only be shipped once.

so I will create a lookup field on item - to let know the package.

But I need that to be created from the package side. e.g.: when I create a new package, I add to that 1-50 items. Each item should display that it was shipped with a certain package.

How can I automate that part?

2

Alternately, are you asking how to best to this through the UI? Adding multiple related records one at a time is a pain. There are tools to help with that. My personal favorite is GridBuddy: https://appexchange.salesforce.com/listingDetail?listingId=a0N300000055r6aEAA (<-- free version with limitations, but there's a paid version that's also awesome)

| improve this answer | |
1

If I understand correctly:

You'd create a lookup from Item to Package. Thus package will have a related list of Items from where you can create a new Item related to the package.

So, at this point the item will already show the package, if you need additional info you could use formula fields.

If you need to limit that each package only can had 1 x each item type, you'll need to do that with an apex insert trigger on the item object.

| improve this answer | |
  • thanks. I want to add multiple items to a package with ease. Not one by one, as some may have 50 + items. some automation is needed. – Saariko Dec 25 '13 at 9:34
  • 1
    Ah, then as far as I can think of right now, you're gonna need visualforce. But there could be things and tricks I'm unaware of. – Samuel De Rycke Dec 25 '13 at 9:44
  • If I understand this correctly, when a new Package is added to the database, you want to default it to 1-50 Items (where the number of Items depends on something about the Package)? This can be done either with a VF controller extension that handles the SAVE action and does DML inserts of Items, or by an After insert/update trigger that does the DML inserts of the Items. Choice depends on whether you want the behavior only for user interaction via a New Package - Save sequence or for all package inserts, including from Data Loader, the API, custom web and Rest services as well as the UI – cropredy Dec 27 '13 at 2:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.