Home › Forums › vLooup for SharePoint › Dynamically hide vLookup column
- This topic has 6 replies, 2 voices, and was last updated 4 years, 6 months ago by Christopher Holubarz.
-
AuthorPosts
-
-
June 22, 2020 at 09:55 #30717
Hi Alexander,
I’m encountering following situation:
I have a vLookup Column which depends on the selection of a product. The vLookup column has 3 currency columns (CHF, EUR, USD) and I want to dynamically display only one of them depending on the currency selection in the parent.
Is there a possibility to hide / show vLookup columns dynamically ?
Thank you very much in advance and BR,
Chris -
June 22, 2020 at 15:13 #30723
It is unfortunately no functionality to dynamically hide columns in vLookup, but if you have the sum in one column you can use custom js to append the correct currency symbol after the number.
Alexander
-
June 24, 2020 at 06:38 #30741
Hi Alexander,
Thank you for your feedback. Actually I have all 3 prices for each item, but returning the correct one to a [CustomField] doesn’t seem to work, although I get no errors in the code. (see attached Screenshots)
BR,
ChrisAttachments:
-
June 24, 2020 at 17:44 #30753
Hi,
The way you get the price is not synchronous so you must change it – please post the code you use as text here, and I’ll modify it for you – it is easier that explaining what to do.Alexander
-
June 24, 2020 at 17:52 #30759
Hi Alexander,
Here is the code:
function returnItemPrice(a, item) { var id = item.get_item("ID"); debugger; var whr = getFieldValue('W_x00e4_hrung'); var cc = new SP.ClientContext.get_current(); var list = cc.get_web().get_lists().getByTitle('Pakete'); var oItem = list.getItemById(id); cc.load(oItem); cc.executeQueryAsync( function(sender, args) { switch(whr) { case 'EUR': console.log("Returning '"+oItem.get_item('EUR').toString()+"'"); return oItem.get_item('EUR').toString(); case 'CHF': console.log("Returning '"+oItem.get_item('CHF').toString()+"'"); return oItem.get_item('CHF').toString(); case 'USD': console.log("Returning '"+oItem.get_item('USD').toString()+"'"); return oItem.get_item('USD').toString(); } }, function(sender, args) { console.log("Error getting price"); } ); }
Thank you in advance and BR,
Chris-
June 24, 2020 at 18:03 #30761
Here is the modified code – please note that I have not tested this code so use the debugger to look at the variables to see that it picks up the correct values:
function returnItemPrice(a, item) { var id = item.get_item("ID"); debugger; var whr = getFieldValue('W_x00e4_hrung'); var cc = new SP.ClientContext.get_current(); var list = cc.get_web().get_lists().getByTitle('Pakete'); var oItem = list.getItemById(id); cc.load(oItem); cc.executeQueryAsync( function (sender, args) { var val = ""; switch (whr) { case 'EUR': val = oItem.get_item('EUR').toString(); case 'CHF': val = oItem.get_item('CHF').toString(); case 'USD': val = oItem.get_item('USD').toString(); } console.log("Returning '" + val + "'"); // Locate the correct placeholder and replace the value var itemId = oItem.get_item('ID'); jQuery("#price_placeholder_" + itemId).html(val); }, function (sender, args) { console.log("Error getting price"); } ); // While the asynchronous function above finishes, return a placeholder return "<span id='price_placeholder_" + id + "'>...</span>"; }
Alexander
-
-
June 25, 2020 at 06:43 #30763
Hi Alexander,
Thank you very much for your help, this worked like a charm 🙂
Thank you and BR,
Chris
-
-
AuthorPosts
- You must be logged in to reply to this topic.