Get List or Library Lookup Values only on select (before saving)

Dear Community,

I read a article that it's not possible to get the extra values out of a lookup field.
Now I'm wondering, whether the problem still exists and if it's also relevant in a List or Library Control.

I have created a Plumsail Form, where People can Sign up to different fairs and where they can select some tickets in the list or library.

Here is a Screenshot:

Now I'm just wondering, if it's possible to get the info and price per ticket after choosing a ticket and before saving it to SharePoint.

Here is my Source for the List or Library Control:
image

Here is a snippet of the Code I have so far for the List or Library Control:

fd.control('SPDataTable1').$on('edit', function(editData) {
  editData.field('Ticket').filter = "Messe/ID eq " + fair;

    editData.field('Anzahl').disabled = true;
    editData.field('Ticket').required = true;

    
    
    editData.field('Ticket').$on('change', function(value) {
    
        console.log(editData.field('Ticket').value);
        //editData.field('Ticket_x003a_Infotext').value;
    
        if (editData.field('Ticket').value.LookupValue == 'Gutschein Tageskarte FBM') {
            editData.field('Anzahl').disabled = false;;
        } else {
            editData.field('Anzahl').disabled = true;
        }
    })

Would be great, if you could help me to implement the code into the all ready existing.
Thank you!

Kind regards,
Jan

Dear @Jan,
It should be possible to copy the extra value to another column.

Something like this should work:

fd.control('SPDataTable1').$on('edit', function(editData) {
  editData.field('Ticket').extraFields = ["Price"];
        
  editData.field('Ticket').filter = "Messe/ID eq " + fair;

    editData.field('Anzahl').disabled = true;
    editData.field('Ticket').required = true;

    editData.field('Ticket').$on('change', function(value) {
        if (editData.field('Ticket').value.Price){
           editData.field('PricePerTicket').value = editData.field('Ticket').value.Price;
        }
        console.log(editData.field('Ticket').value);
        //editData.field('Ticket_x003a_Infotext').value;
        if (editData.field('Ticket').value.LookupValue == 'Gutschein Tageskarte FBM') {
            editData.field('Anzahl').disabled = false;
        } else {
            editData.field('Anzahl').disabled = true;
        }
    })
})

At least something like that. Do not forget to change Internal Names for Price and PricePerTicket fields.

@Nikita_Kurguzov thank you!!!

Very helpful. The only issue I had, was that the price and the Info field are auto generated lookup fields coming together with the Ticket field so I could't fill them with dynamic values.

So I created new fields in the list that I now just auto fill in the change/edit function.

Thank you! :slight_smile:

1 Like