Forms and Lookups

Hi there, new here. never used Forms and I would like to see if this is possible?

I have a form where the user select an US State i.e FL and I would like to do a lookup based on that selection to show a checkbox with a hyperlink. My current form is a MS Form in public mode.
Is this possible with plumsail form?

Thanks in advance

Dear @sajarac,
Interesting question! It is possible to filter a SharePoint lookup field by state, we have many examples of filtering a lookup field in this article - https://plumsail.com/docs/forms-sp/how-to/lookup-filter.html

Unfortunately, I am not sure about all the details in your case:

  1. MS Form in public mode - should the data be available to unauthorized users? SharePoint lookup fields are normally just used in SharePoint, where users need to have appropriate permissions to access items.
  2. Show checkbox with a hyperlink - what would this look like? Lookup fields are usually just dropdowns with search functionality, they don't have any checkboxes, how would you want it to look like? Maybe a screenshot would help.

Hey, thank you very much for your prompt response.
I was reading the article but now I am lost. LOL. sorry new to this.
Let me try to describe my scenario to see if you can get a better idea of what I am trying to accomplish.

Let's say:
I have a dropdown with each US State i.e. AL, AK, AZ, AR.......WY.

Now each state have their own terms and conditions. So I have 50+ pdf files in a public folder location such as AL - T&C.pdf, AK - T&C.pdf, AZ - T&C.pdf.........WY - T&C.pdf.

Remember this is a public for, so not Share point involved yet. I will transfer the data collected here to my share point list later using flow.

Now when any user select a state from the State dropdown list. I would like to see in a separate box a check box something that indicates : Do you agree the Terms & Conditions for this State? and a hyperlink with the proper file URL.

Make sense?

Unfortunately I can't provide some screen shots because this is a new request. I have my current form in MS Forms but I am only using now a single state so not a big deal but I can not complete this without using a lookup currently not supported by MS.

Thanks in advance

Dear @sajarac,
Well, does the checkbox need some specific connection, or is it the same checkbox for all the states, and only the link itself changes?

The easiest way is to probably just to replace the link, and do it with JavaScript, no lookups - otherwise this will be very complex to realize. I have an example of what it might look like for you here - https://forms.plumsail.com/7f006e43-7e97-4d19-8a86-1fb83c66f34a

This is the code that I've used:

fd.rendered(function(){
    fd.field('State').value = ''
    showStateConditions(fd.field('State').value);

    fd.field('State').$on('change', function(value) {
        showStateConditions(value)
    });
});

function showStateConditions(value){
    if(value.length > 0){
        if(value == 'Alabama, AL'){
          fd.control('Hyperlink1').text = 'Terms and Conditions for Alabama, AL';
          fd.control('Hyperlink1').href = 'https://plumsail.com/';
        }
        else if(value == 'Alaska, AK'){
          fd.control('Hyperlink1').text = 'Terms and Conditions for Alaska, AK';
          fd.control('Hyperlink1').href = 'https://google.com/';
        }
        else if(value == 'Arizona, AZ'){
          fd.control('Hyperlink1').text = 'Terms and Conditions for Arizona, AZ';
          fd.control('Hyperlink1').href = 'https://facebook.com/';
        }
        $(fd.control('Hyperlink1').$el).show();
        $(fd.field('Agree').$parent.$el).show();
    }
    else{
        $(fd.control('Hyperlink1').$el).hide();
        $(fd.field('Agree').$parent.$el).hide();
    }
}

Well, does the checkbox need some specific connection, or is it the same checkbox for all the states, and only the link itself changes?

A/ The checkbox is only a confirmation that the state selected and the terms and conditions has been read and approved. so I might say a single check box and the link changes itself

Your sample is what I was looking for. that is exactly what I was looking for.

AWESOME !!!!!!

Now for a new and silly guy, could you please point me on how to implement this?

Sorry :frowning:

Dear @sajarac,
You do know how to create forms, right? :smiley: Just in case, here's a video to get started - https://youtu.be/26x25IhUbOg

Now, I've placed a Dropdown on the form, gave it Name: State, and placed three state options to select. You can have all the states, not a problem.

Then, I've added a Hyperlink control under it for the Terms and Conditions - this is the URL that I'm changing with the code.

Finally, we don't have a single checkbox control, only Checkboxes - that's what I've added and gave Name: Agree. I only left one checkbox with value: Yes.

That's all I did, then I've added the code that you see in the original reply post. You can add more states, and URLs to the documents that you need for each one.

Thank you very much, I guess I need to start reading.

One last question? I have copied the code provided and pasted in the JS and the CSS console and is not working is this correct?

Got it.
I've have founded the issue. I was working in the web version not in the desktop designer, and the web version doesn't have the hyperlink choice:

That is why I was getting mental trying to figure our this thing.


Dear @sajarac,
My bad, that's actually pretty big! I didn't know the Hyperlink control is not available yet. I'll remind the dev team to add it as soon as possible, I think it can be useful in situations like this.

For the HTML control, please, use this code instead:

fd.rendered(function(){
    fd.field('State').value = ''
    showStateConditions(fd.field('State').value);

    fd.field('State').$on('change', function(value) {
        showStateConditions(value)
    });
});

function showStateConditions(value){
    if(value.length > 0){
        if(value == 'Alabama, AL'){
          fd.control('HTML1').$el.innerHTML ='<a href="https://plumsail.com/" target="_blank">Terms and Conditions for Alabama, AL</a>';
        }
        else if(value == 'Alaska, AK'){
          fd.control('HTML1').$el.innerHTML ='<a href="https://google.com/" target="_blank">Terms and Conditions for Alaska, AK</a>';
        }
        else if(value == 'Arizona, AZ'){
          fd.control('HTML1').$el.innerHTML ='<a href="https://facebook.com/" target="_blank">Terms and Conditions for Arizona, AZ</a>';
        }
        $(fd.control('HTML1').$el).show();
        $(fd.field('Agree').$parent.$el).show();
    }
    else{
        $(fd.control('HTML1').$el).hide();
        $(fd.field('Agree').$parent.$el).hide();
    }
}

Thank you very much again for your help. I was able to replicate the output using the Desktop designer. And BTW that *.exe files reports a false positive virus infection by Avast AV, or if this is true my PC is already infected, but who cares I got the form working!!! LOL

thank you kindly!