Adding comments, toolbar buttons, and help options to a form

This example shows how to add a comments field and toolbar button to a form (AP10). It also gives an example of adding a help option in the navigation menu for the form.

function FORM_OnAfterTransaction(data) 
{ 
    // was transaction successful? 
    if (formState.agsError) 
    { 
        return; 
    } 
 
    // grab the value for the select box 
    const vList = lawForm.getFormValue("select12"); 
    if (vList !== "None") 
    { 
        addComment(vList); 
    } 
} 
 
function addComment(vList) 
{ 
    //Case for the four options 
    let vAudt; 
    switch (vList) 
    { 
        case "All": 
            vAudt = "A"; 
            break; 
        case "Report": 
            vAudt = "D"; 
            break; 
        case "Note": 
            vAudt = "N"; 
            break; 
        case "Check": 
            vAudt = "C"; 
            break; 
    } 
    // set variables from the form to use in API 
    const vComm = lawForm.getFormValue("textarea1"); 
    const vCompany = lawForm.getDataValue("API-COMPANY"); 
    const vVendor = lawForm.getDataValue("API-VENDOR"); 
    const  vInvoice = lawForm.getFormValue("text12"); 
    const vTitle = portalWnd.oUserProfile.getAttribute("lawsonusername"); 
 
    // build the API call for the writeattach cgi 
    let  s = portalWnd.WRITEATTACHPath + "?_OUT=XML&_PDL=" + strPDL; 
    s += "&_FN=APINVOICE&_IN=APISET1&K1=" + vCompany; 
    s += "&K2=" + vVendor; 
    s += "&K3=" + vInvoice; 
    s += "&K4=000&K5=0000&_ATYP=C&_AUDT=" + vAudt; 
    s += "&_USCH=none&_DATA=TRUE&_OPM=M&_ECODE=FALSE&_ANAM=" + vTitle; 
    s += "&_ATXT=" + vComm; 
 
    // send API to the server 
    portalWnd.httpRequest(s); 
 
    // Reset the Textarea and set the select to None 
    lawForm.setFormValue("textarea1",""); 
    lawForm.setFormValue("select12","None"); 
} 
 
function FORM_OnAfterFrameworkInit() 
{ 
    // add help menu item 
    const strHelp = "View WebEx"; 
    portalObj.helpOptions.addItem(strHelp, strHelp, "myWebExHelp()", window); 
 
    // create a new toolbar button to go to Job List 
    const btnText = portalObj.getPhrase("LBL_JOBS_REPORTS"); 
    toolbar.createButton(btnText, loadJobList, "btnJobList"); 
} 
 
function myWebExHelp() 
{ 
    // URL function to open Webex 
    portalWnd.openWindow("https://www.myCompany.com/help/802Diff.wrf"); 
} 
 
function loadJobList() 
{ 
    portalWnd.switchContents("reports/joblist.htm"); 
}