Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 82002

Call Action using javascript

$
0
0

Hi all,

I am getting error while calling Action from javascript, below is my code

==========CODE===================

function CallAction()
{
var requestPath = 'str_GlobalAction';
var requestMethod = 'POST';
var requestData = {

'Topic': JSON.stringify({
'EntityType': Xrm.Page.data.entity.getEntityName(),
'EntityId': Xrm.Page.data.entity.getId()
})
};

var req = new XMLHttpRequest();
req.open(requestMethod, Xrm.Page.context.getClientUrl() + '/api/data/v9.0/' + requestPath, (typeof onSuccess === 'function'));
req.setRequestHeader('OData-MaxVersion', '4.0');
req.setRequestHeader('OData-Version', '4.0');
req.setRequestHeader('Accept', 'application/json');
req.setRequestHeader('Content-Type', 'application/json; charset=utf-8');
req.setRequestHeader('Prefer', 'odata.include-annotations="OData.Community.Display.V1.FormattedValue"');
req.send(requestData !== null ? JSON.stringify(requestData) : null);

if (typeof onSuccess === 'function') {
debugger;
req.onreadystatechange = function () {
if (this.readyState === 4) {
debugger;
req.onreadystatechange = null;
if (this.status === 204) {
//onSuccess(null);
debugger;
} else {
debugger;
var d = null;
try {
d = JSON.parse(this.response);
} catch (ex) { }
if (this.status === 200 && d !== null)
{
debugger;
result = JSON.parse(result.OutData);
if (result.Error)
{
Xrm.Utility.alertDialog(result.Error);
}
else {
Xrm.Page.data.refresh();
}
}
else
{
debugger;
var err = this.response;
if (d && d.error && d.error.message) {
err = d.error.message;
}
if (typeof onError === 'function') {
Xrm.Utility.alertDialog(result.Error);
} else {

}
}
}
}
};
}

if (typeof onSuccess !== 'function') {
debugger;
if (req.status === 204) {
return null;
} else {
var d = null;
try {
debugger;
d = JSON.parse(req.response);
} catch (ex) { }
if (req.status === 200 && d !== null) {
debugger;
return d;
} else {
debugger;
var err = req.response;
if (d && d.error && d.error.message) {
// err = d.error.message;
}
if (typeof onError === 'function') {
// onError(err);
} else {
//Xrm.Utility.alertDialog(localize('javascript_error_global', [err]));
}
}
}
}
}

=============ERROR================================

<TraceText i:nil="true"/></InnerFault><OriginalException i:nil="true"/><TraceText i:nil="true"/></InnerFault><OriginalException i:nil="true"/><TraceText>&#xD;
[Microsoft.Crm.ObjectModel: Microsoft.Crm.ObjectModel.SyncWorkflowExecutionPlugin]&#xD;
[ad23c9ac-5627-e811-a95c-000d3a1a941e: ]&#xD;
Starting sync workflow 'Global Action', Id: a523c9ac-5627-e811-a95c-000d3a1a941e&#xD;
Entering CustomActivityStep1_step: Custome workflow actvity&#xD;
Sync workflow 'Global Action' terminated with error 'SandboxFault.ThrowIfGuidEmpty: entityId'&#xD;
</TraceText>

Thanks,

Shahbaaz


Viewing all articles
Browse latest Browse all 82002

Latest Images

Trending Articles



Latest Images