Look up values for multiple columns DFFS

Forums SPJS-Lookup Look up values for multiple columns DFFS

This topic contains 5 replies, has 3 voices, and was last updated by  Alexander Bautz 1 year, 2 months ago.

  • Author
    Posts
  • #10275

    Brett
    Participant

    Hi Alexander,

    Can you please provide the correct syntax to use multiple lookup columns on a form?
    I’ve tried different variations, drop-downs are showing but no values are provided.
    The single drop-down value for “CompanyName” worked perfectly.

    This is an example of what I’ve tried
    “fieldToConvertToDropdown”:[“CompanyName”,”PositionTitle”],
    “listName”:”Tasks”,
    “listBaseUrl”:”/Sites/MySite”,
    “optTextFieldInternalName”:”CompanyName”,”Position”,
    “sortFieldName”:”CompanyName”,”Position”,

    The error I’m receiveing:
    [LookupInTextField: Debug]
    1.11
    ListName: Tasks
    Query: <Where><IsNotNull><FieldRef Name=’CompanyName,Position’ /></IsNotNull></Where><OrderBy><FieldRef Name=’CompanyName,Position’ Ascending=’TRUE’/></OrderBy>
    ViewFields: ID,CompanyName,Position
    Query returned -1 items.

    Thanks for your help.

  • #10299

    Alexander Bautz
    Keymaster

    Hi,
    It is only the “fieldToConvertToDropdown” parameter that should contains multiple field names. This means you must use only one field name in “optTextFieldInternalName” and “sortFieldName”.

    When using multiple fields in “fieldToConvertToDropdown” you basically create multiple identical lookups in different fields in the form.

    If what you wanted was to add multiple DIFFERENT lookups, you must duplicate the entire function call – with the argument object.

    Hope this helps,
    Alexander

  • #12014

    Jeff Law
    Participant

    Hi
    I have been using the Lookup function for a while and have it working fine on a library that contains documents received from various companies. The current process is that a file is added to the library, and then the user fills out the form to update the metadata for that new item.
    Company Name is one of the metadata fields, and it is a SLOT which is use the Lookup function on querying the Companies list to get a list of all possible companies in a dropdown which the user can select which one.
    I have now realised that since the company name is the first part of the file name, I could parse the file name and automatically populate the Company Name field for the user. I have now added a “Parse File Name” button on the form which calls a custom function to parse the file name and extract the company name.
    This all works, and it also updates the field but the form field does not get updated. ie the Company Name field still displays the default value of “select company”, but after saving the form, the real Company Name is displayed in the list, and will appear in the form when editing it. (I am using the setFieldValue function to set the company name field)

    I also get a couple of other parameters from the file name, such as a Reference, which is just a SLOT, and also a Document Type (Invoice, Statement, etc) which is a Managed Metadata field, and both of these fields are updated on the form when I use the setFieldValue function to update them.

    So, I am guessing that there is some subtle trick to getting a field which is controlled by spjs.lookup to update if the field changes behind the scenes as it were?

    Regards
    Jeff

  • #12016

    Jeff Law
    Participant

    Sorry, this was supposed to be a new post, not attached to this one.

  • #12018

    Jeff Law
    Participant

    …and looking at this on another day, I manage to find the answer.

    spjs.lookup.setValue(“FieldInternalName_of_your_field”,”The value you want to set”);

    All sorted.

  • #12020

    Alexander Bautz
    Keymaster

    I’m glad you figured it out.

    Alexander

You must be logged in to reply to this topic.