CRM2016 On Premises
With a lot of help, I have added a button to a view, added the javascript and created an action to fire a plugin .. but Its not working and I just cannot see why
view is on New_transactionsets
JavaScript
function BuildBACSFile(selectedItems)
{
try {
alert("Test 1");
var stringlist ="";
for (var i = 0; i < selectedItems.length; i++)
{
if(stringlist != "")
{
if(selectedItems[i] != null && selectedItems[i] != undefined)
stringlist = stringlist + "," + selectedItems[i].Id;
}
else
{
if(selectedItems[i] != null && selectedItems[i] != undefined)
stringlist = selectedItems[i].Id;
}
}
alert(Test 2);
var inputParams = [
{ key: "ParameterGuids", type: Process.Type.String, value: stringlist }];
//Call the custom action
Process.callAction("new_BuildMultiBACSFile", inputParams, successCallback, errorCallback);
}
catch(err)
{
alert(err)
}
}
function successCallback(params) {
alert("successCallback");
//Get the result from the plugin and display the information in a notification
var outputParamOne = params["PluginResponse"];
alert(outputParamOne )}
function errorCallback(error, trace) {
alert("errorCallback");
alert("Error: " + error, "ERROR", "myError");
}
The Action

I have registered the plugin successfully
Plugin in code ( simple for testing .. just writing to a text file )
Imports System.Globalization
Imports System.IO
Imports System.Net
Imports Microsoft.Xrm.Sdk
Namespace BuildBacsFile
Public Class clsBuildBACSFile
Implements IPlugin
Public Sub Execute(serviceProvider As IServiceProvider) Implements IPlugin.Execute
writetolog("Started ")
Dim tracingService As ITracingService = DirectCast(serviceProvider.GetService(GetType(ITracingService)),
ITracingService)
Dim localContext As IPluginExecutionContext =
DirectCast(serviceProvider.GetService(GetType(IPluginExecutionContext)), IPluginExecutionContext)
Dim output As String = String.Empty
Try
If localContext Is Nothing Then
Throw New InvalidPluginExecutionException("localContext")
End If
Dim TransactionsetRef As EntityReference = CType(localContext.InputParameters("Target"), EntityReference)
Dim parmsqlLedgerKey As String = CStr(localContext.InputParameters("ParameterGuids"))
writetolog("Started " & parmsqlLedgerKey)
output = "Completed"
Catch exception As WebException
Dim str As String = String.Empty
If exception.Response IsNot Nothing Then
Using reader As StreamReader = New StreamReader(exception.Response.GetResponseStream())
str = reader.ReadToEnd()
End Using
exception.Response.Close()
End If
If exception.Status = WebExceptionStatus.Timeout Then
Throw New InvalidPluginExecutionException("The timeout elapsed while attempting to issue the request.", exception)
End If
Throw New InvalidPluginExecutionException(String.Format(CultureInfo.InvariantCulture, "A Web exception occurred while attempting to issue the request. {0}: {1}", exception.Message, str), exception)
End Try
localContext.OutputParameters("PluginResponse") = output
End Sub
Public Function writetolog(message As String) As Boolean
Using Errorprocessing As StreamWriter = File.AppendText("C:\Logs\workflow.txt")
Errorprocessing.WriteLine(message)
End Using
Return True
End Function
End Class
End Namespace
When I have selected a record and clicked the button, I get the alert Test 1 and Test 2. ( I have shown that the stringlist contains data ) . Nothing else, no err alert and no workflow.txt file. It is as though the action is not firing the plugin. on the Process, I have looked and there are no process session listed. Im at a loss as to where to look to try and resolve this