I have used the Below code for passing parameters to the custom action , am getting Unexpected token u in JSON at position 0,please suggest me regarding this
<html>
<head>
<title></title>
<script src="../../ClientGlobalContext.js.aspx"></script>
</head>
<body onload="setFocusOnComments()" style="overflow-wrap: break-word;">
<h5>Security Role Manager</h5>
<div class="container-fluid">
<div class="row">
<div class="col-md-6">
<label for="User_Type">Type Of Users:</label>
</div>
<div class="col-md-6">
<select id="User_Type" name="User_Type">
<option value="International">International</option>
<option value="Local">Local</option>
</select>
</div>
</div>
<div class="row">
<div class="col-md-6">
<label class="Userlabel" for="Application_Type">Application Type:</label>
</div>
<div class="col-md-6">
<select id="Application_Type" name="Application_Type">
<option value="KAM Tool">KAM Tool</option>
<option value="Sales Mobile">Sales Mobile</option>
</select>
</div>
</div>
<div class="row">
<div class="col-md-12"><button type="button" class="btn-primary" onclick="onSubmit()">Assign Roles</button>
</div>
</div>
</div>
<script>
function setFocusOnComments() {
}
function GetURLParameter(sParam) {
var sPageURL = window.location.search.substring(1);
var sURLVariables = sPageURL.split('&');
for (var i = 0; i < sURLVariables.length; i++) {
var sParameterName = sURLVariables[i].split('=');
if (sParameterName[0] == sParam) {
var vals = new Array();
vals = decodeURIComponent(sParameterName[1]).split("&");
for (var i in vals) {
vals[i] = vals[i].replace(/\+/g, " ").split("=");
}
return vals;
}
}
}
function onSubmit() {
debugger;
var queryStrings = GetURLParameter('data');
var id = queryStrings[0][1];
var userType = document.getElementById("User_Type");
var ghi_usertype = userType.options[userType.selectedIndex].value;
var appType = document.getElementById("Application_Type");
var ghi_applicationname = appType.options[appType.selectedIndex].value;
var target = { entityType: "systemuser", id: id };
var reqObject = {};
reqObject.entity = target;
reqObject.UserType = ghi_usertype.toString();
reqObject.ApplicationType = ghi_applicationname.toString();
reqObject.getMetadata = function () {
return {
boundParameter: "entity",
operationType: 0,
operationName: "ghi_AssignSecurityRolefromSecurityManager",
parameterTypes: {
"entity": {
"typeName": "mscrm.systemuser",
"structuralProperty": 5
},
"UserType": {
"typeName": "Edm.String",
"structuralProperty": 1
},
"ApplicationType": {
"typeName": "Edm.String",
"structuralProperty": 1
}
}
}
};
window["ENTITY_SET_NAMES"] = window["ENTITY_SET_NAMES"] || JSON.stringify({
"systemuser": "systemusers",
});
Xrm.WebApi.online.execute(reqObject).then(
function success(result) {
debugger;
console.log(result, 'result');
if (result.ok) {
console.log(result, 'result11');
}
},
function (error) {
Xrm.Utility.alertDialog(error.message);
}
);
}
</script>
</body>
</html>