Hello,
I have a list with two content type, Items and Supplier Form.
Is it possible route to specific form based on value salected in a control lookup field and in the meantime background change even the content type value?
Therefore, when a user select a specific value at point 1, below "Document Type" field must appear the fields require for the particular content type.
Simply I want to give to my user a control lookup field where they can choose one value and if they select a specific value a want to redirect them to a specific form with specific fields for that selected content type.
Is it possible?
Do you have e sample code to share here?
Thank you.
You can save the Lookup control to local storage and refresh the page. In the custom routing settings, retrieve value from the local storage and redirect users to a specific form set.
The code for the form:
fd.spRendered(function() {
fd.control('Lookup1').$on('change', function(value) {
if (value)
localStorage.setItem('FormName', value.LookupValue);
//refresh the page
location.reload()
})
});
The code for the custom routing:
if (localStorage.getItem('FormName') == 'Form Number one') {
localStorage.removeItem('FormName');
return '9c49268c-8d61-4069-99b3-ff394cbb07dd'
}
if (localStorage.getItem('FormName') == 'Form Number two') {
localStorage.removeItem('FormName');
return '9c49268c-8d61-4069-99b3-ff394fdgdfdf'
}
Hello @mnikitina
thank you for your help.
I'm trying your code but I get error probably because I don't understand it well.
My users must select from lookup field or control a value, then the selected value must be set even in the original sharepoint content type field, and this last one actions must routing my form in other one.
Dear @mnikitina ,
My list has only two content type.
I created a specific field Document Type in order to choose wich kind of document I'm loading because all have the same fields, except for only one that has a specific form set and fields. For that field I created a specific content type and I want to redirect to a different form set that will have field and roles different to the other content type.
What is the best way to achieve this?
Thank you.
Thank you for the details! So you have a drop-down field, each option in which represents a specific content type and a form set. Is that correct? If so, you can use this code for the form:
fd.field('Field1').$on('change', function(value) {
if (value == 'Miscellaneous') {
//save form set ID to the local storage
localStorage.setItem('FormSetID', '9c49268c-8d61-4069-99b3-ff394cbb07dd');
//open specific content type
fd.field('ContentType').value= '0x01080080AF88A3052D8C42B30BEBC7050B2A96'
}
})
The code for the custom routing must be added for each content type:
var formSet = localStorage.getItem('FormSetID')
if (formSet) {
localStorage.removeItem('FormSetID');
return formSet
}
You can find the content type ID in the List Settings >> Content Type >> Page URL:
Hello @mnikitina,
I saw that if I update the value of the content type field, my form route automatically to the new one, without routing code, but only with this:
But "Supplier Form" form open in the Full Screen Mode instead Panel Mode.
Now, just to understand better your solution.
I have only 2 content type, Item and Supplier Form.
My form must open by default as Item and only if user select in the fd.control('DocumentType') the value Supplier Form, I must change my form with the specific fields required for the selected content type.
In order to achieve this, will be enough using my code or will be better using you solution?
This this "Supplier Form" content type ID:
0x01004588AAF4AACE1F49A54F0A3997686D80004B3A1483EA07824387A16E5FAD002117
Yes, your code is enough. No need to add the code for the routing.
Yes, currently it works like so. We have a task to open the form for the selected content type in the panel too, but there is no due dates yet. If you want his feature straight away, we can offer you a paid support. Please email us at support@plumsail.com for more details.
When you have multiple different forms for one content type, you can conditionally route users between those forms. This is when you need the code for the Custom Routing.
Please learn more about forms sets in our documentation.