0
votes

i am working with sharepoint 2013... I have two lists;

1°/ Cars{brand,color,price} 2°/ Colors{designation,availability}.

I made the field 'color' (cars list's field) as a lookup field to display colors from colors list. While filling data in cars list, in the field color, i want to just find colors with availibility "yes" in the availability field of colors list. How can i get this please?

Can anyone help me please? Thank you in advance.

2

2 Answers

0
votes

Create a new view on your cars list. Then filter so it only shows items where the availbility = yes

0
votes

I guess that the second list has {colour, designation,availability}. There are two solutions: The first solution is in second list, you add a calculated field that = if Availability=true:[field with color]:"". That will filter out all non-available colors. Yet, you should have a problem when changing from available to not available - i.e you 'll loose information on the previous records.

The second solution needs jquery and ajax. Basically, on document load, you check every option if it's available - if it's not, delete it.The only drawback is that you need to have somewhere jquery.js I'm in the house but if you want it, I could write the code tomorrow. The code is:

$(window).ready(function() { 
$("#PutHereTHeIDOfthedropodown > option").each(
function(index) {
                if (window.console) console.log("inside" + index+"," + $(this).val()); //39, 51 κλπ
                // $(this).hide();// with this, we hide the selection!!
                var mythis = $(this);
                $.ajax( {
                    url:"http://YourWebSite/sites/DNY/_api/Lists(guid'b5910edd-8a39-4d45-GUID-Of-The-List')/items(" + mythis.val()+")?$select=Active",
                    type:"GET",
                     headers: {
                        "accept": "application/json;odata=verbose",
                    },
                  success: function(data){ console.log("ajax call SUCCESS");  
                                       console.log("item:"+mythis.val());
                                            console.log("Data:" + data);
                                            console.log("Active: " + data.d.Active);
                                        if (!data.d.Active) {
                                            console.log("hiding: " + mythis.val() + "["+ "]");
                                            mythis.hide();
                        }//if
                }//success
                    ,
                    error: function(error){
                                           console.log(" =============================================>>Error:" + mythis.val());
                                           console.log (JSON.stringify(error));
                                           console.log(" Error:" + mythis.val());
                                           console.log(JSON.stringify(error));
                            }//error
                    });//ajax
                });//each
            });//ready