Lookup Field Save To

I am trying to use a lookup field but it will not let me set the "Save To" property to what I want. The options it gives me are pictured below. I want to save the selected text to the "Title" field but that isn't in the list. I tried to set the value in code, fd.field('Lookup1').SaveTo = 'Title'; Is there a reason why I can't select 'Title' or why I can't just type in the name of the field I want to populate?

Screenshot 2021-03-09 090050

Dear @smithme,
Please, be careful with your selection here. The value is not stored as text, it's stored in JSON format, and if your selected Save To column will contain values in different format, the field will fail to load properly.

While you can use one of existing fields, we highly recommend creating a new field specifically to store the lookup value.

1 Like

Thank you. Now I understand.

1 Like

Hi @Nikita_Kurguzov.

Is there a way for us to extract the lookup value from the JSON when we choose the "Save to" option of the lookup control? I would like to know if there's a way to just save/extract the lookup value instead of the entire JSON.

Thanks,
stormanh

Dear @stormanh,
You can simply copy the text value to another field when it changes? You'll need to create a field first though, but something like this would work:

fd.spRendered(function(){
 fd.control('Lookup').$on('change', function(value) {
    if(value && value.LookupValue){
      fd.field('Title').value = value.LookupValue;
    }
    else{
      fd.field('Title').value = value;
    }
 });
});
1 Like

Understood, works great! Thank you @Nikita_Kurguzov !

Nikita,

Is there a way to format the column in a list view to show the "text" value of the Lookup JSON? Something like:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "div",
  "txtContent": "@currentField.text"
}

This code does not work. I am wondering if there is a way to do this?

Dear @smithme,
It should only show the text value by default. Or are you trying to remove the link?

@Nikita_Kurguzov

If I do nothing to the data field that holds the Lookup's data, then I see an empty column in the list view. If I format the column and tell it to:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "div",
  "txtContent": "@currentField"
}

then I see:

Capture

What I was thinking is I need to tell the formatter to display the "text" field of the JSON object. To do that, I need a way to convert the @currentField object to have the "text" field. I am exploring that now. I was hoping you could tell me how to only show the "text" field in the list view.

Dear @smithme,
This is how the Save To field should look like by default:
image

If it doesn't look like this, try creating a new field and selecting it as Save To field. See if it appears properly, and if it does - you can copy your data into it.

I did your experiment and it still does not work. It never has worked on my SharePoint.

Dear @smithme,
Are you sure you're using the latest version of the app package? What's the version of the app package in the App Catalog? Is it v1.0.8 or below?

Here's an instruction to update it - Update the app package for Plumsail Forms (SharePoint Online) — SharePoint forms

1 Like

I updated to version 1.0.8.1 and now it is working correctly. Thank you.

Is there a way to still use custom formatting with this column? I can't seem to make it work.

Dear @smithme,
It's possible, though a little beyond our scope. This is a good place to start - Build your first Field Customizer extension | Microsoft Docs

You can always delete an existing customizer by going to Customizers settings on a form.

1 Like