Add data query results to a form

This example shows how you can add text boxes to a form and then populate them with the results of a DME query. The example performs a query against an HR11 record and populates it to new fields that have been added to AP10. This example could be used to view Employee Expenses data in a situation where employees are vendors.

function FORM_OnAfterTransaction(data)
{
    // was transaction successful?
    if (formState.agsError)
    {
        return;
    }

    const vVen = lawForm.getDataValue("VEN-VENDOR");
    portalWnd.cmnDlg.messageBox(vVen);

    // Do DME Call to Get Last Review
    let s = portalWnd.DMEPath;
    s += "?PROD="+ strPDL;
    s += "&FILE=EMPLOYEE";
    s += "&FIELD=EMPLOYEE;LAST-NAME;FIRST-NAME";
    s += "&SELECT=EMPLOYEE=" + vVen;
    s += "&OUT=CSV&DELIM=~&NOHEADER";

    let sReturn = portalWnd.httpRequest(s, null, "text/plain", "text/plain");

    lawForm.setFormValue("text71","");
    lawForm.setFormValue("text72","");
    lawForm.setFormValue("text73","");

    if (!sReturn || sReturn.status > 400)
    {
        return;
    }

    sReturn = sReturn.replace(/\r/g,"");
    let aRecs = sReturn.split("\n");
    aRecs.pop();
    const aRecFields = aRecs[aRecs.length - 1].split("~");
    if (aRecFields[0] !== "")
    {
        lawForm.setFormValue("text71", aRecFields[0]);
    }
    if (aRecFields[1] !== "")
    {
        lawForm.setFormValue("text72", aRecFields[1]);
    }
    if (aRecFields[2] !== "")
    {
        lawForm.setFormValue("text73", aRecFields[2]);
    }
}