Alternative solution for RP.getParameterValue()

Community Alums
Not applicable

com.glide.script.RhinoEcmaError: "RP" is not defined.
sys_script.e6ffde8fdbb54150c14aa90b8a9619e0.script : Line(12) column(0)
9: current.addActiveQuery(); //Keep it OOB
10: }
11: } else {
==> 12: if (RP.getParameterValue("sys_id") != "4f79f4ed1bf995108e576288bd4bcb68" || RP.getParameterValue("id") != "hrm_todos_page") {
13: current.addActiveQuery(); //OOB
14: }
15: }

 

Logs is throwing a warning so is there an alternative solution for RP.getParameterValue()?

5 REPLIES 5

Juhi Poddar
Kilo Patron

Hello @Community Alums 

In a Business Rule, you don't have direct access to RP.getParameterValue() since Business Rules execute on the server side and don't interact with URL parameters directly. However, you can use gs.action.getGlideURI() to retrieve parameters if the Business Rule is triggered during a user interaction where the URI is relevant.

Here’s how you can replace RP.getParameterValue() with gs.action.getGlideURI() in a Business Rule:

(function executeRule(current, previous /*null when async*/) {
    // User-specific behavior
    if (gs.getUser().getID() === "cf34d4d41b12b410e2fedd79b04bcb0e") { // BTOps_UA_R
        var glideURI = gs.action.getGlideURI().toString();
        var isVariablePresent = glideURI.includes("1d15e5d71ba2f050e2fedd79b04bcbe0"); // Requestor variable sys_id
        var refererHeader = GlideTransaction.get().getRequest().getHeader("referer").toString();
        var isOffboardingCatalog = refererHeader.includes("4197ed721b1af410e2fedd79b04bcb7b"); // CSL Offboarding catalog item sys_id

        if (!isVariablePresent && !isOffboardingCatalog) {
            current.addActiveQuery(); // Default behavior
        }
    } else {
        // Generic condition for other users
        var glideParams = gs.action.getGlideURI();
        var sysId = glideParams.get("sys_id");
        var pageId = glideParams.get("id");

        if (sysId !== "4f79f4ed1bf995108e576288bd4bcb68" && pageId !== "hrm_todos_page") {
            current.addActiveQuery();
        }
    }
})(current, previous);

Hope this helps!

 

"If you found my answer helpful, please like and mark it as an "accepted solution". It helps others find the solution more easily and supports the community!"

 

Thank You
Juhi Poddar