Skip to main content

Js Code for auto populate lookup on a create from a subgrid in Power Portal

$(document).ready(function () {    
    var url = window.location.href;
    var id = getParameterByName("id"url);
    var name = $("#msnfp_name").val();

    localStorage.setItem("id"id);
    localStorage.setItem("name"name);

    function getParameterByName(nameurl) {
        if (!urlurl = window.location.href;
        name = name.replace(/[\[\]]/g"\\$&");
        var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
            results = regex.exec(url);
        if (!resultsreturn null;
        if (!results[2]) return '';
        return decodeURIComponent(results[2].replace(/\+/g" "));
    }
});
following Code you need to add on main form where your sub grid is located this code
will set your records guide and name on local storage



then go to your insert form and use following code
$(document).ready(function () {
    var id = localStorage.getItem("id");
    var name = localStorage.getItem("name");
    $("#msnfp_workitemid_name").attr("value"name);
    $("#msnfp_workitemid").attr("value"id);
    $("#msnfp_workitemid_entityname").attr("value""msnfp_workitem");
    $("#msnfp_workitemid").attr("aria-invalid""false");
});

Comments