This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal


Aug 1, 2018, 6:56 AM
7 Posts

Custom_Scene_PostLoad_Lite example

  • Category: iNotes
  • Platform: Windows
  • Release: 9.0.1
  • Role: Developer
  • Tags: inotes 9 agent postload
  • Replies: 3

Hi all, I have to call a backend agent (lotusscript) in Custom_Scene_PostLoad_Lite of Custom_JS_Lite subform, to set a field value in memo form, but I don't know the exact syntax...

someone can give me an example?

Thanks in advance for any help

M

Aug 2, 2018, 12:18 PM
1 Posts
iNotes - call background agent

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);
}

Aug 3, 2018, 1:33 PM
7 Posts
how trigger agent

Hello Norbert, Many thanks for your answer, however I'm not able to trigger the agent, I put for example an alert just after the call:

function runAnAgent(sId) { 

alert ("OK");

but the alert is never displayed... my "scene" is memo opened from inbox (or other folder) in "read" mode... and after opening I must set a flag in backend...

thank you again,

M

Aug 6, 2018, 3:24 PM
7 Posts
found a way

Hello, I found the right way to call the agent in my "scene", I put this line before the call

if ((s_SceneName || '').split(':')[1] == 'EdT' && s_SceneName.indexOf('$new') == -1 )   {

var oElem = AAA.EcK.getElementById(s_SceneName.split(':')[0]);
var sContentId = oElem.getAttribute('com_ibm_dwa_ui_mailinfo_contentid');
var oContent = AAA.Fkb().getContent(sContentId);
var sDocUnid = oContent.sId;


     try {
         runAnAgent(sDocUnid); ...

Thank you again for your answer ,

M


This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal