3

Parent List has a lookup with multiple promotional items. Once user chooses a promotional item, I want user to be able to add a quantity to that specific item. User should be able to select Multiple items, and assign unique quantities to each item. Any help would be great!!

Brenton Pierce
  • 193
  • 8
  • 21

2 Answers2

3

I would suggest to consider the following solution:

  1. Create a list "Quantities" with three columns: Title, Promotional item, Quantity. The Promotional item column, obvioulsy, is the lookup to the list with promotional items.
  2. Create a multilookup column Items with quantities in the Parent List, which points to Title column of the "Quantities" list
  3. Create a special control for editing the Items with quantities column (see details below)
  4. Using custom ListFieldIterator, override standard control with your custom control.

The most curious thing here is the mentioned custom control for displaying "Items with quantities" column. It would look something like this:

enter image description here

When you press -> button, the control should create a new item in the "Quantities" list, by using EcmaScript client object model, and set initial values as follows:

  1. Title = PromotionalItemTitle + "(" + DefaultQuantity + ")"
  2. Quantity = DefaultQuantity
  3. Promotional item = PromotionalItemId

Each time you change quantity, the control must update the corresponding item in the "Quantities" list, following way:

  1. Title = PromotionalItemTitle + "(" + NewQuantity + ")"
  2. Quantity = NewQuantity
  3. Promotional item remains unchanged

Thus, since the Items with quantities column is linked to the Title column of the "Quantities" list, values of this column will be displayed by default as "[Title] ([Quantity])", this is I assume quite acceptable. Hence, you will be able to avoid any display customizations.

Andrey Markeev
  • 16,286
  • 3
  • 40
  • 70
  • This is great!! any guidance on creating custom control. Yes I am new to sharepoint dev...

    I am also working in Sharepoint Designer, do I need to create custom controls in Visual Studio first? then apply them in Designer?

    – Brenton Pierce Feb 03 '12 at 19:59
  • Brenton, I think it's possible to implement this solution even without Visual Studio. You can create custom edit and new forms, and with help of js (or better jquery) improve the original, OOTB multilookup control, adding handlers to it's buttons and overriding it's right select with some cool div. – Andrey Markeev Feb 03 '12 at 20:18
  • I think that is a great solution. However, I am not even sure where to begin with the editing of this form. I am well versed with jquery, but where does one even get to the code from designer?? Sorry in advance for the hand holding!! – Brenton Pierce Feb 03 '12 at 20:24
  • You can add a custom jQuery to any list form by switching the form page into Edit mode, adding Content Editor WebPart to the page, and then adding <script> tag there. To achieve this, you will need to edit HTML source (Ribbon -> Editing tools -> Format Text tab -> HTML -> Edit HTML source) – Andrey Markeev Feb 03 '12 at 20:45
  • Ok, I am in there, Do i need to call the "ListFieldIterator" class in this layout, or is that a property i set in the multiple lookup? – Brenton Pierce Feb 03 '12 at 20:51
  • You won't need ListFieldIterator if you decide to use only SPD. Information about how to create custom list forms in SharePoint Designer can be found here: http://office.microsoft.com/en-us/sharepoint-designer-help/create-a-custom-list-form-using-sharepoint-designer-HA010378258.aspx#BM2 – Andrey Markeev Feb 03 '12 at 20:52
  • And the last note: please try to resolve simple questions in Google or by probing them yourself first, and only if you fail, you should then go here and create a separate question and articulate your particular problem. Also, please don't forget to accept and upvote the answer if it was correct. – Andrey Markeev Feb 03 '12 at 20:53
  • @omlin: +1 Including the quantity in the other list's title so that it shows in the lookup is a very cunning plan. – Stu Pegg Feb 03 '12 at 21:53
  • Thanks, actually I came to this idea after reading your answer (btw it was I who added +1 to your post ;).. ), because I found that it is not possible to display quantities using XSLT or even custom field type in a list view, because you will not have enough data for this and querying data each page load is not acceptable of course (1 request per row, just imagine!!). – Andrey Markeev Feb 03 '12 at 22:03
  • @omlin: Thanks for the vote. :) I was thinking that it would be possible to use the multi-value column functionality in a CFT to store the data in the column itself (possibly as key/value pairs); avoiding the third list altogether. Both CAML and XSLT will let you extract such multi-values by number. – Stu Pegg Feb 04 '12 at 17:53
  • @omlin I actually ended up using ECMAScript to pull in the list items, then JQUERY to add them to a select box. Then i added a TextArea to my original list, and when users selected items, it just appends them to the textArea. Works well for them, thanks for the pointers – Brenton Pierce Mar 09 '12 at 14:51
1

In order to do this you would have to add the following components:

  • A third list containing lookups to the other two lists, and the quantity.
  • A custom form on the parent list to display the add/edit interface, and update the third list.
  • A custom form on the parent list to view the item, and related items/quantities

But this would still not display the quantities on the list view.

Alternatively, you could create a multi-valued Custom Field Type to handle input and display, but this is is likely to be even more difficult.

Stu Pegg
  • 4,623
  • 7
  • 48
  • 91