Issue with Custom Routing

We have a single SharePoint list used for both Mileage Claims and Expense Reimbursements. We created separate Plumsail forms for Mileage and Expenses, with SharePoint tiles linking to each form.

Previously, our custom routing worked to direct staff to the correct form based on a URL parameter (formType):

var urlParams = new URLSearchParams(window.location.search);
var formType = urlParams.get("formType");

if (formType === "Mileage") {
    return "d3cdb0ec-a731-4c8e-89db-b9d00a1b6ddf"; // Mileage Form Set ID
}
if (formType === "Expenses") {
    return "52beeb7a-06f0-4ff5-9c9f-2d3610b795fc"; // Expenses Form Set ID
}

We now need to restrict certain generic "House" accounts from submitting forms, requiring staff to be logged in under their individual accounts.

To do this:

  • Created a House form set containing a message:
    "You are logged in with a House account. Please log in with your staff account to submit your request" and a cancel button.

  • Created a SharePoint group Houses with all House accounts.

  • Configured the House form set to “Open form if current user belongs to the selected groups” > Houses.

  • Left Mileage and Expenses form sets with no group restrictions.

We updated the custom routing to check the SharePoint group:

var urlParams = new URLSearchParams(window.location.search);
var formType = urlParams.get("formType");

return fd.webservices.currentUserInGroup("Houses").then(function(isInGroup) {
    if (isInGroup) {
        return "5cec7ef5-2f4a-4f87-825c-1a87f7338331"; // House form set ID
    }
    if (formType === "Mileage") {
        return "d3cdb0ec-a731-4c8e-89db-b9d00a1b6ddf"; // Mileage form set ID
    }
    if (formType === "Expenses") {
        return "52beeb7a-06f0-4ff5-9c9f-2d3610b795fc"; // Expenses form set ID
    }
});

Testing results:

  • Logging in as a House account > correctly routed to the House form (works as intended)

  • Logging in as a staff account > incorrectly defaults to the All Users form instead of Mileage or Expenses

Question: How can we modify this setup so that staff are correctly routed to their respective Mileage or Expenses forms while still redirecting House accounts to the House form?

Hello @Kyle,

Please try updating the code like so:

var urlParams = new URLSearchParams(window.location.search);
var formType = urlParams.get("formType");

if (formType === "Mileage") {
    return "d3cdb0ec-a731-4c8e-89db-b9d00a1b6ddf"; // Mileage form set ID
}
if (formType === "Expenses") {
    return "52beeb7a-06f0-4ff5-9c9f-2d3610b795fc"; // Expenses form set ID
}

return fd.webservices.currentUserInGroup("Houses").then(function(isInGroup) {
    if (isInGroup) {
        return "5cec7ef5-2f4a-4f87-825c-1a87f7338331"; // House form set ID
    }
});