Hello, the agent has to reside in forms_x.nsf. This code should work.
function Custom_Scene_PostLoad_Lite( s_SceneName, bInEditMode ){
try {
runAnAgent(sId);
}
catch(e)
{
// .....
}
}
function runAnAgent(sId) {
// Get the UNIDs of the selected documents
var unids = API_GetSelectedDocs_Lite();
// Create an XMLHttpRequest object
if (window.XMLHttpRequest)
{
xhr = new XMLHttpRequest(); // Firefox, Safari, ...
}
else if (window.ActiveXObject) // ActiveX version
{
xhr = new ActiveXObject("Microsoft.XMLHTTP"); // Internet Explorer
}
// Set the function to be called when the request finishes
xhr.onreadystatechange = function()
{
if(xhr.readyState == 4)
{
if(xhr.status == 200) { // success
// Set status message and/or pop up an alert
AAA.EVI.sr (2, "", "Received:" + xhr.responseText, true);
//alert("OK");
// Refresh the ToDo list
AAA.DSq.ELU(null, 'e-actions-todoview-list', 'ESV');
}
else { // error
AAA.EVI.sr (2, "", "Error code " + xhr.status, true);
alert("Error running agent. Error code: " + xhr.status);
}
}
};
// Set the POST params
var sNonce = AAA.HHT ? AAA.HHT() : AAA.getNonce();
var params = "%25%25Nonce=" + sNonce + "&yourparameters=" + unids;
// Send the request
xhr.open("POST", "./?EditDocument&Form=s_RunAgent&PresetFields=AgentName;YourAgentNameHere,CommonAgent;2", true);
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhr.send(params);
}