Set value from vLookup table to a field in the current form

Forums vLooup for SharePoint Set value from vLookup table to a field in the current form

Viewing 4 reply threads
  • Author
    Posts
    • #18269
      Alexander Bautz
      Keymaster

      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

    • #18298
      mk3jamie
      Participant

      Hi Alex,

      This is an excellent solution. Does exactly what I was looking for, thanks again.

      Jamie.

    • #18320
      mk3jamie
      Participant

      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.

    • #18379
      Alexander Bautz
      Keymaster

      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

    • #18427
      mk3jamie
      Participant

      Yeah it was only 1 line and as always thank you very much Alex. Spot on solution.

Viewing 4 reply threads
  • You must be logged in to reply to this topic.