Hello!
I used a direct URL to specific form sets to open forms from buttons or in dialogs.
Now that routing is done differently, I'm changing to use a query parameter.
But how do I route to the default form? Which does not have a form set ID?
For example, in the code below, my discipline is Systems Engineer, so I route to the "master form".
In that form are buttons which direct to any of the forms, including the default.
e.g. On button click (this one works fine):
window.open("https://beveridgewilliams.sharepoint.com/sites/StartCardsandSWMS/SitePages/PlumsailForms/StartCard/Start%20Card/NewForm.aspx?FormID=3282d960-7982-464d-96cd-4d67201fafb0", "_self");
But this button to the default form puts me into a loop (It routes me back to the master form, when I want the default...):
window.open("https://beveridgewilliams.sharepoint.com/sites/StartCardsandSWMS/SitePages/PlumsailForms/StartCard/Start%20Card/NewForm.aspx?", "_self");
Here is the routing:
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
//FormID is the name of the query parameter
const formSetId = urlParams.get('FormID')
if(formSetId ){
//open the form based on query parameter
return formSetId ;
}
else {
//Get properties of the current user
return pnp.sp.profiles.myProperties.get().then(function(result) {
var props = result.UserProfileProperties;
//if there is a property with Key: Department and Value: Engineering
if (props.some(function(p){ return p.Key === 'Discipline' && (p.Value === 'Administrator' || p.Value === 'Town Planner' || p.Value === 'Landscape Architect' || p.Value === 'Urban Designer' || p.Value === 'Accountant' || p.Value === 'Human Resources' || p.Value === 'Traffic Engineer' || p.Value === 'Desktop Support' || p.Value === 'Systems Administrator' || p.Value === 'End User Support')})) {
//return ID of Lite Form Set
return 'a58f6909-b230-486a-8134-ac9e5bbef75d';
}
else if (props.some(function(p){ return p.Key === 'Discipline' && (p.Value === 'Engineer' || p.Value === 'Construction Engineer' || p.Value === 'Project Manager' || p.Value === 'Water Resources Engineer')})) {
//return ID of Engineering's Form Set
return '3282d960-7982-464d-96cd-4d67201fafb0'
}
else if (props.some(function(p){ return p.Key === 'Discipline' && (p.Value === 'Executive' || p.Value === 'Systems Engineer' || p.Value === 'Auditor')})) {
//return ID of Master Form Set
return 'e792d63a-0a22-4266-a0e4-c07892791616'
}
});
}
Your assistance would be greatly appreciated!
Adam