I have two lists: Products and Suppliers.
In Products, i have 3 columns :
-Name of Product (single line of text)
-Supplier (lookup of Suppliers : Name of Supplier)
-Price (choice list)
In Suppliers, i have 3 columns too :
-Name of Supplier (single line of text)
-Product (lookup of Products : Name of Product)
-Category (choice list)
Actually, in the .js linked to Product (list), i'm using this code to get the informations of the list Suppliers
var oList = clientContext.get_web().get_lists().getByTitle('Suppliers');
But it's hardcoded and i have to dynamise the code so i will be able to apply this code to other lists.
For example:
var NameOfList = "code to get the name of the list which is linked by the lookup (in my case it's the list Suppliers)";
var ColumnsOfList = "NameOfList.getAllColumns (in my case it's Name of Supplier, Product, Category)";
var oList = clientContext.get_web().get_lists().getByTitle(NameOfList);
var txt = [];
txt.push('The list ' + NameOfList + ' has those columns : ');
for(i=0 ; i<ColumnsOfList.length ; i++){
txt.push(ColumnsOfList[i]);
}
alert(txt);
It will display The list Suppliers has those columns : Name of Supplier, Product, Category
.
So, i would like to know which code or function to use for retrieve the listname and columns of the list which is linked by lookup. In my case, i would like to get "Suppliers" as listname and "Name of Supplier, Product, Category" as columns name.
Can someone help me please ?
EDIT : enter image description here