Home › Forums › vLooup for SharePoint › Set value from vLookup table to a field in the current form
- This topic has 4 replies, 2 voices, and was last updated 7 years, 1 month ago by mk3jamie.
-
AuthorPosts
-
-
September 26, 2017 at 15:04 #18269
I got this questions:
Hi Alex,
Was wondering if you could help with a quick question. Is it possible to take the value displayed in a vLookup and assign it to a value in another tab?
For example I have a vLookup for sales documents, showing a quoted price. I want to use that quoted price in my vLookup tab and display it in an adjacent tab in a “Opportunity Price” field.
Thanks again for your help.
Kind regards,
Jamie.Yes, this can be done like shown below. It will add a button to the right of the value in the vLookup table and the user can click it to bring the value into the filed you specify in the code snippet below.
Add this to the “Special configuration” textarea for your field in vLookup configuration (it is the “function” parameter you need – the other ones are for prefixing and setting the decimals):
{"prefix":"$","decimals":2,"function":"add_vLookupValueToField"}
Then add this to the Custom JS:
function add_vLookupValueToField(value, item){ var r = value; if(value !== ""){ r = r + "<input type='button' value='Add to MY_FIELD' onclick='setFieldValue(\"MY_FIELD\",\""+value+"\")'>"; } return r; }
Change the “MY_FIELD” text to match your field name.
Alexander
-
September 28, 2017 at 15:09 #18298
Hi Alex,
This is an excellent solution. Does exactly what I was looking for, thanks again.
Jamie.
-
October 2, 2017 at 11:02 #18320
Quick amendment to this Alex, would it be possible to have the field sync automatically rather than making use of a button?
Kind regards,
Jamie. -
October 8, 2017 at 10:36 #18379
Yes, this is possible, but do you have only one “line” in the vLookup child table?
The easy method that lets you reuse this code is to replace the input with an image tag like this:
function add_vLookupValueToField(value, item){ var r = value; if(value !== ""){ r = r + "<img src='/_layouts/images/blank.gif' onload='setFieldValue(\"MY_FIELD\",\""+value+"\")'>"; } return r; }
Alexander
-
October 16, 2017 at 09:54 #18427
Yeah it was only 1 line and as always thank you very much Alex. Spot on solution.
-
-
AuthorPosts
- You must be logged in to reply to this topic.